In SQL databases, what does the term "referential integrity" mean?
In SQL databases, what does the term "referential integrity" mean?
Solution
Referential integrity means the relationships between tables stay consistent. It is enforced through a foreign key: every foreign key value in the child table must match an existing primary key value in the parent table, or be NULL. This prevents orphan records, such as an order that refers to a customer who does not exist.
Option 1: this is entity integrity (uniqueness and non-null primary keys), not referential integrity.
Option 3: too general; it describes data integrity as a whole, of which referential integrity is only one type.
Option 4: this is about performance, which is handled by indexing and query optimisation.
Related questions:
2026: 29 May Shift 2
2025: 30 May Shift 2
2025: 22 May Shift 1