![]() ![]() What about changes that don't go through the application? Suppose you raise a support issue and a junior technician sends you a script to fix it - who or what will do the checking then? What when the application vendor is taken over and a whole new group of programmers takes the code in a different direction and accidentally (or otherwise) leaves out the relationship checks? No, database integrity should be enforced in the database layer.Īlso how else do you find about the bad allocation of records? With the foreign key you get a nice logged error (at least in any sensible application) that helps you track down the misallocation. While it's nice to have the extra check in the DB the work of determining appropriate foreign key values should already have been done in the application correctly, I don't think that's an unreasonable expectation. What is a better solution to "Low Tech Ley" problem without forcing him to give up his ORM that is polluting all his Java/C# code with schema details?ĮDIT: The bit I don't understand about "Low Tech Ley" solution is that after segregating all the data so that each logical database entity is the "responsibility" for a single micro-service, why does he still need to split the database up physically? He's already done it logically. His services are no longer independently deployable so he's sad. A schema change for one micro-service is in danger of propagating changes to other micro-services at the same time. His micro-services are highly decoupled except when it comes to the DB, because they all reference the same schema. I see "Low Tech Ley" problem as wanting to be able to make a change to single micro-service without impacting the other micro-services. Referential integrity isn't a problem that "Low Tech Ley" is trying to solve, it's a problem created by his solution to his actual problem. ![]() While it's nice to have the extra check in the DB the work of determining appropriate foreign key values should already have been done in the application correctly, I don't think that's an unreasonable expectation.Įven if a case can be made to not use Foreign Keys, you still have to live with "Low Tech Ley" wish to fragment the database into separate (micro)databases. If an application is so badly designed/developed it is consistently trying to assign bad foreign key values that is a problem that should be fixed at the root cause not by hiding it behind DB errors(once again as I said if an application is assigning bad foreign key values how do you know that even when it doesn't trigger a bad foreign key constraint it's actually assigning it to the right parent). I've never said I think foreign keys are bad, all I've said is that I don't understand why some people consider them a must have. It's nice to see you have extensive knowledge of my work experience based on my one opinion of one feature. It's clearly not a universal panacea to stop inconsistent data but it's practically a free check if designed in early, that allows the developers to concentrate on the real issues that will always come up on anything of any significance. ![]() This is a simple and obvious example that could of course be avoided - but there are a few thousand variations on this theme that can, do and will occur without foreign keys. The company loses money whilst this is fixed. Then some developer's assumption is proven wrong and the invoice screen and / or reports all stop working. Not to sound harsh, but have you ever done any real, complex database development work? It certainly sounds like you haven't.įor instance, typically what might occur is that some peculiar web hiccup allows an invoice to be entered without a customer. ![]() and in that example with foreign key constraints in place the customer still wouldn't get their order because not only would there not be a parent order there wouldn't even be line items which would make trying to track down the issue that much harder. We who build databases shouldn't as well. We don't expect people who build our homes to take shortcuts. This is a topic that speaks to professionalism. But for the customer who didn't get an order filled because there were line items but no header the impact is consequential. How "dire" the consequences are is perhaps open to interpretation. I guess you've never had to explain why parts of orders are missing and so on. I guess why I find this topic so interesting is that I keep hearing this "the consequences will dire" statement about not using foreign keys and I just don't see it ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |