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. Introduced in 5.9 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.
| Cypher® 25 includes the ability to set an open schema using graph types. Graph types include more additional, more sophisticated constraint types and a more holistic and simplified approach for constraining and maintaining the shape of the data in a graph. It is, therefore, recommended to define a schema using a graph type. For more information, see the Cypher® 25 Manual → Graph types. |