Referential integrity is a relational database concept.This is the most common type of integrity constraint. This is used to manage the relationships between primary and foreign keys. Referential integrity is best illustrated by an example.Let's assume the department and employee entities have been implemented as tables in a relational database system.When entering a new employee, the department in which they work needs to be specified. Department number is the foreign key in the employee table and the primary key in the department table.In order to preserve the integrity of the data in the database there are a set of rules that need to be observed:If inserting an employee in the employee table, the insertion should only be allowed if their department number exists in the department tableIf deleting a department in the department table, the deletion should only be allowed if there are no employees working in that departmentIf changing the value of a department number in the department table, the update should only be allowed if there are no employees working in the department whose number is being changedIf changing the value of a department number in the employee table, the update should only be allowed if the new value exists in the department tableIf any of the above is allowed to happen then we have data in an inconsistent state. The integrity of the data is compromised - the data does not make sense.
Referential integrity (RI) is a relational database concept, which states that table relationships must always be consistent. In other words, any foreign key field must agree with the primary key that is referenced by the foreign key. Thus, any primary key field changes must be applied to all foreign keys, or not at all. The same restriction also applies to foreign keys in that any updates (but not necessarily deletions) must be propagated to the primary parent key.
category should not be .NET
Foreign Key releationship in database