Reputation: 915
In Neo4J it is possible to create a UNIQUE constraints on nodes like this:
CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE
Is it possible to do the same with relationships.
Upvotes: 0
Views: 202
Reputation: 66967
If necessary, you can work around the lack of uniqueness constraint support for relationship types by "reifying" the relationships as nodes.
For example, instead of using this data model (where :BORROWS(id)
must be unique, which is not supported):
(:Person)-[:BORROWS {id: 123}]->(:Book)
you can use something like this (where :Borrowing(id)
must be unique, which is supported):
(:Person)-[:PERFORMS]->(:Borrowing {id: 123})-[:ON]->(:Book)
Upvotes: 1
Reputation: 590
It's not possible to apply unique constraints on relationships out of the box.
Upvotes: 1