Neo4j helps enforce data integrity with the use of constraints.
You can use unique constraints to ensure that property values are unique for all nodes with a specific label. Unique constraints do not mean that all nodes have to have a unique value for the properties — nodes without the property are not subject to this rule.
Remember that adding constraints is an atomic operation that can take a while — all existing data has to be scanned before Neo4j can turn the constraint “on”.
You can have multiple unique constraints for a given label.
To create a constraint that makes sure that your database will never contain more than one node with a specificlabel and one property value, use the IS
UNIQUE
syntax.
Query.
CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE
Copyright © 2013 Neo Technology