Skip to main content

4. Referential integrity




§ It is a database concept that ensures that relationships between tables remain consistent. When one table has a foreign key to another table.
§ Theconcept of referential integrity states that you may not add a record to the table that contains the foreign key unless there is a corresponding record in the linked table.
Example
§ Consider the situation where we have two tables: Employees and Managers.
§ The Employees table has a foreign key attribute entitled ManagedBy which points to the record for that employee’s manager in the Managers table.
Referential integrity enforces the following three rules:
1.      We may not add a record to the Employees table unless the ManagedBy attribute points to a valid record in the Managers table.
2.      If the primary key for a record in the Managers table changes, all corresponding records in the Employees table must be modifiedusing a cascading update.
3.      If a record in the Managers table is deleted, all corresponding records in the Employees table must be deleted using a cascading delete.









<<Prev                                                                                                                                              Next>>






Comments