Interview Question

What is referential integrity?

Referential integrity prevents invalid references between related tables.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

Referential integrity means foreign-key references remain valid. • A referencing value must match a referenced key or be NULL when allowed. • Deleting or changing referenced rows follows the configured action. • The database enforces the relationship across statements and transactions.

💡 SQL Example

ALTER TABLE orders ADD CONSTRAINT orders_customer_fk FOREIGN KEY (customer_id) REFERENCES customers(customer_id);

Result

ALTER TABLE

⚡ Quick Revision

Referential integrity prevents invalid references between related tables.