Hacker News new | past | comments | ask | show | jobs | submit login

"we should not use foreign keys"

Some Microsoft enterprise products were like this (e.g. Dynamics AX) - try understanding 5000 odd tables without any foreign keys!




All database designs have foreign keys whether they are enforced in the database or not. If they are not obvious from the documentation, that is a documentation problem.


Tangential, but this is one of the main reasons I never liked Ruby on Rails with Active Record when I first took a look at it. Not having DB-level foreign keys by default always drove me insane. Isn't maintaining data integrity/correctness half the point of using a SQL database lol?


What is the idea behind no foreign keys? Seems quite crazy.

Surely that defeats the whole relational database concept?

Without FKs you have no clearly defined relations.

Is the idea that you have no constraints imposed by FKs, but tables still have some sort of informal relation?


There were no foreign key constraints at the database level - the application must have been holding and enforcing the relevant constraints.

A bit of a pain when you are looking at the SQL database trying to understand how it is structured so you can extract data in a meaningful way.


Foreign keys as a concept are a critical portion of a data model, but may reasonably choose to not enable them via schema constraints due to write performance, scaling, sharding, or replication issues.


If you have a super high write throughput table (say a constant stream of sensor data) foreign keys and extra indexes can slow it down to too much. Besides that, you should always use foreign keys.




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

Search: