I need to go through and update the graph in SQL.
To bring this into the future, I will give an example:
- Each company may represent a different company in this subject.
- Companies may represent each other, but not for the same entity.
This assumes tables such as:
companies(id)
, representations(source_id, destination_id, subject)
.
But the rule is that when my company no longer represents you on this topic, no company from my network can represent my company on the same issue.
I hope you understand what I mean.
So, with simple data like:
C1: --sell--> C2 --pay--> C3 C2: --sell--> C3 --pay--> C1 C3: --mail--> C1 --sell--> C4 C4: --deliver-->C1
Now we delete the view (I should have called it a relation) C2--sell-->C3
we should get the following structure ( [X]
- deleted):
C1: --sell--> C2 --pay--> C3 C2: [X]--sell--> C3 --pay--> C1 C3: --mail--> C1 [X]--sell--> C4 C4: --deliver-->C1
So, the question is, how can I choose all the companies that are in the chain from mine for this subject?
I assume that a CTE recursive expression is the only way to do this.
NOTES:
- A structure is not a tree; it is an ordered cyclic graph.
- The graphical database is not an option right now (this is only a small part of the system)
- Updates do not have to be immediate, and itβs normal for them to be consistent in the long run (from a few seconds to a few minutes).
source share