What is referential integrity?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Database Design / Normalization basics — a prerequisite for any developer role.

Answer

Referential integrity ensures that relationships between tables remain consistent — a foreign key value in a child table must always match an existing primary key value in the parent table. It prevents orphan records (child rows with no matching parent). Enforced by the database via foreign key constraints. Violation examples: inserting an order for a non-existent customer, or deleting a customer who still has orders. Cascade options handle related row management: ON DELETE CASCADE, ON DELETE RESTRICT, ON DELETE SET NULL. Without referential integrity, data becomes inconsistent over time.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last Database Design / Normalization project, I used this when...' immediately makes your answer more credible and memorable.