Hacker News new | past | comments | ask | show | jobs | submit login
On the Usefulness (Or Lack Thereof) of Foreign Keys (bigeng.io)
2 points by stevencorona on Sept 28, 2015 | hide | past | favorite | 1 comment



Is this a troll to get mentioned in the "To Laugh Or To Cry" section of Database Debunkings?

Foreign key constraints, like all constraints are there to enforce integrity and to make relationships explicit (like a specification with teeth).

If every application accessing the database has to know about and enforce integrity constraints you are multiplying the work -- remember the DRY principle. Moving constraints out of the database seems like a good idea, if you have never worked with a system that has multiple applications accessing the database, written by different teams in different languages, over time. You are imagining a single application with a "database access layer," but even then you are duplicating functionality in application code that the RDBMS gives you.

If your production data is not important then go ahead and turn those constraints off. For real businesses the integrity and consistency of the business data is more important than application code.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: