diff --git a/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/lesson.adoc b/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/lesson.adoc index d9e3c0d00..b0725464c 100644 --- a/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/lesson.adoc +++ b/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/lesson.adoc @@ -1,10 +1,10 @@ = Constraints in Neo4j -:type: video +:type: lesson :order: 1 :sandbox: true -[.video] -video::N_m8Qb6vnfA[youtube,width=560,height=315] +// [.video] +// video::N_m8Qb6vnfA[youtube,width=560,height=315] //https://youtu.be/N_m8Qb6vnfA @@ -13,15 +13,16 @@ video::N_m8Qb6vnfA[youtube,width=560,height=315] A constraint is implemented internally as an index. It is used to constrain what is added to the graph. -There are three types of constraints you can define: -* Uniqueness for a single node property value or a set of node property values. -* Existence for a property of a node or relationship. -* Existence and uniqueness for a node property value or a set of node property values (Node key). +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: + +* Property uniqueness constraints - ensure that all values for a property are unique. +* Property existence constraints - ensure that a property exists. +* Key constraints - ensure that a combination of properties exists and is unique. === Uniqueness constraints -A uniqueness constraint can be defined for a property of a node with a given label. +A uniqueness constraint can be defined for a property. For example, in the Movie graph, we uniquely identify every Person node. 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 You will learn how to create and test an existence constraint later in this module. -=== Node key constraint +=== Key constraint -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: +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: -. Exist for all nodes with that label. +. Exist for all nodes or relationships with that label or type. . Be unique for all values. For example, suppose you want to ensure that all Person nodes in the graph have unique values for Person.name and Person.tmdbId. diff --git a/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/1-select-answer.adoc b/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/1-select-answer.adoc index 5b2089a7c..04a5eaaa2 100644 --- a/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/1-select-answer.adoc +++ b/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/1-select-answer.adoc @@ -1,19 +1,19 @@ [.question] = 1. What type of constraint can you define to ensure a _set of property values_ is unique? -* [ ] Uniqueness on a node property. +* [ ] Uniqueness on a property. * [ ] Uniqueness on a set of relationship type properties. -* [x] Node key for a set of properties of a node label. -* [ ] Uniqueness key for a set of properties of a node label. +* [x] Key constraint for a set of properties. +* [ ] Uniqueness key for a set of properties. [TIP,role=hint] .Hint ==== -There is one construct used to uniquely identify property values for a set of node labels. +There is one construct used to uniquely identify property values. ==== [TIP,role=solution] .Solution ==== -A Node key is used to ensure that a set of property values for all nodes of that label type are unique in the graph. +A key constraint is used to ensure that a set of property values for all nodes or relationships of that label or type are unique in the graph. ==== \ No newline at end of file diff --git a/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/2-select-answer.adoc b/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/2-select-answer.adoc index 7ef39069b..0976721db 100644 --- a/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/2-select-answer.adoc +++ b/asciidoc/courses/cypher-indexes-constraints/modules/2-constraints/lessons/01-constraint-overview/questions/2-select-answer.adoc @@ -1,19 +1,19 @@ [.question] -= 2. What type of constraint can be created for node properties or relationship properties? += 2. What type of constraint can be created? -* [ ] Node key -* [ ] Uniqueness +* [x] Key +* [x] Uniqueness * [x] Existence * [ ] IS NULL [TIP,role=hint] .Hint ==== -There is only one type of constraint that you can define on node properties or relationship properties. +You cannot create a constraint to ensure a property doesn't exist. ==== [TIP,role=solution] .Solution ==== -The correct answer is Existence constraint. +The correct answer are Key, Uniqueness, and Existence. ==== \ No newline at end of file