Databases & Data Storage

Referential Integrity

Definition

Referential integrity is a property of data stating that all its references are valid. For a relational database, it requires that if a value of one attribute (column) of a relation (table) references a value of another attribute, then the referenced value must exist.

Why It Matters

It is a crucial data integrity rule that prevents "orphan" records. It ensures that relationships between tables are always valid and consistent.

Contextual Example

If an `Orders` table has a `CustomerID` that refers to the `Customers` table, referential integrity ensures you cannot create an order for a non-existent customer. It also prevents you from deleting a customer who still has active orders.

Common Misunderstandings

  • Referential integrity is enforced using primary key and foreign key constraints.
  • Violating this integrity would lead to inconsistent and unusable data.

Related Terms

Last Updated: December 17, 2025