Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 892 Bytes

1005.md

File metadata and controls

14 lines (13 loc) · 892 Bytes

Foreign Key Does Not Exist

Consider adding a foreign key:

Are you leaving out the application constraints? Even though it seems at first that skipping foreign key constraints makes your database design simpler, more flexible, or speedier, you pay for this in other ways. It becomes your responsibility to write code to ensure referential integrity manually. Use foreign key constraints to enforce referential integrity. Foreign keys have another feature you can't mimic using application code: cascading updates to multiple tables. This feature allows you to update or delete the parent row and lets the database takes care of any child rows that reference it. The way you declare the ON UPDATE or ON DELETE clauses in the foreign key constraint allow you to control the result of a cascading operation. Make your database mistake-proof with constraints.