Referential Integrity • Ensures that a value that appears in one relation for a given set of attributes also appears for a certain set of attributes in another relation. • Example: If “Perryridge” is a branch name appearing in one of the tuples in the account relation, then there exists a tuple in the branch relation for branch “Perryridge”. • Primary and candidate keys and foreign keys can be specified as part of the SQL create table statement: • The primary key clause lists attributes that comprise the primary key. • The unique key clause lists attributes that comprise a candidate key. • The foreign key clause lists the attributes that comprise the foreign key and the name of the relation referenced by the foreign key. By default, a foreign key references the primary key attributes of the referenced table详细讲解以上
时间: 2024-04-28 15:22:03 浏览: 8
Referential Integrity is a concept in database design that ensures that the relationships between tables are maintained correctly. It ensures that if a value appears in one table's attribute, it must also appear in another table's attribute where it is referenced as a foreign key.
For example, if the account relation contains a tuple with a branch name of "Perryridge", there must be a corresponding tuple in the branch relation with the same branch name.
Primary keys and candidate keys are used to uniquely identify tuples in a table, and foreign keys are used to reference tuples in another table. In SQL, these keys can be specified using the create table statement.
The primary key clause lists the attributes that make up the primary key, which uniquely identifies each tuple in a table. The unique key clause lists the attributes that make up a candidate key, which is a set of attributes that can also uniquely identify each tuple in a table.
The foreign key clause lists the attributes that make up the foreign key and the name of the referenced table. By default, a foreign key references the primary key attributes of the referenced table.
Overall, referential integrity ensures the consistency and accuracy of data in a database by enforcing the relationships between tables.