01
What is a foreign key and what is referential integrity?
Show answer
A foreign key is a column in one table that refers to the primary key of another, such as orders.customer_id pointing to customers.customer_id. Referential integrity means every foreign key value must exist in the parent table, so you cannot have an order for a customer who does not exist. The database enforces it on insert, update and delete, which keeps joins reliable for reporting.