How a foreign key works: why the database refuses customer 9
How a foreign key works: why the database refuses customer 9
Order 104 points at customer 9. There is no customer 9, so the database refuses it.
A foreign key is a column that has to match a real row in another table. It also stops you deleting a customer who still has orders, unless you ask for cascade, which takes her orders with her.
Save it for the next time you see FOREIGN KEY constraint failed.
#sql #database #foreignkey #coding #learnsql #technology