CREATE CONSTRAINT ON (p:Person)
ASSERT p.name IS UNIQUE
Create a unique property constraint on the label Person and property name .
If any other node with that label is updated or created with a name that
already exists, the write operation will fail.
This constraint will create an accompanying index.
|
CREATE CONSTRAINT uniqueness ON (p:Person)
ASSERT p.age IS UNIQUE
Create a unique property constraint on the label Person and property age with the name uniqueness .
If any other node with that label is updated or created with a age that
already exists, the write operation will fail.
This constraint will create an accompanying index.
|
CREATE CONSTRAINT ON (p:Person)
ASSERT exists(p.name)
(★) Create a node property existence constraint on the label Person and property name , throws an error if the constraint already exists.
If a node with that label is created without a name , or if the name property is
removed from an existing node with the Person label, the write operation will fail.
|
CREATE CONSTRAINT node_exists IF NOT EXISTS ON (p:Person)
ASSERT exists(p.name)
(★)(★★) If a node property existence constraint on the label Person and property name or any constraint with the name node_exists already exist then nothing happens.
If no such constraint exists, then it will be created.
|
CREATE CONSTRAINT ON ()-[l:LIKED]-()
ASSERT exists(l.when)
(★) Create a relationship property existence constraint on the type LIKED and property when .
If a relationship with that type is created without a when , or if the when property is
removed from an existing relationship with the LIKED type, the write operation will fail.
|
CREATE CONSTRAINT relationship_exists ON ()-[l:LIKED]-()
ASSERT exists(l.since)
(★) Create a relationship property existence constraint on the type LIKED and property since with the name relationship_exists .
If a relationship with that type is created without a since , or if the since property is
removed from an existing relationship with the LIKED type, the write operation will fail.
|
CREATE CONSTRAINT ON (p:Person)
ASSERT (p.firstname, p.surname) IS NODE KEY
(★) Create a node key constraint on the label Person and properties firstname and surname .
If a node with that label is created without both firstname and surname
or if the combination of the two is not unique,
or if the firstname and/or surname labels on an existing node with the Person label
is modified to violate these constraints, the write operation will fail.
|
CREATE CONSTRAINT node_key ON (p:Person)
ASSERT (p.name, p.surname) IS NODE KEY
(★) Create a node key constraint on the label Person and properties name and surname with the name node_key .
If a node with that label is created without both name and surname
or if the combination of the two is not unique,
or if the name and/or surname labels on an existing node with the Person label
is modified to violate these constraints, the write operation will fail.
|
DROP CONSTRAINT uniqueness
Drop the constraint with the name uniqueness , throws an error if the constraint does not exist.
|
DROP CONSTRAINT uniqueness IF EXISTS
(★★) Drop the constraint with the name uniqueness if it exists, does nothing if it does not exist.
|