Are foreign keys really necessary in a database design? Are foreign keys really necessary in a database design? oracle oracle

Are foreign keys really necessary in a database design?


Foreign keys help enforce referential integrity at the data level. They also improve performance because they're normally indexed by default.


Foreign keys can also help the programmer write less code using things like ON DELETE CASCADE. This means that if you have one table containing users and another containing orders or something, then deleting a user could automatically delete all orders that point to that user.


I can't imagine designing a database without foreign keys. Without them, eventually you are bound to make a mistake and corrupt the integrity of your data.

They are not required, strictly speaking, but the benefits are huge.

I'm fairly certain that FogBugz does not have foreign key constraints in the database. I would be interested to hear how the Fog Creek Software team structures their code to guarantee that they will never introduce an inconsistency.