javaneo4jgraph-databasesneo4j-java-apineo4j-bolt

How to add user defined constraints on a node/relationship in Neo4j using Java API


Consider I have a node having Label L1 in Neo4j database. I need to put a constraint on all nodes having label L1 such that there shall be no outgoing edge from these nodes. So whenever user tries to add an outgoing edge from these nodes, a constraint violation occurs. Is it possible to add user defined constraints on nodes and relationships?

If yes, how can I put such constraint(s) on nodes/relationships using Neo4j Java API's?


Solution

  • According to the Neo4j constraints documentation there is no way to do this.

    I think you should delegate this type of responsibility to the application layer. Alternatively, you can try achieve your goal writing your own user defined procedure.