Referential integrity

Referential integrity is a concept in relational databases that ensures the relationships between tables are maintained. It enforces the consistency and validity of the relationships between tables by defining rules that must be followed when inserting, updating, or deleting records. Those rules are part of the data model, declared as foreign-key constraints in the foreign keys that link a child table to its parent.

Eventual referential integrity refers to a state in which the relationships between tables are eventually consistent, even if they are not immediately consistent at all times. This concept is often used in distributed databases and other distributed software that persists state, where immediate consistency is not always feasible due to latency, network partitions, or other factors. Delayed enforcement of referential integrity constraints may be necessary to ensure that the system remains operational even when immediate consistency is not possible.

Referential integrity is one aspect of the broader goal of data integrity. Normalization is the schema-level discipline that keeps redundant copies of the same relationships from arising in the first place, so referential integrity has fewer references to police.

See also