cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Constraint on number/type of relations per node

I have two types of nodes: :Person and :Event.
Between these nodes there can be several different relations: :DECEDENT, :SPOUSE, :CHILD, :PARENT, etc.

Q1: Is it possible to set constraint on allowed relation types for specific :Event type?
Example:
For (:Event {id: "9452ae03-8f8c-4675-a7aa-21ed9e868559", type: "Death"}) only allowed relation should be (:Event)-[:DECEDENT]->(:Person) and all other relation types should be banned.

Q2: Is it possible to set limit on relation count per node?
Example: Following above case node :Person should be pointed by [0-1] :DECEDENT relation.
I would imagine syntax to be sth like:
CREATE CONSTRAINT ON (:Event)-(r:DECEDENT)->(:Person) ASSERT count(r) < 2

2 REPLIES 2

Constraint functionality and what is possible is described at Constraints - Neo4j Cypher Manual

and to which at this time for Q1 and Q2 from the initial post, both are not possible

Would it be feature that could be implemented in the future?