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

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?

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.

1 Like

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)

1 Like

Indeed, this would be a very helpful feature.