cancel
Showing results for 
Search instead for 
Did you mean: 

Unique Constraint on Relationship Types

dheerajk
Node

Neo4j Version: Neo4j Enterprise 4.3.5
API : Neo4j Java Driver

Neo4j does not support Unique property constraints on relationships; however, I need to enforce uniqueness for a property within a Relationship Type. What is the best way to achieve that?

1 REPLY 1

The best thing is to put up a feature request on github.

For now on relationships there are only existence constraints and indexes.

So you would have to do it manually, by using MERGE on a relationship, and possibly taking a lock on a central node for concurrency safety.

MERGE (start)-[:TYPE {id:$relId}]->(end)

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.