Reputation: 153
Is there a way in Neo4j 3 to set edge multiplicity settings for edges with a given label or property?
For example, if I had a "biological mother" relationship, I would want to enforce a many-to-one edge multiplicity for relationships of this type.
I'm looking for something similar as the edge multiplicity settings in JanusGraph.
As a follow up question, what setting values are available if defining edge multiplicity is possible?
Upvotes: 0
Views: 110
Reputation: 30397
Neo4j currently doesn't have constraints to support this kind of usage (restricting edge multiplicity on nodes of a given label). You could do this yourself, however.
You could do this via APOC Procedures by adding a trigger that can check, when you add a relationship of the given type to a node, that the nodes linked adhere your expected multiplicity limits.
If you want to do this without APOC, you would need to create a TransactionEventHandler to perform the check, and then you'd need to create a kernel extension for the purpose of loading your TransactionEventHandler instance. Here's a blog entry describing this approach.
Upvotes: 1