Complex schema constraints and constraint discovery - anyone tried it?

Skip to first unread message

Mark Novak

Oct 21, 2019, 2:38:02 PM10/21/19
to Neo4j
I have a requirement of placing a set of constraints on nodes, relationships and properties, and making these discoverable.

For instance, a constraint might be that a relationship X may exist between nodes with labels A and B, , D and B, or B and C, but not between A and C or A and D.
Or, a constraint may be that a property P set on a node with label A might only have a number of valid values: P1 or P2. An attempt to create a node with label A and a property P set to anything other than P1 and P2 would be invalid.

Further, I'd like to be able to query these constrains to offer only legal choices when new nodes and relationships are created.

Has anyone had a similar problem? How have you solved it?

I am thinking of modeling these constraints as a graph in their own right, but maybe there is an existing solution or idea I should look at?


Michael Hunger

Oct 21, 2019, 2:41:13 PM10/21/19
Did you see the ontology checking article on
There is also imho a constraints extension from GraphAware for that.

I think you should also be able to use apoc triggers to veto transactions that violate your constraints.

You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages