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.

Can I have a Constraint that a specific Relationship exists between two nodes/labels?

admin3
Node Clone

So I create a node labelled User and another node labelled Profile which are connected with HAS_PROFILE i.e. (user:User)-[rel:HAS_PROFILE]->(profile:Profile).

Can I create a constraint that Profile nodes always have a HAS_PROFILE relationship coming from User nodes?

1 ACCEPTED SOLUTION

Unfortunately not at this time.

We definitely like this idea, it's been on our backlog, but then there's a lot of feature requests on our backlog. It's a matter of prioritizing and planning. While I have no doubt we'll get this one eventually, I don't have any idea on when that will happen.

You could probably implement a trigger for this, but you'd need to add the logic yourself for checking when a node is created or a relationship removed.

View solution in original post

3 REPLIES 3

Unfortunately not at this time.

We definitely like this idea, it's been on our backlog, but then there's a lot of feature requests on our backlog. It's a matter of prioritizing and planning. While I have no doubt we'll get this one eventually, I don't have any idea on when that will happen.

You could probably implement a trigger for this, but you'd need to add the logic yourself for checking when a node is created or a relationship removed.

Indeed, this would be a very helpful feature.

clem
Graph Steward

I'd sure like to see constraints on relationship from-to. For the dyslexics, it's way too easy to make the relationship go in the wrong direction and not realize the mistake.

In case you do, there is this APOC function: call apoc.refactor.invert(rel)