A hyper-edge is a graph construct that is a relationship with 3 or more endpoints. Neo4j does not have these, but I would like to fake one in Neo4j.
The idea would follow this example of modeling a contract:
- Create a node label called "ContractHyperEdge"
- Create two nodes with the label "Person", and one with the label "Contract".
- Create a trigger for the ContractHyperedge label that says whenever any node with that label is created or modified, do not save changes unless it is connected to two Contract node and one Person nodes.
It's tricky because even if you manage to enforce the 2-Person 1-Contract rule on the ContractHyperedge itself, it would be hard to enforce that rule on the connected contract or person nodes. If someone were to delete one of the persons from the database, then the hyper-edge should either prevent that from happening or terminate itself.
Can anyone recommend an approach, even different from mine?