kew
kew

Reputation: 11

Constraint on relationship existence (Cypher)

I am trying to create a relationship similar to the following:

  create constraint hasSource for (i:Information)-[r:SOURCED_FROM]->(s: Source) assert r is not null

Essentially I want all information nodes to have (at least one) source.

Upvotes: 0

Views: 280

Answers (1)

Charchit Kapoor
Charchit Kapoor

Reputation: 9284

It's not possible as per the latest version of neo4j. You can create an existence constraint on the property of a relationship, but you cannot create a constraint between two nodes, to have a particular relation. This sort of validation needs to be taken care of at the application level.

Here is link to the documentation related to constraints.

Upvotes: 1

Related Questions