Commencing with Neo4j 2.3.x it is possible to create the equivalent of a primary key on a property of a label. For example the following Cypher
CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE CREATE CONSTRAINT ON (book:Book) ASSERT exists(book.isbn)
will create two constraints on the property
isbn of nodes with label
Book and ensure that when a new Book node is created, its
isbn must be defined, and that it must be unique across all nodes with the
Property existence constraints are only available in the Neo4j Enterprise Edition. Databases with property existence constraints cannot be opened using Neo4j Community Edition.
- Last Modified: 2020-08-03 16:12:21 UTC by Dana Canzano.
- Relevant for Neo4j Versions: 3.4,3.5.
- Relevant keywords cypher.