How to create unique CONSTRAINT to relationship by neo4j cypher?
If I understood your problem correctly, you want to enforce uniqueness of certain kind of relation rather than uniqueness of relation's certain attribute. If that's what you want, then you enforce such uniqueness by using "CREATE UNIQUE":
MATCH (root { name: 'root' })
CREATE UNIQUE (root)-[:LOVES]-(someone)
RETURN someone
The Neo4j Manual: Create unique relationships
it seems that a relationship constraint can only enforce the existence of a relationship property but not its uniqueness
CREATE CONSTRAINT ON ()-[like:LIKED]-() ASSERT exists(like.day)
http://neo4j.com/docs/developer-manual/current/cypher/#query-constraints-prop-exist-rels
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With