Professional Documents
Culture Documents
1
9/28/2017
2
9/28/2017
Referential Integrity
• Applies to Foreign Keys Referential Integrity
• If all foreign key constraints are enforced, referential integrity is
achieved, i.e. there are no ‘dangling references’ in the database • FK’s prevent accidental deletion
• if a foreign key in Table 1 refers to the Primary Key of Table 2, Once defined, your DBMS does not allow the deletion of rows that
then every value of the Foreign Key in Table 1 must be null or have related rows in other tables.
be available in Table 2. For example, E.g. can’t delete a customer (Customer ID) with associated orders;
Must delete orders first (attend to them) and then the customer.
3
9/28/2017
Unique Constraints
Unique Constraints
• Ensure all data in a column or set of columns is unique; • A relation is defined as a set of tuples. All tuples or all
• Example of (Stu-No and Reg-No) rows in a relation must be unique or distinct. Suppose if in
• Similar to PK.s but: a relation, tuple uniqueness constraint is applied, then all
Can contain null the rows of that table must be unique i.e. it does not
A table can have several UC’s, but only one PK; contain the duplicate values. For example,
Can be modified or updated
Cannot be used to define FK’s.