Customers
customer_id
Orders
order_id
customer_id fk
If I have two tables and define a foreign key on customer_id in the Orders table, by allow
There is another situation that I can think of:
Within one table, you have an ID field that uniquely identifies that record. That same record may (or may not) have a single parent.
Table with the following columns:
With a foreign key constraint, you can ensure that if the field is not null, then it refers to a valid parent. Furthermore, if you attempt to delete the parent record without fixing the children, then the parent cannot be deleted.