I'm wondering how helpful foreign secrets actually are inside a database. Basically, when the designers understand what secrets the various tables rely on, they are able to write the queries just as if there is an overseas key, right?
Also, I actually do observe how to foreign-key constraints assist in preventing a variety of bugs with data integrity, but say for instance, the developers perform a good job of protecting data integrity, how necessary are foreign secrets really?
If you do not worry about referential integrity then you're right. You Need To Worry About REFERENTIAL INTEGRITY
However , people get some things wrong. Computer systems don't.
Relating to your comment:
but say for instance, the developers perform a good job of protecting data integrity
Someone will ultimately get it wrong. We're not perfect. And if you bring somebody new in your soul aren't always certain of remarkable ability to create "perfect" code.
Additionally to that particular you loose a chance to do cascading down removes and many other features that getting defined foreign secrets allow.
The question for you is why wouldn't you need to have foreign secrets defined?
Foreign secrets are invaluable as a way of making certain integrity, and even when you believe in designers never to (!) make errors the price of getting them is generally worthwhile.
Foreign secrets also function as documentation, for the reason that you can observe what pertains to what. This post is typically also utilized by tools, such for producing reviews, creating data sets from table definitions, object-relational mappers, etc. Even when you don't use these today, getting FKs can make it simpler to tread that path later.
Foreign secrets also permit you to define cascade rules, which e.g. may be used to to remove connected records in related tables whenever a row in a single table is erased.
Only when you've absurdly high loads in the event you consider skipping FKs.
Edit: up-to-date response to include points using their company solutions (reviews, cascades).
I believe that presuming that developers will invariably preserve data integrity is really a dangerous assumption.
There is no reason you would not create foreign secrets, or being able to guarantee integrity rather than just wishing for integrity is sufficient cause.
It's not necessary to rely on them but thinking about?
They're exist for. From making existence simpler with cascade updates and cascade removes, to ensuring that constraints aren't violated.
Maybe the applying honors the restrictions, but is not it helpful to possess them clearly specified? You could document them, or you might insert them in the database where most developers anticipate finding constraints they are meant to comply with (a much better idea I believe!).
Finally, should you ever have to import data into this database which does not go through the front-finish, you might accidently import data which violates the restrictions and breaks the applying.
I'd definetly not recommend missing the associations inside a database
Foreign Secrets make existence a lot simpler when utilizing report contractors and data analysis tools. Just choose one table, look into the
include related tables box and BAM! you have you are report built. Ok Ok, it isn't that simple, however they certianly save your time for the reason that respect.