I have come across this scenario several times in different projects. Here is a chart of four tables marked with letters:
A 1 / \ 1 / \ * / \ * BC 1 \ / 1 \ / * \ / * D
In this case, the data may become inconsistent if the keys from B to A and C to A do not match for the given D
For a specific (compiled) example, imagine A is Company , B is Employee , C is Project , and D is WorkItem . In this case, there is nothing that could stop the creation of a work item that claims to be assigned to a person who does not even work for the company that owns the project.
I'm basically just curious if there is a design solution to this problem? I know that in real applications, when it matters, you can use triggers or some other protection. I did not find a way to modify the tables to make such inconsistency impossible. Is there any way?
Please note that only disconnecting one of the connections, for example from C to A , does not work, because if there is no D for C , you will not have a way to track connections to A
database-design
Tesserex
source share