Question

1.How should I prevent nodes to have relationships with themselves in neo4j graph?

2.How should I force nodes to have only one relationship with each other,I mean if node A have relationship with node B this way: A--->B, there should not be any B--->A?

I know in graph making everything is on my own so I can handle both of them,but consider there is a java api which user says which nodes and relationships should be created,but I want to prevent user from 1 and 2?

Is there any possibility in neo4j for handling them?

Was it helpful?

Solution

You can implement a [TransactionEventHandler][1] that performs the enforcing your constraints and register it with your GraphDatabaseService instance. A TransactionEventHandler can inspect the contents of the current transaction and eventually veto on committing, see http://docs.neo4j.org/chunked/stable/transactions-events.html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top