You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/lesson.adoc
A constraint is implemented internally as an index.
15
15
It is used to constrain what is added to the graph.
16
-
There are three types of constraints you can define:
17
16
18
-
* Uniqueness for a single node property value or a set of node property values.
19
-
* Existence for a property of a node or relationship.
20
-
* Existence and uniqueness for a node property value or a set of node property values (Node key).
17
+
You can define link:https://neo4j.com/docs/cypher-manual/current/constraints/[different types of constraint^] that apply to nodes with a specific label or relationships of a type, including:
18
+
19
+
* Property uniqueness constraints - ensure that all values for a property are unique.
20
+
* Property existence constraints - ensure that a property exists.
21
+
* Key constraints - ensure that a combination of properties exists and is unique.
21
22
22
23
=== Uniqueness constraints
23
24
24
-
A uniqueness constraint can be defined for a property of a node with a given label.
25
+
A uniqueness constraint can be defined for a property.
25
26
26
27
For example, in the Movie graph, we uniquely identify every Person node.
27
28
To do this, we identify a property whose value will be unique for all nodes with the Person label.
@@ -128,11 +129,11 @@ RETURN p
128
129
129
130
You will learn how to create and test an existence constraint later in this module.
130
131
131
-
=== Node key constraint
132
+
=== Key constraint
132
133
133
-
A node key is a specialized type of constraint in the graph that enables you to define a set of properties for a node label that must:
134
+
A key is a specialized type of constraint in the graph that enables you to define a set of properties for a node label or relationship type that must:
134
135
135
-
. Exist for all nodes with that label.
136
+
. Exist for all nodes or relationships with that label or type.
136
137
. Be unique for all values.
137
138
138
139
For example, suppose you want to ensure that all Person nodes in the graph have unique values for Person.name and Person.tmdbId.
0 commit comments