Constraints
Neo4j offers several constraints to ensure the quality and integrity of data in a graph. The following constraints are available in Neo4j:
-
Property uniqueness constraints: ensure that the combined property values are unique for all nodes with a specific label or all relationships with a specific type.
-
Property existence constraints: ensure that a property exists either for all nodes with a specific label or for all relationships with a specific type. Enterprise Edition
-
Property type constraints: ensure that a property has the required property type for all nodes with a specific label or for all relationships with a specific type. Enterprise Edition
-
Key constraints: ensure that all properties exist and that the combined property values are unique for all nodes with a specific label or all relationships with a specific type.Enterprise Edition
For more information about index-backed constraints, constraint creation failures and data violation scenarios, as well as creating, listing and dropping constraints, see:
For reference material about the Cypher® commands used to manage constraints, see Syntax → Constraints.
|
All constraints created using the older It is, therefore, recommended to define a schema using a graph type, which offers both additional, more sophisticated constraint types and a more holistic and simplified approach for constraining and maintaining the shape of the data in a graph. For more information, see Graph types. |