4 ms·
So basically the author is saying that experience says foreign keys are good, but in practice foreign keys make development and switching data providers harder.
by fnid 17y ago
So basically the author is saying that experience says foreign keys are good, but in practice foreign keys make development and switching data providers harder.
Seems like an experienced developer would have written a data access layer that wasn't so concerned about how the underlying data store managed foreign keys. Almost all senior level developers know that foreign keys are a performance inhibitor and plans for eventual denormalization of data.
I'm wondering if this person is actually an experience developer or not. He starts out saying one of the problems he solved would be to “figure out a way to speed up the data processing”, yet he doesn't understand how foreign keys play into this and had to work around normalization?
I also wonder exactly why it took so long to rewrite the application because of foreign keys. I've never migrated from mysql to postgres but if the process was so time consuming to warrant a blog post like this, I really question the amount of experience this individual really has.
- gaius 17y agoIf the purpose of your foreign key is to ensure data integrity, then no amount of denormalizing can help. The point of FKs is to enforce business rules in a central location (e.g. don't ship a part to a non-existent customer, if a customer's address changes then there's only one place to update, etc). The alternative to FKs is to write your own "middleware" or "business rules engine" and guess what, that doesn't get you to market any quicker either.
- fnid 17y agoMy point was only that it seems the author of the post has limited experience with foreign keys.