Neo4j Create Constraints
In Neo4j, a constraint is used to place restrictions over the data that can be entered against a node or a relationship.
There are two types of constraints in Neo4j:
Uniqueness Constraint: It specifies that the property must contain a unique value. (For example: no two nodes with an player label can share a value for the Goals property.)
Property Existence Constraint: It makes ensure that a property exists for all nodes with a specific label or for all relationships with a specific type.
Create a Uniqueness Constraint
CREATE CONSTRAINT ON statement is used to create a uniqueness constraint in Neo4j.
Use the :schema command to check the constraints.
Property Existence Constraint
Property existence constraint is used to make ensure that all nodes with a certain label have a certain property.
Note: exists property constraint are only available in the Neo4j Enterprise Edition.