From ace6614997cbbf37dd6db9f090eb9e711dd6b096 Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Fri, 18 Nov 2022 14:38:12 +0100 Subject: [PATCH 01/12] Update create constraint plan operator to reflect implementation --- .../execution-plans/operator-summary.adoc | 22 +-- .../ROOT/pages/execution-plans/operators.adoc | 134 ++---------------- 2 files changed, 12 insertions(+), 144 deletions(-) diff --git a/modules/ROOT/pages/execution-plans/operator-summary.adoc b/modules/ROOT/pages/execution-plans/operator-summary.adoc index 23a525efd..00123b90c 100644 --- a/modules/ROOT/pages/execution-plans/operator-summary.adoc +++ b/modules/ROOT/pages/execution-plans/operator-summary.adoc @@ -88,26 +88,8 @@ Tests for the absence of a pattern predicate. | label:yes[] | -| xref::execution-plans/operators.adoc#query-plan-create-node-key-constraint[CreateNodeKeyConstraint] -| Creates a node key constraint on a set of properties for all nodes with a certain label. -| -| label:yes[] -| - -| xref::execution-plans/operators.adoc#query-plan-create-node-property-existence-constraint[CreateNodePropertyExistenceConstraint] -| Creates an existence constraint on a property for all nodes with a certain label. -| -| label:yes[] -| - -| xref::execution-plans/operators.adoc#query-plan-create-relationship-property-existence-constraint[CreateRelationshipPropertyExistenceConstraint] -| Creates an existence constraint on a property for all relationships of a certain type. -| -| label:yes[] -| - -| xref::execution-plans/operators.adoc#query-plan-create-unique-constraint[CreateUniqueConstraint] -| Creates a unique constraint on a set of properties for all nodes with a certain label. +| xref::execution-plans/operators.adoc#query-plan-create-constraint[CreateConstraint] +| Creates a constraint for either nodes or relationships. | | label:yes[] | diff --git a/modules/ROOT/pages/execution-plans/operators.adoc b/modules/ROOT/pages/execution-plans/operators.adoc index 9dcfaf2d2..634a006bc 100644 --- a/modules/ROOT/pages/execution-plans/operators.adoc +++ b/modules/ROOT/pages/execution-plans/operators.adoc @@ -4879,15 +4879,20 @@ Total database accesses: 106, total allocated memory: 184 ====== -[[query-plan-create-unique-constraint]] -== Create Unique Constraint -// CreateUniqueConstraint +[[query-plan-create-constraint]] +== Create Constraint +// CreateConstraint + + +The `CreateConstraint` operator creates a constraint. + +This constraint can either be an uniqueness, existence, node key, or relationship key constraint. +Existence, node key, and relationship key constraints will only appear in Enterprise Edition. -The `CreateUniqueConstraint` operator creates a unique constraint on a set of properties for all nodes having a certain label. The following query will create a unique constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label. -.CreateUniqueConstraint +.CreateConstraint ====== .Query @@ -4960,125 +4965,6 @@ Total database accesses: ? ====== - -[[query-plan-create-node-property-existence-constraint]] -== Create Node Property Existence Constraint -// CreateNodePropertyExistenceConstraint - -The `CreateNodePropertyExistenceConstraint` operator creates an existence constraint with the name `existence` on a property for all nodes having a certain label. -This will only appear in Enterprise Edition. - - -.CreateNodePropertyExistenceConstraint -====== - -.Query -[source, cypher, role="noplay"] ----- -CREATE CONSTRAINT existence -FOR (p:Person) REQUIRE p.name IS NOT NULL ----- - -.Query Plan -[source, query plan, subs="attributes+", role="noheader"] ----- -Planner ADMINISTRATION - -Runtime SCHEMA - -Runtime version {neo4j-version-minor} - -+-------------------+------------------------------------------------------------------+ -| Operator | Details | -+-------------------+------------------------------------------------------------------+ -| +CreateConstraint | CONSTRAINT existence FOR (p:Person) REQUIRE (p.name) IS NOT NULL | -+-------------------+------------------------------------------------------------------+ - -Total database accesses: ? ----- - -====== - - -[[query-plan-create-node-key-constraint]] -== Create Node Key Constraint -// CreateNodeKeyConstraint - -The `CreateNodeKeyConstraint` operator creates a node key constraint with the name `node_key` which ensures -that all nodes with a particular label have a set of defined properties whose combined value is unique, and where all properties in the set are present. -This will only appear in Enterprise Edition. - - -.CreateNodeKeyConstraint -====== - -.Query -[source, cypher, role="noplay"] ----- -CREATE CONSTRAINT node_key -FOR (e:Employee) REQUIRE (e.firstname, e.surname) IS NODE KEY ----- - -.Query Plan -[source, query plan, subs="attributes+", role="noheader"] ----- -Planner ADMINISTRATION - -Runtime SCHEMA - -Runtime version {neo4j-version-minor} - -+-------------------+-----------------------------------------------------------------------------------+ -| Operator | Details | -+-------------------+-----------------------------------------------------------------------------------+ -| +CreateConstraint | CONSTRAINT node_key FOR (e:Employee) REQUIRE (e.firstname, e.surname) IS NODE KEY | -+-------------------+-----------------------------------------------------------------------------------+ - -Total database accesses: ? ----- - -====== - - -[[query-plan-create-relationship-property-existence-constraint]] -== Create Relationship Property Existence Constraint -// CreateRelationshipPropertyExistenceConstraint - -The `CreateRelationshipPropertyExistenceConstraint` operator creates an existence constraint with the name `existence` on a property for all relationships of a certain type. -This will only appear in Enterprise Edition. - - -.CreateRelationshipPropertyExistenceConstraint -====== - -.Query -[source, cypher, role="noplay"] ----- -CREATE CONSTRAINT existence -FOR ()-[l:LIKED]-() REQUIRE l.when IS NOT NULL ----- - -.Query Plan -[source, query plan, subs="attributes+", role="noheader"] ----- -Planner ADMINISTRATION - -Runtime SCHEMA - -Runtime version {neo4j-version-minor} - -+-------------------+-----------------------------------------------------------------------+ -| Operator | Details | -+-------------------+-----------------------------------------------------------------------+ -| +CreateConstraint | CONSTRAINT existence FOR ()-[l:LIKED]-() REQUIRE (l.when) IS NOT NULL | -+-------------------+-----------------------------------------------------------------------+ - -Total database accesses: ? ----- - -====== - - [[query-plan-drop-constraint]] == Drop Constraint // DropConstraint From 3c4777ca6dc4debe8f126243913def8ceefcf075 Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Tue, 22 Nov 2022 16:08:57 +0100 Subject: [PATCH 02/12] Document relationship key and uniqueness constraints and also allowing `UNIQUENESS` for the type filtering in `SHOW UNIQUE CONSTRAINTS` --- modules/ROOT/pages/constraints/examples.adoc | 724 +++++++++++++++++- modules/ROOT/pages/constraints/index.adoc | 33 +- modules/ROOT/pages/constraints/syntax.adoc | 141 +++- ...ions-additions-removals-compatibility.adoc | 67 ++ modules/ROOT/pages/keyword-glossary.adoc | 16 +- 5 files changed, 912 insertions(+), 69 deletions(-) diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index 74fed31b0..d5ae1fd80 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -12,19 +12,19 @@ Examples of how to manage constraints used for ensuring data integrity. [[administration-constraints-unique-nodes]] == Unique node property constraints -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint[] -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-only-if-it-does-not-already-exist[] -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-with-specified-index-provider[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-an-already-existing-unique-property-constraint[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-on-same-schema-as-existing-index[] +* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes[] +* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes-only-if-it-does-not-already-exist[] +* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes-with-specified-index-provider[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-nodes[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-nodes-on-same-schema-as-existing-index[] * xref::constraints/examples.adoc#administration-constraints-create-a-node-that-complies-with-unique-property-constraints[] * xref::constraints/examples.adoc#administration-constraints-create-a-node-that-violates-a-unique-property-constraint[] * xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-nodes[] [discrete] -[[administration-constraints-create-a-unique-constraint]] -=== Create a unique constraint +[[administration-constraints-create-a-unique-constraint-nodes]] +=== Create a node unique constraint When creating a unique constraint, a name can be provided. The constraint ensures that your database will never contain more than one node with a specific label and one property value. @@ -49,19 +49,24 @@ FOR (book:Book) REQUIRE book.isbn IS UNIQUE Unique constraints added: 1 ---- +[NOTE] +==== +The statistics will be updated to say `Node uniqueness constraints` in 6.0. +==== + ====== [discrete] -[[administration-constraints-create-a-unique-constraint-only-if-it-does-not-already-exist]] -=== Create a unique constraint only if it does not already exist +[[administration-constraints-create-a-unique-constraint-nodes-only-if-it-does-not-already-exist]] +=== Create a node unique constraint only if it does not already exist If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. The uniqueness constraint ensures that your database will never contain more than one node with a specific label and one property value. [NOTE] ==== -No constraint will be created if any other constraint with the given name or another uniqueness constraint on the same schema already exists. +No constraint will be created if any other constraint with the given name or another node uniqueness constraint on the same schema already exists. ==== @@ -75,7 +80,7 @@ CREATE CONSTRAINT constraint_name IF NOT EXISTS FOR (book:Book) REQUIRE book.isbn IS UNIQUE ---- -Assuming no constraint with the given name or other uniqueness constraint on the same schema exists: +Assuming no constraint with the given name or other node uniqueness constraint on the same schema exists: .Result [queryresult] @@ -86,12 +91,17 @@ Assuming no constraint with the given name or other uniqueness constraint on the Unique constraints added: 1 ---- +[NOTE] +==== +The statistics will be updated to say `Node uniqueness constraints` in 6.0. +==== + ====== [discrete] -[[administration-constraints-create-a-unique-constraint-with-specified-index-provider]] -=== Create a unique constraint with specified index provider +[[administration-constraints-create-a-unique-constraint-nodes-with-specified-index-provider]] +=== Create a node unique constraint with specified index provider To create a unique constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. @@ -126,12 +136,17 @@ OPTIONS { Unique constraints added: 1 ---- +[NOTE] +==== +The statistics will be updated to say `Node uniqueness constraints` in 6.0. +==== + ====== [discrete] -[[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint]] -=== Failure to create an already existing unique property constraint +[[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-nodes]] +=== Failure to create an already existing node unique property constraint .+CREATE CONSTRAINT+ @@ -158,12 +173,17 @@ Constraint already exists: Constraint( id=4, name='preExistingUnique', type='UNIQUENESS', schema=(:Book {title}), ownedIndex=3 ) ---- +[NOTE] +==== +The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. +==== + ====== [discrete] -[[administration-constraints-failure-to-create-a-unique-property-constraint-on-same-schema-as-existing-index]] -=== Failure to create a unique property constraint on same schema as existing index +[[administration-constraints-failure-to-create-a-unique-property-constraint-nodes-on-same-schema-as-existing-index]] +=== Failure to create a node unique property constraint on same schema as existing index .+CREATE CONSTRAINT+ @@ -286,11 +306,301 @@ You may choose to use xref::indexes-for-search-performance.adoc[] instead or rem .Error message [source, "error message", role="noheader"] ---- -Unable to create Constraint( name='constraint_62365a16', type='UNIQUENESS', -schema=(:Book {isbn}) ): +Unable to create Constraint( name='constraint_62365a16', type='UNIQUENESS', schema=(:Book {isbn}) ): Both Node(0) and Node(1) have the label `Book` and property `isbn` = '1449356265' ---- +[NOTE] +==== +The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. +==== + +====== + + +[[administration-constraints-unique-relationships]] +== Unique relationship property constraints + +* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships[] +* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships-only-if-it-does-not-already-exist[] +* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships-with-specified-index-provider[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-relationships[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-relationships-on-same-schema-as-existing-index[] +* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-complies-with-unique-property-constraints[] +* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-violates-a-unique-property-constraint[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-relationships[] + + +[discrete] +[[administration-constraints-create-a-unique-constraint-relationships]] +=== Create a relationship unique constraint + +When creating a unique constraint, a name can be provided. +The constraint ensures that your database will never contain more than one relationship with a specific relationship type and one property value. + + +.+CREATE CONSTRAINT+ +====== + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT constraint_name +FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +---- + +.Result +[queryresult] +---- ++-------------------+ +| No data returned. | ++-------------------+ +Relationship uniqueness constraints added: 1 +---- + +====== + + +[discrete] +[[administration-constraints-create-a-unique-constraint-relationships-only-if-it-does-not-already-exist]] +=== Create a relationship unique constraint only if it does not already exist + +If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. +The uniqueness constraint ensures that your database will never contain more than one relationship with a specific relationship type and one property value. + +[NOTE] +==== +No constraint will be created if any other constraint with the given name or another relationship uniqueness constraint on the same schema already exists. +==== + + +.+CREATE CONSTRAINT+ +====== + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT constraint_name IF NOT EXISTS +FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +---- + +Assuming no constraint with the given name or other relationship uniqueness constraint on the same schema exists: + +.Result +[queryresult] +---- ++-------------------+ +| No data returned. | ++-------------------+ +Relationship uniqueness constraints added: 1 +---- + +====== + + +[discrete] +[[administration-constraints-create-a-unique-constraint-relationships-with-specified-index-provider]] +=== Create a relationship unique constraint with specified index provider + +To create a unique constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. + +The index type of the backing index is set with the `indexProvider` option. + +Valid values for the index provider are: + +* `range-1.0` label:default[] + +// Only one valid value exists for the index provider in Neo4j 5.0 + + +.+CREATE CONSTRAINT+ +====== + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT constraint_with_options +FOR ()-[friend:FRIENDS_WITH]-() REQUIRE (friend.nickname, friend.since) IS UNIQUE +OPTIONS { + indexProvider: 'range-1.0', +} +---- + +.Result +[queryresult] +---- ++-------------------+ +| No data returned. | ++-------------------+ +Relationship uniqueness constraints added: 1 +---- + +====== + + +[discrete] +[[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-relationships]] +=== Failure to create an already existing relationship unique property constraint + + +.+CREATE CONSTRAINT+ +====== + +Create a unique property constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when that constraint already exists. + +//// +CREATE CONSTRAINT preExistingUnique FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +//// + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +---- + +In this case the constraint can not be created because it already exists. + +.Error message +[source, "error message", role="noheader"] +---- +Constraint already exists: +Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', schema=()-[:FRIENDS_WITH {nickname}]-(), ownedIndex=3 ) +---- + +====== + + +[discrete] +[[administration-constraints-failure-to-create-a-unique-property-constraint-relationships-on-same-schema-as-existing-index]] +=== Failure to create a relationship unique property constraint on same schema as existing index + + +.+CREATE CONSTRAINT+ +====== + +Create a unique property constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when an index already exists on that relationship type and property combination. + +//// +CREATE INDEX FOR ()-[friend:FRIENDS_WITH]-() ON (friend.nickname) +//// + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +---- + +In this case the constraint can not be created because there already exists an index covering that schema. + +.Error message +[source, "error message", role="noheader"] +---- +There already exists an index ()-[:FRIENDS_WITH {nickname}]-(). +A constraint cannot be created until the index has been dropped. +---- + +====== + + +[discrete] +[[administration-constraints-create-a-relationship-that-complies-with-unique-property-constraints]] +=== Create a relationship that complies with unique property constraints + + +.+CREATE RELATIONSHIP+ +====== + +Create a `FRIENDS_WITH` relationship with an `nickname` that is not already in the database. + +//// +CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +//// + +.Query +[source, cypher, indent=0] +---- +CREATE (:Person {name: 'Josefin'})-[:FRIENDS_WITH {nickname: 'Mimi'}]->(:Person {name: 'Emilia'}) +---- + +.Result +[queryresult] +---- ++-------------------+ +| No data returned. | ++-------------------+ +Nodes created: 2 +Relationships created: 1 +Properties set: 3 +Labels added: 2 +---- + +====== + + +[discrete] +[[administration-constraints-create-a-relationship-that-violates-a-unique-property-constraint]] +=== Create a relationship that violates a unique property constraint + + +.+CREATE RELATIONSHIP+ +====== + +Create a `FRIENDS_WITH` relationship with an `nickname` that is already used in the database. + +//// +CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +CREATE (:Person {name: 'Emma'}), (:Person {name: 'Josefin'})-[:FRIENDS_WITH {nickname: 'Mimi'}]->(:Person {name: 'Emilia'}) +//// + +.Query +[source, cypher, indent=0] +---- +MATCH (emma:Person {name: 'Emma'}), (emilia:Person {name: 'Emilia'}) +CREATE (emma)-[:FRIENDS_WITH {nickname: 'Mimi'}]->(emilia) +---- + +In this case the relationship is not created in the graph. + +.Error message +[source, "error message", role="noheader"] +---- +Relationship(0) already exists with type `FRIENDS_WITH` and property `nickname` = 'Mimi' +---- + +====== + + +[discrete] +[[administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-relationships]] +=== Failure to create a unique property constraint due to conflicting relationships + + +.+CREATE CONSTRAINT+ +====== + +Create a unique property constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type when there are two relationships with the same `nickname`. + +//// +CREATE (emma:Person {name: 'Emma'}), (josefin:Person {name: 'Josefin'}), (emilia:Person {name: 'Emilia'}) +CREATE (josefin)-[:FRIENDS_WITH {nickname: 'Mimi'}]->(emilia), (emma)-[:FRIENDS_WITH {nickname: 'Mimi'}]->(emilia) +//// + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT friends FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE +---- + +In this case the constraint can not be created because it is violated by existing data. +You may choose to use xref::indexes-for-search-performance.adoc[] instead or remove the offending relationships and then re-apply the constraint. + +.Error message +[source, "error message", role="noheader"] +---- +Unable to create Constraint( name='friends', type='RELATIONSHIP_UNIQUENESS', schema=()-[:FRIENDS_WITH {nickname}]-() ): +Both Relationship(0) and Relationship(1) have the type `FRIENDS_WITH` and property `nickname` = 'Mimi' +---- + ====== @@ -335,6 +645,12 @@ FOR (book:Book) REQUIRE book.isbn IS NOT NULL Property existence constraints added: 1 ---- +[NOTE] +==== +The statistics for property existence constraints wil be split between nodes and relationships in 6.0. +For the node property existence constraints they will say `Node property existence constraints`. +==== + ====== [discrete] @@ -529,8 +845,7 @@ In this case the constraint can't be created because it is violated by existing .Error message [source, "error message", role="noheader"] ---- -Unable to create Constraint( type='NODE PROPERTY EXISTENCE', schema=(:Book -{isbn}) ): +Unable to create Constraint( type='NODE PROPERTY EXISTENCE', schema=(:Book {isbn}) ): Node(0) with label `Book` must have the property `isbn` ---- @@ -577,6 +892,12 @@ FOR ()-[like:LIKED]-() REQUIRE like.day IS NOT NULL Property existence constraints added: 1 ---- +[NOTE] +==== +The statistics for property existence constraints wil be split between nodes and relationships in 6.0. +For the relationship property existence constraints they will say `Relationship property existence constraints`. +==== + ====== @@ -771,8 +1092,7 @@ In this case the constraint can not be created because it is violated by existin .Error message [source, "error message", role="noheader"] ---- -Unable to create Constraint( type='RELATIONSHIP PROPERTY EXISTENCE', -schema=-[:LIKED {day}]- ): +Unable to create Constraint( type='RELATIONSHIP PROPERTY EXISTENCE', schema=-[:LIKED {day}]- ): Relationship(0) with type `LIKED` must have the property `day` ---- @@ -1021,7 +1341,7 @@ In this case the node is not created in the graph. .Error message [source, "error message", role="noheader"] ---- -Node(0) with label `Person` must have the properties (firstname, surname) +Node(0) with label `Person` must have the properties (`firstname`, `surname`) ---- ====== @@ -1053,7 +1373,7 @@ In this case the property is not removed. .Error message [source, "error message", role="noheader"] ---- -Node(0) with label `Person` must have the properties (firstname, surname) +Node(0) with label `Person` must have the properties (`firstname`, `surname`) ---- ====== @@ -1085,9 +1405,327 @@ We may choose to remove the offending nodes and then re-apply the constraint. .Error message [source, "error message", role="noheader"] ---- -Unable to create Constraint( type='NODE PROPERTY EXISTENCE', schema=(:Person -{firstname, surname}) ): -Node(0) with label `Person` must have the properties (firstname, surname) +Unable to create Constraint( type='NODE KEY', schema=(:Person {firstname, surname}) ): +Node(0) with label `Person` must have the properties (`firstname`, `surname`) +---- + +====== + + +[role=enterprise-edition] +[[administration-constraints-rel-key]] +== Relationship key constraints + +* xref::constraints/examples.adoc#administration-constraints-create-a-rel-key-constraint[] +* xref::constraints/examples.adoc#administration-constraints-create-a-rel-key-constraint-only-if-it-does-not-already-exist[] +* xref::constraints/examples.adoc#administration-constraints-create-a-rel-key-constraint-with-specified-index-provider[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-rel-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-rel-key-constraint-with-the-same-name-as-existing-index[] +* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-complies-with-rel-key-constraints[] +* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-violates-a-rel-key-constraint[] +* xref::constraints/examples.adoc#administration-constraints-removing-a-rel-key-constrained-property[] +* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-rel-key-constraint-due-to-existing-relationship[] + + +[discrete] +[[administration-constraints-create-a-rel-key-constraint]] +=== Create a relationship key constraint + +When creating a relationship key constraint, a name can be provided. +The constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique and all properties in the set are present. + + +.+CREATE CONSTRAINT+ +====== + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT constraint_name +FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS RELATIONSHIP KEY +---- + +.Result +[queryresult] +---- ++-------------------+ +| No data returned. | ++-------------------+ +Relationship key constraints added: 1 +---- + +====== + + +[discrete] +[[administration-constraints-create-a-rel-key-constraint-only-if-it-does-not-already-exist]] +=== Create a relationship key constraint only if it does not already exist + +If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. +The relationship key constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique and all properties in the set are present. +No constraint will be created if any other constraint with the given name or another relationship key constraint on the same schema already exists. + + +.+CREATE CONSTRAINT+ +====== + +//// +CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS RELATIONSHIP KEY +//// + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT constraint_name IF NOT EXISTS +FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS RELATIONSHIP KEY +---- + +Assuming a relationship key constraint on `()-[:ROAD {startPoint, endPoint}]-()` already existed: + +.Result +[queryresult] +---- ++--------------------------------------------+ +| No data returned, and nothing was changed. | ++--------------------------------------------+ +---- + +====== + + +[discrete] +[[administration-constraints-create-a-rel-key-constraint-with-specified-index-provider]] +=== Create a relationship key constraint with specified index provider + +To create a relationship key constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. + +The index type of the backing index is set with the `indexProvider` option. + +Valid values for the index provider are: + +* `range-1.0` label:default[] + + +.+CREATE CONSTRAINT+ +====== + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT constraint_with_provider +FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS REL KEY +OPTIONS { + indexProvider: 'range-1.0' +} +---- + +.Result +[queryresult] +---- ++-------------------+ +| No data returned. | ++-------------------+ +Relationship key constraints added: 1 +---- + +====== + + +[discrete] +[[administration-constraints-failure-to-create-a-rel-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema]] +=== Failure to create a relationship key constraint when a unique property constraint exists on the same schema + + +.+CREATE CONSTRAINT+ +====== + +Create a relationship key constraint on the properties `startPoint` and `endPoint` on relationships with the `ROAD` relationship type, when a unique property constraint already exists on the same relationship type and property combination. + +//// +CREATE CONSTRAINT preExistingUnique FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS UNIQUE +//// + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS REL KEY +---- + +In this case the constraint can not be created because there already exist a conflicting constraint on that relationship type and property combination. + +.Error message +[source, "error message", role="noheader"] +---- +Constraint already exists: +Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', schema=()-[:ROAD {startPoint, endPoint}]-(), ownedIndex=3 ) +---- + +====== + + +[discrete] +[[administration-constraints-failure-to-create-a-rel-key-constraint-with-the-same-name-as-existing-index]] +=== Failure to create a relationship key constraint with the same name as existing index + + +.+CREATE CONSTRAINT+ +====== + +Create a named relationship key constraint on the property `coordinates` on relationships with the `INTERSECTION` relationship type, when an index already exists with the given name. + +//// +CREATE INDEX intersections FOR ()-[intersect:Roundabout]-() ON (intersect.coordinates) +//// + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT intersections +FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY +---- + +In this case the constraint can't be created because there already exists an index with the given name. + +.Error message +[source, "error message", role="noheader"] +---- +There already exists an index called 'intersections'. +---- + +====== + + +[discrete] +[[administration-constraints-create-a-relationship-that-complies-with-rel-key-constraints]] +=== Create a relationship that complies with relationship key constraints + + +.+CREATE RELATIONSHIP+ +====== + +Create a `ROAD` relationship with both a `startPoint` and `endPoint` property. + +//// +CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS REL KEY +CREATE (:Intersection {name: 'a', coordinates: point({x: 1, y:2})}), (:Intersection {name: 'b', coordinates: point({x: 2, y:5})}) +//// + +.Query +[source, cypher, indent=0] +---- +MATCH (a:Intersection {name: 'a'}), (b:Intersection {name: 'b'}) +CREATE (a)-[:ROAD {startPoint: a.coordinates, endPoint: b.coordinates}]->(b) +---- + +.Result +[queryresult] +---- ++-------------------+ +| No data returned. | ++-------------------+ +Relationships created: 1 +Properties set: 2 +---- + +====== + + +[discrete] +[[administration-constraints-create-a-relationship-that-violates-a-rel-key-constraint]] +=== Create a relationship that violates a relationship key constraint + + +.+CREATE RELATIONSHIP+ +====== + +Trying to create a `INTERSECTION` relationship without a `coordinates` property, given a relationship key constraint on `:INTERSECTION(coordinates)`, will fail. + +//// +CREATE CONSTRAINT FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY +CREATE (:Road {name: 'a'}), (:Road {name: 'b'}) +//// + +.Query +[source, cypher, indent=0] +---- +MATCH (a:Road {name: 'a'}), (b:Road {name: 'b'}) +CREATE (a)-[:INTERSECTION]->(b) +---- + +In this case the relationship is not created in the graph. + +.Error message +[source, "error message", role="noheader"] +---- +Relationship(0) with type `INTERSECTION` must have the property `coordinates` +---- + +====== + + +[discrete] +[[administration-constraints-removing-a-rel-key-constrained-property]] +=== Removing a +RELATIONSHIP KEY+-constrained property + + +.+REMOVE PROPERTY+ +====== + +Trying to remove the `endPoint` property from an existing relationship `ROAD`, given a `RELATIONSHIP KEY` constraint on `:ROAD(startPoint, endPoint)`. + +//// +CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS REL KEY +CREATE (a:Intersection {name: 'a', coordinates: point({x: 1, y:2})}), (b:Intersection {name: 'b', coordinates: point({x: 2, y:5})}) +CREATE (a)-[:ROAD {startPoint: a.coordinates, endPoint: b.coordinates}]->(b) +//// + +.Query +[source, cypher, indent=0] +---- +MATCH ()-[r:ROAD {startPoint: point({x: 1, y:2}), endPoint: point({x: 2, y:5})}]->() REMOVE r.endPoint +---- + +In this case the property is not removed. + +.Error message +[source, "error message", role="noheader"] +---- +Relationship(0) with type `ROAD` must have the properties (`startPoint`, `endPoint`) +---- + +====== + + +[discrete] +[[administration-constraints-failure-to-create-a-rel-key-constraint-due-to-existing-relationship]] +=== Failure to create a relationship key constraint due to existing relationship + + +.+CREATE CONSTRAINT+ +====== + +Trying to create a relationship key constraint on the property `coordinates` on relationships with the `INTERSECTION` relationship type will fail when two relationships with identical `coordinates` already exists in the database. + +//// +CREATE (a:Road {name: 'a'}), (b:Road {name: 'b'}) +CREATE (a)-[:INTERSECTION {coordinates: point({x:1, y:2})}]->(b) +CREATE (a)<-[:INTERSECTION {coordinates: point({x:1, y:2})}]-(b) +//// + +.Query +[source, cypher, indent=0] +---- +CREATE CONSTRAINT intersectionConstriant FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY +---- + +In this case the relationship key constraint can not be created because it is violated by existing data. +We may choose to remove the offending relationships and then re-apply the constraint. + +.Error message +[source, "error message", role="noheader"] +---- +Unable to create Constraint( name='intersectionConstriant', type='RELATIONSHIP KEY', schema=()-[:INTERSECTION {coordinates}]-() ): +Both Relationship(0) and Relationship(1) have the type `INTERSECTION` and property `coordinates` = {geometry: {type: "Point", coordinates: [1.0, 2.0], crs: {type: link, properties: {href: "http://spatialreference.org/ref/sr-org/7203/", code: 7203}}}} ---- ====== @@ -1105,7 +1743,7 @@ Node(0) with label `Person` must have the properties (firstname, surname) === Drop a constraint A constraint can be dropped using the name with the `DROP CONSTRAINT constraint_name` command. -It is the same command for unique property, property existence and node key constraints. +It is the same command for unique property, property existence and node/relationship key constraints. The name of the constraint can be found using the xref::constraints/syntax.adoc#administration-constraints-syntax-list[`SHOW CONSTRAINTS` command], given in the output column `name`. @@ -1139,7 +1777,7 @@ Named constraints removed: 1 === Drop a non-existing constraint If it is uncertain if any constraint with a given name exists and you want to drop it if it does but not get an error should it not, use `IF EXISTS`. -It is the same command for unique property, property existence and node key constraints. +It is the same command for unique property, property existence and node/relationship key constraints. .+DROP CONSTRAINT+ ====== @@ -1186,7 +1824,8 @@ This can be used to drop the constraint with the xref::constraints/syntax.adoc#a ====== //// -CREATE CONSTRAINT constraint_1bc95fcb FOR (n:Book) REQUIRE (n.isbn) IS UNIQUE +CREATE CONSTRAINT isbnConstraint FOR (n:Book) REQUIRE (n.isbn) IS UNIQUE +CREATE CONSTRAINT roadConstraint FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS UNIQUE //// .Query @@ -1197,14 +1836,21 @@ SHOW CONSTRAINTS [queryresult] ---- -+-------------------------------------------------------------------------------------------------------------+ -| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | -+-------------------------------------------------------------------------------------------------------------+ -| 4 | "constraint_1bc95fcb" | "UNIQUENESS" | "NODE" | ["Book"] | ["isbn"] | "constraint_1bc95fcb" | -+-------------------------------------------------------------------------------------------------------------+ -1 row ++------------------------------------------------------------------------------------------------------------------------------------+ +| id | name | type | entityType | labelsOrTypes | properties | ownedIndex | ++------------------------------------------------------------------------------------------------------------------------------------+ +| 4 | "isbnConstraint" | "UNIQUENESS" | "NODE" | ["Book"] | ["isbn"] | "isbnConstraint" | +| 6 | "roadConstraint" | "RELATIONSHIP_UNIQUENESS" | "RELATIONSHIP" | ["ROAD"] | ["startPoint", "endPoint"] | "roadConstraint" | ++------------------------------------------------------------------------------------------------------------------------------------+ +2 rows ---- +[NOTE] +==== +The `type` column returns `UNIQUENESS` for the node unique property constraint and `RELATIONSHIP_UNIQUENESS` for the relationship unique property constraint. +The `type` for node unique property constraint will be updated to `NODE_UNIQUENESS` in 6.0. +==== + ====== @@ -1213,8 +1859,8 @@ SHOW CONSTRAINTS === Listing constraints with filtering One way of filtering the output from `SHOW CONSTRAINTS` by constraint type is the use of type keywords, -listed in xref::constraints/syntax.adoc#administration-constraints-syntax-list[Syntax for listing constraints]. -For example, to show only unique node property constraints, use `SHOW UNIQUE CONSTRAINTS`. +listed in the xref::constraints/syntax.adoc#administration-constraints-syntax-list-type-filter[syntax for listing constraints type filter table]. +For example, to show only unique property constraints, use `SHOW UNIQUENESS CONSTRAINTS`. Another more flexible way of filtering the output is to use the `WHERE` clause. An example is to only show constraints on relationships. diff --git a/modules/ROOT/pages/constraints/index.adoc b/modules/ROOT/pages/constraints/index.adoc index 48a149bdf..10ac58800 100644 --- a/modules/ROOT/pages/constraints/index.adoc +++ b/modules/ROOT/pages/constraints/index.adoc @@ -14,17 +14,22 @@ This section explains how to manage constraints used for ensuring data integrity The following constraint types are available: *Unique node property constraints*:: -Unique property constraints ensure that property values are unique for all nodes with a specific label. +Unique node property constraints ensure that property values are unique for all nodes with a specific label. For unique property constraints on multiple properties, the combination of the property values is unique. Unique constraints do not require all nodes to have a unique value for the properties listed -- nodes without all properties are not subject to this rule. +*Unique relationship property constraints*:: +Unique relationship property constraints ensure that property values are unique for all relationships with a specific type. +For unique property constraints on multiple properties, the combination of the property values is unique. +Unique constraints do not require all relationships to have a unique value for the properties listed -- relationships without all properties are not subject to this rule. + *Node property existence constraints* label:enterprise-edition[]:: Node property existence constraints ensure that a property exists for all nodes with a specific label. Queries that try to create new nodes of the specified label, but without this property, will fail. The same is true for queries that try to remove the mandatory property. *Relationship property existence constraints* label:enterprise-edition[]:: -Property existence constraints ensure that a property exists for all relationships with a specific type. +Relationship property existence constraints ensure that a property exists for all relationships with a specific type. All queries that try to create relationships of the specified type, but without this property, will fail. The same is true for queries that try to remove the mandatory property. @@ -42,10 +47,24 @@ Queries attempting to do any of the following will fail: * Remove one of the mandatory properties. * Update the properties so that the combination of property values is no longer unique. +*Relationship key constraints* label:enterprise-edition[]:: +Relationship key constraints ensure that, for a given type and set of properties: ++ +[lowerroman] +. All the properties exist on all the relationships with that type. +. The combination of the property values is unique. + ++ +Queries attempting to do any of the following will fail: + +* Create new relationships without all the properties or where the combination of property values is not unique. +* Remove one of the mandatory properties. +* Update the properties so that the combination of property values is no longer unique. + [NOTE] ==== -Node key constraints, node property existence constraints and relationship property existence constraints are only available in Neo4j Enterprise Edition. +Node key constraints, relationship key constraints, node property existence constraints, and relationship property existence constraints are only available in Neo4j Enterprise Edition. Databases containing one of these constraint types cannot be opened using Neo4j Community Edition. ==== @@ -54,15 +73,15 @@ Databases containing one of these constraint types cannot be opened using Neo4j Creating a constraint has the following implications on indexes: -* Adding a node key or unique property constraint on a single property also adds an index on that property and therefore, an index of the same index type, label, and property combination cannot be added separately. -* Adding a node key or unique property constraint for a set of properties also adds an index on those properties and therefore, an index of the same index type, label, and properties combination cannot be added separately. +* Adding a node key, relationship key, or unique property constraint on a single property also adds an index on that property and therefore, an index of the same index type, label/relationship type, and property combination cannot be added separately. +* Adding a node key, relationship key, or unique property constraint for a set of properties also adds an index on those properties and therefore, an index of the same index type, label/relationship type, and properties combination cannot be added separately. * Cypher will use these indexes for lookups just like other indexes. Refer to xref::indexes-for-search-performance.adoc[] for more details on indexes. -* If a node key or unique property constraint is dropped and the backing index is still required, the index need to be created explicitly. +* If a node key, relationship key, or unique property constraint is dropped and the backing index is still required, the index need to be created explicitly. Additionally, the following is true for constraints: -* A given label can have multiple constraints, and unique and property existence constraints can be combined on the same property. +* A given label or relationship type can have multiple constraints, and unique and property existence constraints can be combined on the same property. * Adding constraints is an atomic operation that can take a while -- all existing data has to be scanned before Neo4j DBMS can turn the constraint 'on'. * Best practice is to give the constraint a name when it is created. If the constraint is not explicitly named, it will get an auto-generated name. diff --git a/modules/ROOT/pages/constraints/syntax.adoc b/modules/ROOT/pages/constraints/syntax.adoc index 5a759d93f..366bdd5f2 100644 --- a/modules/ROOT/pages/constraints/syntax.adoc +++ b/modules/ROOT/pages/constraints/syntax.adoc @@ -19,7 +19,7 @@ If a name is not explicitly given, a unique name will be auto-generated. The create constraint command is optionally idempotent. This means its default behavior is to throw an error if an attempt is made to create the same constraint twice. With the `IF NOT EXISTS` flag, no error is thrown and nothing happens should a constraint with the same name or same schema and constraint type already exist. It may still throw an error if conflicting data, indexes, or constraints exist. -Examples of this are nodes with missing properties, indexes with the same name, or constraints with same schema but a different constraint type. +Examples of this are nodes with missing properties, indexes with the same name, or constraints with same schema but a different conflicting constraint type. For constraints that are backed by an index, the index provider for the backing index can be specified using the `OPTIONS` clause. Only one valid value exists for the index provider, `range-1.0`, which is the default value. @@ -30,7 +30,7 @@ There is no supported index configuration for range indexes. Creating a constraint requires the xref::access-control/database-administration.adoc#access-control-database-administration-constraints[`CREATE CONSTRAINT` privilege]. ==== -[[administration-constraints-syntax-create-unique]] +[[administration-constraints-syntax-create-node-unique]] [discrete] === Create a unique node property constraint @@ -40,7 +40,7 @@ This command creates a uniqueness constraint on nodes with the specified label a ---- CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] FOR (n:LabelName) -REQUIRE n.propertyName IS UNIQUE +REQUIRE n.propertyName IS [NODE] UNIQUE [OPTIONS "{" option: value[, ...] "}"] ---- @@ -48,7 +48,32 @@ REQUIRE n.propertyName IS UNIQUE ---- CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] FOR (n:LabelName) -REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS UNIQUE +REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] UNIQUE +[OPTIONS "{" option: value[, ...] "}"] +---- + +Index provider can be specified using the `OPTIONS` clause. + + +[[administration-constraints-syntax-create-rel-unique]] +[discrete] +=== Create a unique relationship property constraint + +This command creates a uniqueness constraint on relationships with the specified relationship type and properties. + +[source, syntax, role="noheader", indent=0] +---- +CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] +FOR ()-"["r:RELATIONSHIP_TYPE"]"-() +REQUIRE r.propertyName IS [REL[ATIONSHIP]] UNIQUE +[OPTIONS "{" option: value[, ...] "}"] +---- + +[source, syntax, role="noheader", indent=0] +---- +CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] +FOR ()-"["r:RELATIONSHIP_TYPE"]"-() +REQUIRE (r.propertyName_1, ..., r.propertyName_n) IS [REL[ATIONSHIP]] UNIQUE [OPTIONS "{" option: value[, ...] "}"] ---- @@ -105,7 +130,7 @@ This command creates a node key constraint on nodes with the specified label and ---- CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] FOR (n:LabelName) -REQUIRE n.propertyName IS NODE KEY +REQUIRE n.propertyName IS [NODE] KEY [OPTIONS "{" option: value[, ...] "}"] ---- @@ -113,7 +138,32 @@ REQUIRE n.propertyName IS NODE KEY ---- CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] FOR (n:LabelName) -REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS NODE KEY +REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] KEY +[OPTIONS "{" option: value[, ...] "}"] +---- + +Index provider can be specified using the `OPTIONS` clause. + + +[[administration-constraints-syntax-create-rel-key]] +[discrete] +=== Create a relationship key constraint label:enterprise-edition[] + +This command creates a relationship key constraint on relationships with the specified relationship type and properties. + +[source, syntax, role="noheader", indent=0] +---- +CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] +FOR ()-"["r:RELATIONSHIP_TYPE"]"-() +REQUIRE r.propertyName IS [REL[ATIONSHIP]] KEY +[OPTIONS "{" option: value[, ...] "}"] +---- + +[source, syntax, role="noheader", indent=0] +---- +CREATE CONSTRAINT [constraint_name] [IF NOT EXISTS] +FOR ()-"["r:RELATIONSHIP_TYPE"]"-() +REQUIRE (r.propertyName_1, ..., r.propertyName_n) IS [REL[ATIONSHIP]] KEY [OPTIONS "{" option: value[, ...] "}"] ---- @@ -143,18 +193,28 @@ Dropping a constraint requires the xref::access-control/database-administration. == Syntax for listing constraints List constraints in the database, either all or filtered on constraint type. -This requires thexref::access-control/database-administration.adoc#access-control-database-administration-constraints[`SHOW CONSTRAINT`] privilege. + +[NOTE] +==== +Listing constraints requires the xref::access-control/database-administration.adoc#access-control-database-administration-constraints[`SHOW CONSTRAINTS` privilege]. +==== The simple version of the command allows for a `WHERE` clause and will give back the default set of output columns: [source, syntax, role="noheader", indent=0] ---- -SHOW [ALL - |UNIQUE +SHOW [ + ALL + |NODE UNIQUE[NESS] + |REL[ATIONSHIP] UNIQUE[NESS] + |UNIQUE[NESS] |NODE [PROPERTY] EXIST[ENCE] |REL[ATIONSHIP] [PROPERTY] EXIST[ENCE] |[PROPERTY] EXIST[ENCE] - |NODE KEY] CONSTRAINT[S] + |NODE KEY + |REL[ATIONSHIP] KEY + |KEY +] CONSTRAINT[S] [WHERE expression] ---- @@ -162,18 +222,66 @@ To get the full set of output columns, a yield clause is needed: [source, syntax, role="noheader", indent=0] ---- -SHOW [ALL - |UNIQUE +SHOW [ + ALL + |NODE UNIQUE[NESS] + |REL[ATIONSHIP] UNIQUE[NESS] + |UNIQUE[NESS] |NODE [PROPERTY] EXIST[ENCE] |REL[ATIONSHIP] [PROPERTY] EXIST[ENCE] |[PROPERTY] EXIST[ENCE] - |NODE KEY] CONSTRAINT[S] + |NODE KEY + |REL[ATIONSHIP] KEY + |KEY +] CONSTRAINT[S] YIELD { * | field[, ...] } [ORDER BY field[, ...]] [SKIP n] [LIMIT n] [WHERE expression] [RETURN field[, ...] [ORDER BY field[, ...]] [SKIP n] [LIMIT n]] ---- +The type filtering keywords filters the returned constraints on constraint type: + +[[administration-constraints-syntax-list-type-filter]] +.Type filters +[options="header", width="100%", cols="4m,6a"] +|=== +| Filter | Description + +|ALL +| Returns all constraints, no filtering on constraint type. +This is the default if none is given. + +|NODE UNIQUE[NESS] +| Returns the node unique property constraints. + +|REL[ATIONSHIP] UNIQUE[NESS] +| Returns the relationship unique property constraints. + +|UNIQUE[NESS] +| Returns all unique property constraints, for both nodes and relationships. + +|NODE [PROPERTY] EXIST[ENCE] +| Returns the node property existence constraints. + +|REL[ATIONSHIP] [PROPERTY] EXIST[ENCE] +| Returns the relationship property existence constraints. + +|[PROPERTY] EXIST[ENCE] +| Returns all property existence constraints, for both nodes and relationships. + +|NODE KEY +| Returns the node key constraints. + +|REL[ATIONSHIP] KEY +| Returns the relationship key constraints. + +|KEY +| Returns all node and relationship key constraints. + +|=== + + The returned columns from the show command is: .Listing constraints output @@ -188,7 +296,7 @@ The returned columns from the show command is: | Name of the constraint (explicitly set by the user or automatically assigned). label:default-output[] | type -| The ConstraintType of this constraint (`UNIQUENESS`, `NODE_PROPERTY_EXISTENCE`, `NODE_KEY`, or `RELATIONSHIP_PROPERTY_EXISTENCE`). label:default-output[] +| The ConstraintType of this constraint (`UNIQUENESS` (node uniqueness), `RELATIONSHIP_UNIQUENESS`, `NODE_PROPERTY_EXISTENCE`, `RELATIONSHIP_PROPERTY_EXISTENCE`, `NODE_KEY`, or `RELATIONSHIP_KEY`). label:default-output[] | entityType | Type of entities this constraint represents (nodes or relationship). label:default-output[] @@ -210,8 +318,3 @@ The returned columns from the show command is: |=== -[NOTE] -==== -Listing constraints requires the xref::access-control/database-administration.adoc#access-control-database-administration-constraints[`SHOW CONSTRAINTS` privilege]. -==== - diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index 649634b25..6f43abaf7 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -62,6 +62,73 @@ a| A `COUNT` subquery now supports any non-writing query. For example, it now supports `UNION` and `CALL` clauses. +|=== + +[[cypher-deprecations-additions-removals-5.3]] +== Version 5.3 + +=== Deprecated features + +[cols="2", options="header"] +|=== +| Feature +| Details + +a| +//not sure what category this should be, it is more information about a coming breaking change than actual deprecation +label:returnValues[] +label:deprecated[] +[source, cypher, role="noheader"] +---- +SHOW NODE UNIQUE CONSTRAINTS YIELD type +---- +a| + +Current constraint type for node uniqueness constraints, `UNIQUENESS`, will be updated to `NODE_UNIQUENESS` in 6.0. + +This will also be reflected in updates to some error messages and query statistics. + +|=== + +=== New features + +[cols="2", options="header"] +|=== +| Feature +| Details + +a| +label:functionality[] +label:new[] +[source, cypher, role="noheader"] +---- +CREATE CONSTRAINT name FOR ()-[r:TYPE]-() REQUIRE r.prop IS UNIQUE +CREATE CONSTRAINT name FOR ()-[r:TYPE]-() REQUIRE r.prop IS RELATIONSHIP KEY +---- +a| + +Added relationship key and uniqueness constraints. + +a| +label:functionality[] +label:new[] +[source, cypher, role="noheader"] +---- +SHOW NODE UNIQUE[NESS] CONSTRAINTS +SHOW REL[ATIONSHIP] UNIQUE[NESS] CONSTRAINTS +SHOW UNIQUE[NESS] CONSTRAINTS +SHOW REL[ATIONSHIP] KEY CONSTRAINTS +SHOW KEY CONSTRAINTS +---- +a| + +Added filtering for the new constraint types to `SHOW CONSTRAINTS`. +Includes filtering for the node part, relationship part, or both parts of each type (`NODE KEY` filtering already exists previously). + +The existing `UNIQUE` filter will now return both node and relationship uniqueness constraints. +All uniqueness constraint type filters now allow both `UNIQUE` and `UNIQUENESS` keywords. + + |=== [[cypher-deprecations-additions-removals-5.2]] diff --git a/modules/ROOT/pages/keyword-glossary.adoc b/modules/ROOT/pages/keyword-glossary.adoc index e0f8cf603..242062a0c 100644 --- a/modules/ROOT/pages/keyword-glossary.adoc +++ b/modules/ROOT/pages/keyword-glossary.adoc @@ -46,18 +46,26 @@ Typically used when modifying or importing large amounts of data. | Schema | Create a constraint ensuring that all nodes with a particular label have a certain property. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-node-key[CREATE CONSTRAINT [node_key\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS NODE KEY [OPTIONS {optionKey: optionValue[, ...\]}\]] +| xref::constraints/syntax.adoc#administration-constraints-syntax-create-rel-exists[CREATE CONSTRAINT [existence\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE r.property IS NOT NULL [OPTIONS {}\]] +| Schema +| Create a constraint that ensures all relationships with a particular type have a certain property. + +| xref::constraints/syntax.adoc#administration-constraints-syntax-create-node-key[CREATE CONSTRAINT [node_key\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS [NODE\] KEY [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema | Create a constraint that ensures all nodes with a particular label have all the specified properties and that the combination of property values is unique; i.e. ensures existence and uniqueness. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-rel-exists[CREATE CONSTRAINT [existence\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE r.property IS NOT NULL [OPTIONS {}\]] +| xref::constraints/syntax.adoc#administration-constraints-syntax-create-rel-key[CREATE CONSTRAINT [rel_key\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE (r.prop1[, ..., r.propN\]) IS [REL[ATIONSHIP\]\] KEY [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema -| Create a constraint that ensures all relationships with a particular type have a certain property. +| Create a constraint that ensures all relationships with a particular type have all the specified properties and that the combination of property values is unique; i.e. ensures existence and uniqueness. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-unique[CREATE CONSTRAINT [uniqueness\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS UNIQUE [OPTIONS {optionKey: optionValue[, ...\]}\]] +| xref::constraints/syntax.adoc#administration-constraints-syntax-create-node-unique[CREATE CONSTRAINT [uniqueness\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS [NODE\] UNIQUE [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema | Create a constraint that ensures the uniqueness of the combination of node label and property values for a particular property key combination across all nodes. +| xref::constraints/syntax.adoc#administration-constraints-syntax-create-rel-unique[CREATE CONSTRAINT [uniqueness\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE (r.prop1[, ..., r.propN\]) IS [REL[ATIONSHIP\]\] UNIQUE [OPTIONS {optionKey: optionValue[, ...\]}\]] +| Schema +| Create a constraint that ensures the uniqueness of the combination of relationship type and property values for a particular property key combination across all relationships. + | xref::indexes-for-full-text-search.adoc[CREATE FULLTEXT INDEX [name\] [IF NOT EXISTS\] FOR (n:Label["\|" ... "\|" LabelN\]) ON EACH "[" n.property[, ..., n.propertyN\] "\]" [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema | Create a fulltext index on nodes. From 27a64aef26eb06341bfe0878cc9bfe93d1b10c85 Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Thu, 24 Nov 2022 14:03:23 +0100 Subject: [PATCH 03/12] Update to always refer to the uniqueness constraints as such It was a mix of uniqueness, unique and unique property --- .../pages/clauses/listing-procedures.adoc | 6 +- modules/ROOT/pages/clauses/merge.adoc | 38 +++++----- modules/ROOT/pages/constraints/examples.adoc | 74 +++++++++---------- modules/ROOT/pages/constraints/index.adoc | 20 ++--- modules/ROOT/pages/constraints/syntax.adoc | 10 +-- ...ions-additions-removals-compatibility.adoc | 6 +- .../execution-plans/operator-summary.adoc | 4 +- .../ROOT/pages/execution-plans/operators.adoc | 12 +-- modules/ROOT/pages/introduction/index.adoc | 2 +- 9 files changed, 86 insertions(+), 86 deletions(-) diff --git a/modules/ROOT/pages/clauses/listing-procedures.adoc b/modules/ROOT/pages/clauses/listing-procedures.adoc index 5be57ef6d..f3540f541 100644 --- a/modules/ROOT/pages/clauses/listing-procedures.adoc +++ b/modules/ROOT/pages/clauses/listing-procedures.adoc @@ -213,7 +213,7 @@ SHOW PROCEDURES 4+d|Rows: 15 |=== -The above table only displays the first 15 results of the query. +The above table only displays the first 15 results of the query. For a full list of all built-in procedures in Neo4j, visit the {neo4j-docs-base-uri}/operations-manual/{page-version}/reference/procedures#/#_list_of_procedures[Operations Manual -> List of procedures]. == Listing procedures with filtering on output columns @@ -252,7 +252,7 @@ WHERE admin 2+d|Rows: 15 |=== -The above table only displays the first 15 results of the query. +The above table only displays the first 15 results of the query. For a full list of all procedures which require `admin` privileges in Neo4j, visit the {neo4j-docs-base-uri}/operations-manual/{page-version}/reference/procedures#/#_list_of_procedures[Operations Manual -> List of procedures]. == Listing procedures with other filtering @@ -353,7 +353,7 @@ SHOW PROCEDURES EXECUTABLE BY CURRENT USER YIELD * 4+d|Rows: 15 |=== -The above table only displays the first 15 results of the query. +The above table only displays the first 15 results of the query. Note that the two `roles` columns are empty due to missing the xref::access-control/dbms-administration.adoc#access-control-dbms-administration-role-management[`SHOW ROLE`] privilege. Also note that the following columns are not present in the table: `mode`, `worksOnSystem`, `signature`, `argumentDescription`, `returnDescription`, `admin`, and `options`. diff --git a/modules/ROOT/pages/clauses/merge.adoc b/modules/ROOT/pages/clauses/merge.adoc index 5a5f4d0e1..ca88599c1 100644 --- a/modules/ROOT/pages/clauses/merge.adoc +++ b/modules/ROOT/pages/clauses/merge.adoc @@ -26,11 +26,11 @@ Either the pattern already exists, or it needs to be created. ** xref::clauses/merge.adoc#merge-merge-on-an-undirected-relationship[Merge on an undirected relationship] ** xref::clauses/merge.adoc#merge-merge-on-a-relationship-between-two-existing-nodes[Merge on a relationship between two existing nodes] ** xref::clauses/merge.adoc#merge-merge-on-a-relationship-between-an-existing-node-and-a-merged-node-derived-from-a-node-property[Merge on a relationship between an existing node and a merged node derived from a node property] -* xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using unique constraints with `MERGE`] -** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-creates-a-new-node-if-no-node-is-found[Merge using unique constraints creates a new node if no node is found] -** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-matches-an-existing-node[Merge using unique constraints matches an existing node] -** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-partial-matches[Merge with unique constraints and partial matches] -** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-conflicting-matches[Merge with unique constraints and conflicting matches] +* xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using uniqueness constraints with `MERGE`] +** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-creates-a-new-node-if-no-node-is-found[Merge using uniqueness constraints creates a new node if no node is found] +** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-matches-an-existing-node[Merge using uniqueness constraints matches an existing node] +** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-partial-matches[Merge with uniqueness constraints and partial matches] +** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-conflicting-matches[Merge with uniqueness constraints and conflicting matches] * xref::clauses/merge.adoc#merge-using-map-parameters-with-merge[Using map parameters with `MERGE`] [[query-merge-introduction]] @@ -55,8 +55,8 @@ If partial matches are needed, this can be accomplished by splitting a pattern u [IMPORTANT] ==== Under concurrent updates, `MERGE` only guarantees existence of the `MERGE` pattern, but not uniqueness. -To guarantee uniqueness of nodes with certain properties, a xref::constraints/index.adoc[unique constraint] should be used. -See xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using unique constraints with `MERGE`] to see how `MERGE` can be used in combination with a unique constraint. +To guarantee uniqueness of nodes with certain properties, a xref::constraints/index.adoc[uniqueness constraint] should be used. +See xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using uniqueness constraints with `MERGE`] to see how `MERGE` can be used in combination with a uniqueness constraint. ==== As with `MATCH`, `MERGE` can match multiple occurrences of a pattern. @@ -489,15 +489,15 @@ Labels added: 5 [[query-merge-using-unique-constraints]] -== Using unique constraints with `MERGE` +== Using uniqueness constraints with `MERGE` -Cypher prevents getting conflicting results from `MERGE` when using patterns that involve unique constraints. +Cypher prevents getting conflicting results from `MERGE` when using patterns that involve uniqueness constraints. In this case, there must be at most one node that matches that pattern. -For example, given two unique constraints on `:Person(id)` and `:Person(ssn)`, a query such as `MERGE (n:Person {id: 12, ssn: 437})` will fail, if there are two different nodes (one with `id` 12 and one with `ssn` 437) or if there is only one node with only one of the properties. +For example, given two uniqueness constraints on `:Person(id)` and `:Person(ssn)`, a query such as `MERGE (n:Person {id: 12, ssn: 437})` will fail, if there are two different nodes (one with `id` 12 and one with `ssn` 437) or if there is only one node with only one of the properties. In other words, there must be exactly one node that matches the pattern, or no matching nodes. -Note that the following examples assume the existence of unique constraints that have been created using: +Note that the following examples assume the existence of uniqueness constraints that have been created using: [source, cypher, indent=0] ---- @@ -507,9 +507,9 @@ CREATE CONSTRAINT FOR (n:Person) REQUIRE n.role IS UNIQUE; [[merge-merge-using-unique-constraints-creates-a-new-node-if-no-node-is-found]] -=== Merge using unique constraints creates a new node if no node is found +=== Merge using uniqueness constraints creates a new node if no node is found -Merge using unique constraints creates a new node if no node is found. +Merge using uniqueness constraints creates a new node if no node is found. .Query [source, cypher, indent=0] @@ -534,9 +534,9 @@ Labels added: 1 [[merge-merge-using-unique-constraints-matches-an-existing-node]] -=== Merge using unique constraints matches an existing node +=== Merge using uniqueness constraints matches an existing node -Merge using unique constraints matches an existing node. +Merge using uniqueness constraints matches an existing node. .Query [source, cypher, indent=0] @@ -557,9 +557,9 @@ The `'oliver'` node already exists, so `MERGE` just matches it. [[merge-merge-with-unique-constraints-and-partial-matches]] -=== Merge with unique constraints and partial matches +=== Merge with uniqueness constraints and partial matches -Merge using unique constraints fails when finding partial matches. +Merge using uniqueness constraints fails when finding partial matches. .Query [source, cypher, indent=0] @@ -588,9 +588,9 @@ SET michael.role = 'Gordon Gekko' [[merge-merge-with-unique-constraints-and-conflicting-matches]] -=== Merge with unique constraints and conflicting matches +=== Merge with uniqueness constraints and conflicting matches -Merge using unique constraints fails when finding conflicting matches. +Merge using uniqueness constraints fails when finding conflicting matches. .Query [source, cypher, indent=0] diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index d5ae1fd80..c2a25f62a 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -10,7 +10,7 @@ Examples of how to manage constraints used for ensuring data integrity. [[administration-constraints-unique-nodes]] -== Unique node property constraints +== Node uniqueness constraints * xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes[] * xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes-only-if-it-does-not-already-exist[] @@ -24,9 +24,9 @@ Examples of how to manage constraints used for ensuring data integrity. [discrete] [[administration-constraints-create-a-unique-constraint-nodes]] -=== Create a node unique constraint +=== Create a node uniqueness constraint -When creating a unique constraint, a name can be provided. +When creating a uniqueness constraint, a name can be provided. The constraint ensures that your database will never contain more than one node with a specific label and one property value. @@ -59,7 +59,7 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [discrete] [[administration-constraints-create-a-unique-constraint-nodes-only-if-it-does-not-already-exist]] -=== Create a node unique constraint only if it does not already exist +=== Create a node uniqueness constraint only if it does not already exist If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. The uniqueness constraint ensures that your database will never contain more than one node with a specific label and one property value. @@ -101,9 +101,9 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [discrete] [[administration-constraints-create-a-unique-constraint-nodes-with-specified-index-provider]] -=== Create a node unique constraint with specified index provider +=== Create a node uniqueness constraint with specified index provider -To create a unique constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. +To create a uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. The index type of the backing index is set with the `indexProvider` option. @@ -146,13 +146,13 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [discrete] [[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-nodes]] -=== Failure to create an already existing node unique property constraint +=== Failure to create an already existing node uniqueness constraint .+CREATE CONSTRAINT+ ====== -Create a unique property constraint on the property `title` on nodes with the `Book` label, when that constraint already exists. +Create a uniqueness constraint on the property `title` on nodes with the `Book` label, when that constraint already exists. //// CREATE CONSTRAINT preExistingUnique FOR (book:Book) REQUIRE book.title IS UNIQUE @@ -183,13 +183,13 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. [discrete] [[administration-constraints-failure-to-create-a-unique-property-constraint-nodes-on-same-schema-as-existing-index]] -=== Failure to create a node unique property constraint on same schema as existing index +=== Failure to create a node uniqueness constraint on same schema as existing index .+CREATE CONSTRAINT+ ====== -Create a unique property constraint on the property `wordCount` on nodes with the `Book` label, when an index already exists on that label and property combination. +Create a uniqueness constraint on the property `wordCount` on nodes with the `Book` label, when an index already exists on that label and property combination. //// CREATE INDEX FOR (book:Book) ON (book.wordCount) @@ -215,7 +215,7 @@ A constraint cannot be created until the index has been dropped. [discrete] [[administration-constraints-create-a-node-that-complies-with-unique-property-constraints]] -=== Create a node that complies with unique property constraints +=== Create a node that complies with uniqueness constraints .+CREATE NODE+ @@ -249,7 +249,7 @@ Labels added: 1 [discrete] [[administration-constraints-create-a-node-that-violates-a-unique-property-constraint]] -=== Create a node that violates a unique property constraint +=== Create a node that violates a uniqueness constraint .+CREATE NODE+ @@ -281,13 +281,13 @@ Node(0) already exists with label `Book` and property `isbn` = '1449356265' [discrete] [[administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-nodes]] -=== Failure to create a unique property constraint due to conflicting nodes +=== Failure to create a uniqueness constraint due to conflicting nodes .+CREATE CONSTRAINT+ ====== -Create a unique property constraint on the property `isbn` on nodes with the `Book` label when there are two nodes with the same `isbn`. +Create a uniqueness constraint on the property `isbn` on nodes with the `Book` label when there are two nodes with the same `isbn`. //// CREATE (book:Book {isbn: '1449356265', title: 'Graph Databases'}) @@ -319,7 +319,7 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. [[administration-constraints-unique-relationships]] -== Unique relationship property constraints +== Relationship uniqueness constraints * xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships[] * xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships-only-if-it-does-not-already-exist[] @@ -333,9 +333,9 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. [discrete] [[administration-constraints-create-a-unique-constraint-relationships]] -=== Create a relationship unique constraint +=== Create a relationship uniqueness constraint -When creating a unique constraint, a name can be provided. +When creating a uniqueness constraint, a name can be provided. The constraint ensures that your database will never contain more than one relationship with a specific relationship type and one property value. @@ -363,7 +363,7 @@ Relationship uniqueness constraints added: 1 [discrete] [[administration-constraints-create-a-unique-constraint-relationships-only-if-it-does-not-already-exist]] -=== Create a relationship unique constraint only if it does not already exist +=== Create a relationship uniqueness constraint only if it does not already exist If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. The uniqueness constraint ensures that your database will never contain more than one relationship with a specific relationship type and one property value. @@ -400,9 +400,9 @@ Relationship uniqueness constraints added: 1 [discrete] [[administration-constraints-create-a-unique-constraint-relationships-with-specified-index-provider]] -=== Create a relationship unique constraint with specified index provider +=== Create a relationship uniqueness constraint with specified index provider -To create a unique constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. +To create a uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. The index type of the backing index is set with the `indexProvider` option. @@ -440,13 +440,13 @@ Relationship uniqueness constraints added: 1 [discrete] [[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-relationships]] -=== Failure to create an already existing relationship unique property constraint +=== Failure to create an already existing relationship uniqueness constraint .+CREATE CONSTRAINT+ ====== -Create a unique property constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when that constraint already exists. +Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when that constraint already exists. //// CREATE CONSTRAINT preExistingUnique FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE @@ -472,13 +472,13 @@ Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', sche [discrete] [[administration-constraints-failure-to-create-a-unique-property-constraint-relationships-on-same-schema-as-existing-index]] -=== Failure to create a relationship unique property constraint on same schema as existing index +=== Failure to create a relationship uniqueness constraint on same schema as existing index .+CREATE CONSTRAINT+ ====== -Create a unique property constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when an index already exists on that relationship type and property combination. +Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when an index already exists on that relationship type and property combination. //// CREATE INDEX FOR ()-[friend:FRIENDS_WITH]-() ON (friend.nickname) @@ -504,7 +504,7 @@ A constraint cannot be created until the index has been dropped. [discrete] [[administration-constraints-create-a-relationship-that-complies-with-unique-property-constraints]] -=== Create a relationship that complies with unique property constraints +=== Create a relationship that complies with uniqueness constraints .+CREATE RELATIONSHIP+ @@ -539,7 +539,7 @@ Labels added: 2 [discrete] [[administration-constraints-create-a-relationship-that-violates-a-unique-property-constraint]] -=== Create a relationship that violates a unique property constraint +=== Create a relationship that violates a uniqueness constraint .+CREATE RELATIONSHIP+ @@ -572,13 +572,13 @@ Relationship(0) already exists with type `FRIENDS_WITH` and property `nickname` [discrete] [[administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-relationships]] -=== Failure to create a unique property constraint due to conflicting relationships +=== Failure to create a uniqueness constraint due to conflicting relationships .+CREATE CONSTRAINT+ ====== -Create a unique property constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type when there are two relationships with the same `nickname`. +Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type when there are two relationships with the same `nickname`. //// CREATE (emma:Person {name: 'Emma'}), (josefin:Person {name: 'Josefin'}), (emilia:Person {name: 'Emilia'}) @@ -1220,13 +1220,13 @@ Node key constraints added: 1 [discrete] [[administration-constraints-failure-to-create-a-node-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema]] -=== Failure to create a node key constraint when a unique property constraint exists on the same schema +=== Failure to create a node key constraint when a uniqueness constraint exists on the same schema .+CREATE CONSTRAINT+ ====== -Create a node key constraint on the properties `firstname` and `age` on nodes with the `Person` label, when a unique property constraint already exists on the same label and property combination. +Create a node key constraint on the properties `firstname` and `age` on nodes with the `Person` label, when a uniqueness constraint already exists on the same label and property combination. //// CREATE CONSTRAINT preExistingUnique FOR (p:Person) REQUIRE (p.firstname, p.age) IS UNIQUE @@ -1533,13 +1533,13 @@ Relationship key constraints added: 1 [discrete] [[administration-constraints-failure-to-create-a-rel-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema]] -=== Failure to create a relationship key constraint when a unique property constraint exists on the same schema +=== Failure to create a relationship key constraint when a uniqueness constraint exists on the same schema .+CREATE CONSTRAINT+ ====== -Create a relationship key constraint on the properties `startPoint` and `endPoint` on relationships with the `ROAD` relationship type, when a unique property constraint already exists on the same relationship type and property combination. +Create a relationship key constraint on the properties `startPoint` and `endPoint` on relationships with the `ROAD` relationship type, when a uniqueness constraint already exists on the same relationship type and property combination. //// CREATE CONSTRAINT preExistingUnique FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS UNIQUE @@ -1743,7 +1743,7 @@ Both Relationship(0) and Relationship(1) have the type `INTERSECTION` and proper === Drop a constraint A constraint can be dropped using the name with the `DROP CONSTRAINT constraint_name` command. -It is the same command for unique property, property existence and node/relationship key constraints. +It is the same command for uniqueness, property existence and node/relationship key constraints. The name of the constraint can be found using the xref::constraints/syntax.adoc#administration-constraints-syntax-list[`SHOW CONSTRAINTS` command], given in the output column `name`. @@ -1777,7 +1777,7 @@ Named constraints removed: 1 === Drop a non-existing constraint If it is uncertain if any constraint with a given name exists and you want to drop it if it does but not get an error should it not, use `IF EXISTS`. -It is the same command for unique property, property existence and node/relationship key constraints. +It is the same command for uniqueness, property existence and node/relationship key constraints. .+DROP CONSTRAINT+ ====== @@ -1847,8 +1847,8 @@ SHOW CONSTRAINTS [NOTE] ==== -The `type` column returns `UNIQUENESS` for the node unique property constraint and `RELATIONSHIP_UNIQUENESS` for the relationship unique property constraint. -The `type` for node unique property constraint will be updated to `NODE_UNIQUENESS` in 6.0. +The `type` column returns `UNIQUENESS` for the node uniqueness constraint and `RELATIONSHIP_UNIQUENESS` for the relationship uniqueness constraint. +The `type` for node uniqueness constraint will be updated to `NODE_UNIQUENESS` in 6.0. ==== ====== @@ -1860,7 +1860,7 @@ The `type` for node unique property constraint will be updated to `NODE_UNIQUENE One way of filtering the output from `SHOW CONSTRAINTS` by constraint type is the use of type keywords, listed in the xref::constraints/syntax.adoc#administration-constraints-syntax-list-type-filter[syntax for listing constraints type filter table]. -For example, to show only unique property constraints, use `SHOW UNIQUENESS CONSTRAINTS`. +For example, to show only uniqueness constraints, use `SHOW UNIQUENESS CONSTRAINTS`. Another more flexible way of filtering the output is to use the `WHERE` clause. An example is to only show constraints on relationships. diff --git a/modules/ROOT/pages/constraints/index.adoc b/modules/ROOT/pages/constraints/index.adoc index 10ac58800..4dff78b1a 100644 --- a/modules/ROOT/pages/constraints/index.adoc +++ b/modules/ROOT/pages/constraints/index.adoc @@ -14,14 +14,14 @@ This section explains how to manage constraints used for ensuring data integrity The following constraint types are available: *Unique node property constraints*:: -Unique node property constraints ensure that property values are unique for all nodes with a specific label. -For unique property constraints on multiple properties, the combination of the property values is unique. -Unique constraints do not require all nodes to have a unique value for the properties listed -- nodes without all properties are not subject to this rule. +Unique node property constraints, or node uniqueness constraints, ensure that property values are unique for all nodes with a specific label. +For uniqueness constraints on multiple properties, the combination of the property values is unique. +Node uniqueness constraints do not require all nodes to have a unique value for the properties listed -- nodes without all properties are not subject to this rule. *Unique relationship property constraints*:: -Unique relationship property constraints ensure that property values are unique for all relationships with a specific type. -For unique property constraints on multiple properties, the combination of the property values is unique. -Unique constraints do not require all relationships to have a unique value for the properties listed -- relationships without all properties are not subject to this rule. +Unique relationship property constraints, or relationship uniqueness constraints, ensure that property values are unique for all relationships with a specific type. +For uniqueness constraints on multiple properties, the combination of the property values is unique. +Relationship uniqueness constraints do not require all relationships to have a unique value for the properties listed -- relationships without all properties are not subject to this rule. *Node property existence constraints* label:enterprise-edition[]:: Node property existence constraints ensure that a property exists for all nodes with a specific label. @@ -73,15 +73,15 @@ Databases containing one of these constraint types cannot be opened using Neo4j Creating a constraint has the following implications on indexes: -* Adding a node key, relationship key, or unique property constraint on a single property also adds an index on that property and therefore, an index of the same index type, label/relationship type, and property combination cannot be added separately. -* Adding a node key, relationship key, or unique property constraint for a set of properties also adds an index on those properties and therefore, an index of the same index type, label/relationship type, and properties combination cannot be added separately. +* Adding a node key, relationship key, or uniqueness constraint on a single property also adds an index on that property and therefore, an index of the same index type, label/relationship type, and property combination cannot be added separately. +* Adding a node key, relationship key, or uniqueness constraint for a set of properties also adds an index on those properties and therefore, an index of the same index type, label/relationship type, and properties combination cannot be added separately. * Cypher will use these indexes for lookups just like other indexes. Refer to xref::indexes-for-search-performance.adoc[] for more details on indexes. -* If a node key, relationship key, or unique property constraint is dropped and the backing index is still required, the index need to be created explicitly. +* If a node key, relationship key, or uniqueness constraint is dropped and the backing index is still required, the index need to be created explicitly. Additionally, the following is true for constraints: -* A given label or relationship type can have multiple constraints, and unique and property existence constraints can be combined on the same property. +* A given label or relationship type can have multiple constraints, and uniqueness and property existence constraints can be combined on the same property. * Adding constraints is an atomic operation that can take a while -- all existing data has to be scanned before Neo4j DBMS can turn the constraint 'on'. * Best practice is to give the constraint a name when it is created. If the constraint is not explicitly named, it will get an auto-generated name. diff --git a/modules/ROOT/pages/constraints/syntax.adoc b/modules/ROOT/pages/constraints/syntax.adoc index 366bdd5f2..90671ffc6 100644 --- a/modules/ROOT/pages/constraints/syntax.adoc +++ b/modules/ROOT/pages/constraints/syntax.adoc @@ -32,7 +32,7 @@ Creating a constraint requires the xref::access-control/database-administration. [[administration-constraints-syntax-create-node-unique]] [discrete] -=== Create a unique node property constraint +=== Create a node uniqueness constraint This command creates a uniqueness constraint on nodes with the specified label and properties. @@ -57,7 +57,7 @@ Index provider can be specified using the `OPTIONS` clause. [[administration-constraints-syntax-create-rel-unique]] [discrete] -=== Create a unique relationship property constraint +=== Create a relationship uniqueness constraint This command creates a uniqueness constraint on relationships with the specified relationship type and properties. @@ -253,13 +253,13 @@ The type filtering keywords filters the returned constraints on constraint type: This is the default if none is given. |NODE UNIQUE[NESS] -| Returns the node unique property constraints. +| Returns the node uniqueness constraints. |REL[ATIONSHIP] UNIQUE[NESS] -| Returns the relationship unique property constraints. +| Returns the relationship uniqueness constraints. |UNIQUE[NESS] -| Returns all unique property constraints, for both nodes and relationships. +| Returns all uniqueness constraints, for both nodes and relationships. |NODE [PROPERTY] EXIST[ENCE] | Returns the node property existence constraints. diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index 6f43abaf7..dbd54b691 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -80,7 +80,7 @@ label:returnValues[] label:deprecated[] [source, cypher, role="noheader"] ---- -SHOW NODE UNIQUE CONSTRAINTS YIELD type +SHOW NODE UNIQUENESS CONSTRAINTS YIELD type ---- a| @@ -1568,7 +1568,7 @@ REQUIRE (n.propertyName_1, …, n.propertyName_n) IS UNIQUE [OPTIONS "{" option: value[, ...] "}"] ---- a| -Unique property constraints now allow multiple properties, ensuring that the combination of property values are unique. +Uniqueness constraints now allow multiple properties, ensuring that the combination of property values are unique. a| label:functionality[] @@ -1581,7 +1581,7 @@ ON (n:LabelName) ASSERT (n.propertyName_1, …, n.propertyName_n) IS UNIQUE ---- a| -Unique property constraints now allow multiple properties. +Uniqueness constraints now allow multiple properties. Replaced by: [source, cypher, role="noheader"] diff --git a/modules/ROOT/pages/execution-plans/operator-summary.adoc b/modules/ROOT/pages/execution-plans/operator-summary.adoc index 00123b90c..40e7dc3bf 100644 --- a/modules/ROOT/pages/execution-plans/operator-summary.adoc +++ b/modules/ROOT/pages/execution-plans/operator-summary.adoc @@ -53,13 +53,13 @@ Tests for the absence of a pattern predicate. | | xref::execution-plans/operators.adoc#query-plan-assert-same-node[AssertSameNode] -| Used to ensure that no unique constraints are violated. +| Used to ensure that no uniqueness constraints are violated. | | | | xref::execution-plans/operators.adoc#query-plan-asserting-multi-node-index-seek[AssertingMultiNodeIndexSeek] -| Used to ensure that no unique constraints are violated. +| Used to ensure that no uniqueness constraints are violated. | | | diff --git a/modules/ROOT/pages/execution-plans/operators.adoc b/modules/ROOT/pages/execution-plans/operators.adoc index 634a006bc..38ede9ffc 100644 --- a/modules/ROOT/pages/execution-plans/operators.adoc +++ b/modules/ROOT/pages/execution-plans/operators.adoc @@ -1141,9 +1141,9 @@ Total database accesses: 0, total allocated memory: 184 == Asserting Multi Node Index Seek // AssertingMultiNodeIndexSeek -The `AssertingMultiNodeIndexSeek` operator is used to ensure that no unique constraints are violated. +The `AssertingMultiNodeIndexSeek` operator is used to ensure that no uniqueness constraints are violated. The example looks for the presence of a team with the supplied name and id, and if one does not exist, it will be created. -Owing to the existence of two unique constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. +Owing to the existence of two uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. .AssertingMultiNodeIndexSeek @@ -2635,9 +2635,9 @@ Total database accesses: 487, total allocated memory: 5256 == Assert Same Node // AssertSameNode -The `AssertSameNode` operator is used to ensure that no unique constraints are violated in the slotted and interpreted runtime. +The `AssertSameNode` operator is used to ensure that no uniqueness constraints are violated in the slotted and interpreted runtime. The example looks for the presence of a team with the supplied name and id, and if one does not exist, it will be created. -Owing to the existence of two unique constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. +Owing to the existence of two uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. .AssertSameNode @@ -4889,7 +4889,7 @@ The `CreateConstraint` operator creates a constraint. This constraint can either be an uniqueness, existence, node key, or relationship key constraint. Existence, node key, and relationship key constraints will only appear in Enterprise Edition. -The following query will create a unique constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label. +The following query will create a uniqueness constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label. .CreateConstraint @@ -4930,7 +4930,7 @@ Total database accesses: ? To not get an error creating the same constraint twice, we use the `DoNothingIfExists` operator for constraints. This will make sure no other constraint with the given name or another constraint of the same type and schema already exists before the specific `CreateConstraint` operator creates the constraint. If it finds a constraint with the given name or with the same type and schema it will stop the execution and no new constraint is created. -The following query will create a unique constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label only if no constraint named `uniqueness` or unique constraint on `+(:Country {name})+` already exists. +The following query will create a uniqueness constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label only if no constraint named `uniqueness` or uniqueness constraint on `+(:Country {name})+` already exists. .DoNothingIfExists(CONSTRAINT) diff --git a/modules/ROOT/pages/introduction/index.adoc b/modules/ROOT/pages/introduction/index.adoc index 928be4699..6f60a1bda 100644 --- a/modules/ROOT/pages/introduction/index.adoc +++ b/modules/ROOT/pages/introduction/index.adoc @@ -53,7 +53,7 @@ And these are examples of clauses that are used to update the graph: * `SET` (and `REMOVE`): Set values to properties and add labels on nodes using `SET` and use `REMOVE` to remove them. -* `MERGE`: Match existing or create new nodes and patterns. This is especially useful together with unique constraints. +* `MERGE`: Match existing or create new nodes and patterns. This is especially useful together with uniqueness constraints. .Cypher Query From d2577c426f69b61aa0af4e31c352f15d6b259a6a Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Thu, 24 Nov 2022 15:13:30 +0100 Subject: [PATCH 04/12] Address review comments --- modules/ROOT/pages/constraints/examples.adoc | 41 ++++++++++++------- .../ROOT/pages/execution-plans/operators.adoc | 7 +++- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index c2a25f62a..1b2d81493 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -27,7 +27,7 @@ Examples of how to manage constraints used for ensuring data integrity. === Create a node uniqueness constraint When creating a uniqueness constraint, a name can be provided. -The constraint ensures that your database will never contain more than one node with a specific label and one property value. +The constraint ensures that your database will never contain more than one node with the specified label and property value. .+CREATE CONSTRAINT+ @@ -61,8 +61,9 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [[administration-constraints-create-a-unique-constraint-nodes-only-if-it-does-not-already-exist]] === Create a node uniqueness constraint only if it does not already exist -If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. -The uniqueness constraint ensures that your database will never contain more than one node with a specific label and one property value. +Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. +This will ensure no error is thrown if any other constraint with the given name or another node uniqueness constraint on the same schema already existed. +The uniqueness constraint ensures that your database will never contain more than one node with the specified label and property value. [NOTE] ==== @@ -107,7 +108,7 @@ To create a uniqueness constraint with a specific index provider for the backing The index type of the backing index is set with the `indexProvider` option. -Valid values for the index provider are: +The only valid value for the index provider is: * `range-1.0` label:default[] @@ -143,6 +144,7 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. ====== +There is no valid index configuration values for the constraint-backing range indexes. [discrete] [[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-nodes]] @@ -336,7 +338,7 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. === Create a relationship uniqueness constraint When creating a uniqueness constraint, a name can be provided. -The constraint ensures that your database will never contain more than one relationship with a specific relationship type and one property value. +The uniqueness constraint ensures that your database will never contain more than one relationship with the specified relationship type and property value. .+CREATE CONSTRAINT+ @@ -365,8 +367,9 @@ Relationship uniqueness constraints added: 1 [[administration-constraints-create-a-unique-constraint-relationships-only-if-it-does-not-already-exist]] === Create a relationship uniqueness constraint only if it does not already exist -If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. -The uniqueness constraint ensures that your database will never contain more than one relationship with a specific relationship type and one property value. +Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. +This will ensure no error is thrown if any other constraint with the given name or another relationship uniqueness constraint on the same schema already existed. +The uniqueness constraint ensures that your database will never contain more than one relationship with the specified relationship type and property value. [NOTE] ==== @@ -406,7 +409,7 @@ To create a uniqueness constraint with a specific index provider for the backing The index type of the backing index is set with the `indexProvider` option. -Valid values for the index provider are: +The only valid value for the index provider is: * `range-1.0` label:default[] @@ -437,6 +440,8 @@ Relationship uniqueness constraints added: 1 ====== +There is no valid index configuration values for the constraint-backing range indexes. + [discrete] [[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-relationships]] @@ -657,7 +662,8 @@ For the node property existence constraints they will say `Node property existen [[administration-constraints-create-a-node-property-existence-constraint-only-if-it-does-not-already-exist]] === Create a node property existence constraint only if it does not already exist -If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. +Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. +This will ensure no error is thrown if any other constraint with the given name or another node property existence constraint on the same schema already existed. The node property existence constraint ensures that all nodes with a certain label have a certain property. No constraint will be created if any other constraint with the given name or another node property existence constraint on the same schema already exists. @@ -905,7 +911,8 @@ For the relationship property existence constraints they will say `Relationship [[administration-constraints-create-a-relationship-property-existence-constraint-only-if-it-does-not-already-exist]] === Create a relationship property existence constraint only if it does not already exist -If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. +Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. +This will ensure no error is thrown if any other constraint with the given name or another relationship property existence constraint on the same schema already existed. The relationship property existence constraint ensures all relationships with a certain type have a certain property. No constraint will be created if any other constraint with the given name or another relationship property existence constraint on the same schema already exists. @@ -1148,7 +1155,8 @@ Node key constraints added: 1 [[administration-constraints-create-a-node-key-constraint-only-if-it-does-not-already-exist]] === Create a node key constraint only if it does not already exist -If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. +Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. +This will ensure no error is thrown if any other constraint with the given name or another node key constraint on the same schema already existed. The node key constraint ensures that all nodes with a particular label have a set of defined properties whose combined value is unique and all properties in the set are present. No constraint will be created if any other constraint with the given name or another node key constraint on the same schema already exists. @@ -1188,7 +1196,7 @@ To create a node key constraint with a specific index provider for the backing i The index type of the backing index is set with the `indexProvider` option. -Valid values for the index provider are: +The only valid value for the index provider is: * `range-1.0` label:default[] @@ -1217,6 +1225,8 @@ Node key constraints added: 1 ====== +There is no valid index configuration values for the constraint-backing range indexes. + [discrete] [[administration-constraints-failure-to-create-a-node-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema]] @@ -1461,7 +1471,8 @@ Relationship key constraints added: 1 [[administration-constraints-create-a-rel-key-constraint-only-if-it-does-not-already-exist]] === Create a relationship key constraint only if it does not already exist -If it is not known whether a constraint exists or not, add `IF NOT EXISTS` to ensure it does. +Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. +This will ensure no error is thrown if any other constraint with the given name or another relationship key constraint on the same schema already existed. The relationship key constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique and all properties in the set are present. No constraint will be created if any other constraint with the given name or another relationship key constraint on the same schema already exists. @@ -1501,7 +1512,7 @@ To create a relationship key constraint with a specific index provider for the b The index type of the backing index is set with the `indexProvider` option. -Valid values for the index provider are: +The only valid value for the index provider is: * `range-1.0` label:default[] @@ -1530,6 +1541,8 @@ Relationship key constraints added: 1 ====== +There is no valid index configuration values for the constraint-backing range indexes. + [discrete] [[administration-constraints-failure-to-create-a-rel-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema]] diff --git a/modules/ROOT/pages/execution-plans/operators.adoc b/modules/ROOT/pages/execution-plans/operators.adoc index 38ede9ffc..ce5f2ab0b 100644 --- a/modules/ROOT/pages/execution-plans/operators.adoc +++ b/modules/ROOT/pages/execution-plans/operators.adoc @@ -4886,8 +4886,11 @@ Total database accesses: 106, total allocated memory: 184 The `CreateConstraint` operator creates a constraint. -This constraint can either be an uniqueness, existence, node key, or relationship key constraint. -Existence, node key, and relationship key constraints will only appear in Enterprise Edition. +This constraint can have any of the available constraint types: + +* Uniqueness constraints +* Property existence constraints label:enterprise-edition[] +* Node or relationship key constraints label:enterprise-edition[] The following query will create a uniqueness constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label. From 931644bce291ea02f1e9796ea358e399a57a81f4 Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Fri, 25 Nov 2022 10:52:23 +0100 Subject: [PATCH 05/12] Update links and titles for the subsections Also remove 2 places referencing the now removed `db.indexes` and `db.constraints` procedures --- .../database-administration.adoc | 4 - modules/ROOT/pages/constraints/examples.adoc | 319 +++++++++--------- modules/ROOT/pages/constraints/index.adoc | 2 +- modules/ROOT/pages/constraints/syntax.adoc | 22 +- ...ions-additions-removals-compatibility.adoc | 4 +- .../introduction/neo4j-databases-graphs.adoc | 4 +- modules/ROOT/pages/keyword-glossary.adoc | 14 +- 7 files changed, 183 insertions(+), 186 deletions(-) diff --git a/modules/ROOT/pages/access-control/database-administration.adoc b/modules/ROOT/pages/access-control/database-administration.adoc index e44d30f3c..3f4e6447e 100644 --- a/modules/ROOT/pages/access-control/database-administration.adoc +++ b/modules/ROOT/pages/access-control/database-administration.adoc @@ -681,8 +681,6 @@ For example, to grant the role `regularUsers` the ability to create indexes on t GRANT CREATE INDEX ON DATABASE neo4j TO regularUsers ---- -The `SHOW INDEXES` privilege only affects the xref::indexes-for-search-performance.adoc#administration-indexes-list-indexes[`SHOW INDEXES` command], and not the older procedures for listing indexes, such as `db.indexes`. - [[access-control-database-administration-constraints]] == The `CONSTRAINT MANAGEMENT` privileges @@ -743,8 +741,6 @@ For example, to grant the role `regularUsers` the ability to create constraints GRANT CREATE CONSTRAINT ON DATABASE neo4j TO regularUsers ---- -The `SHOW CONSTRAINTS` privilege only affects the xref::constraints/syntax.adoc#administration-constraints-syntax-list[`SHOW CONSTRAINTS` command], and not the older procedures for listing constraints, such as `db.constraints`. - [[access-control-database-administration-tokens]] == The `NAME MANAGEMENT` privileges diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index 1b2d81493..a853b6d5e 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -1,6 +1,6 @@ :description: Examples of how to manage constraints used for ensuring data integrity. -[[administration-constraints-examples]] +[[constraints-examples]] = Examples [abstract] @@ -9,21 +9,21 @@ Examples of how to manage constraints used for ensuring data integrity. -- -[[administration-constraints-unique-nodes]] +[[constraints-examples-node-uniqueness]] == Node uniqueness constraints -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes[] -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes-only-if-it-does-not-already-exist[] -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-nodes-with-specified-index-provider[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-nodes[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-nodes-on-same-schema-as-existing-index[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-that-complies-with-unique-property-constraints[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-that-violates-a-unique-property-constraint[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-nodes[] +* xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint-if-not-exist[] +* xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint-with-index-provider[] +* xref::constraints/examples.adoc#constraints-create-an-already-existing-node-uniqueness-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint-on-same-schema-as-existing-index[] +* xref::constraints/examples.adoc#constraints-create-a-node-that-complies-with-a-uniqueness-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-that-violates-a-uniqueness-constraint[] +* xref::constraints/examples.adoc#constraints-fail-to-create-a-uniqueness-constraint-due-to-conflicting-nodes[] [discrete] -[[administration-constraints-create-a-unique-constraint-nodes]] +[[constraints-create-a-node-uniqueness-constraint]] === Create a node uniqueness constraint When creating a uniqueness constraint, a name can be provided. @@ -58,8 +58,8 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [discrete] -[[administration-constraints-create-a-unique-constraint-nodes-only-if-it-does-not-already-exist]] -=== Create a node uniqueness constraint only if it does not already exist +[[constraints-create-a-node-uniqueness-constraint-if-not-exist]] +=== Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. This will ensure no error is thrown if any other constraint with the given name or another node uniqueness constraint on the same schema already existed. @@ -101,8 +101,8 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [discrete] -[[administration-constraints-create-a-unique-constraint-nodes-with-specified-index-provider]] -=== Create a node uniqueness constraint with specified index provider +[[constraints-create-a-node-uniqueness-constraint-with-index-provider]] +=== Specifying an index provider when creating a constraint To create a uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. @@ -146,9 +146,10 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. There is no valid index configuration values for the constraint-backing range indexes. + [discrete] -[[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-nodes]] -=== Failure to create an already existing node uniqueness constraint +[[constraints-create-an-already-existing-node-uniqueness-constraint]] +=== Creating an already existing constraint will fail .+CREATE CONSTRAINT+ @@ -184,8 +185,8 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. [discrete] -[[administration-constraints-failure-to-create-a-unique-property-constraint-nodes-on-same-schema-as-existing-index]] -=== Failure to create a node uniqueness constraint on same schema as existing index +[[constraints-create-a-node-uniqueness-constraint-on-same-schema-as-existing-index]] +=== Creating a constraint on same schema as an existing index will fail .+CREATE CONSTRAINT+ @@ -216,8 +217,8 @@ A constraint cannot be created until the index has been dropped. [discrete] -[[administration-constraints-create-a-node-that-complies-with-unique-property-constraints]] -=== Create a node that complies with uniqueness constraints +[[constraints-create-a-node-that-complies-with-a-uniqueness-constraint]] +=== Creating a node that complies with an existing constraint .+CREATE NODE+ @@ -250,8 +251,8 @@ Labels added: 1 [discrete] -[[administration-constraints-create-a-node-that-violates-a-unique-property-constraint]] -=== Create a node that violates a uniqueness constraint +[[constraints-create-a-node-that-violates-a-uniqueness-constraint]] +=== Creating a node that violates an existing constraint will fail .+CREATE NODE+ @@ -282,8 +283,8 @@ Node(0) already exists with label `Book` and property `isbn` = '1449356265' [discrete] -[[administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-nodes]] -=== Failure to create a uniqueness constraint due to conflicting nodes +[[constraints-fail-to-create-a-uniqueness-constraint-due-to-conflicting-nodes]] +=== Creating a constraint when there exist conflicting nodes will fail .+CREATE CONSTRAINT+ @@ -320,21 +321,21 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. ====== -[[administration-constraints-unique-relationships]] +[[constraints-examples-relationship-uniqueness]] == Relationship uniqueness constraints -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships[] -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships-only-if-it-does-not-already-exist[] -* xref::constraints/examples.adoc#administration-constraints-create-a-unique-constraint-relationships-with-specified-index-provider[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-relationships[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-relationships-on-same-schema-as-existing-index[] -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-complies-with-unique-property-constraints[] -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-violates-a-unique-property-constraint[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-relationships[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints-if-not-exist[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints-with-index-provider[] +* xref::constraints/examples.adoc#constraints-create-an-already-existing-relationship-uniqueness-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraint-on-same-schema-as-existing-index[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-that-complies-with-a-uniqueness-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-that-violates-a-uniqueness-constraint[] +* xref::constraints/examples.adoc#constraints-fail-to-create-a-uniqueness-constraint-due-to-conflicting-relationships[] [discrete] -[[administration-constraints-create-a-unique-constraint-relationships]] +[[constraints-create-a-relationship-uniqueness-constraints]] === Create a relationship uniqueness constraint When creating a uniqueness constraint, a name can be provided. @@ -364,8 +365,8 @@ Relationship uniqueness constraints added: 1 [discrete] -[[administration-constraints-create-a-unique-constraint-relationships-only-if-it-does-not-already-exist]] -=== Create a relationship uniqueness constraint only if it does not already exist +[[constraints-create-a-relationship-uniqueness-constraints-if-not-exist]] +=== Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. This will ensure no error is thrown if any other constraint with the given name or another relationship uniqueness constraint on the same schema already existed. @@ -402,8 +403,8 @@ Relationship uniqueness constraints added: 1 [discrete] -[[administration-constraints-create-a-unique-constraint-relationships-with-specified-index-provider]] -=== Create a relationship uniqueness constraint with specified index provider +[[constraints-create-a-relationship-uniqueness-constraints-with-index-provider]] +=== Specifying an index provider when creating a constraint To create a uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. @@ -444,8 +445,8 @@ There is no valid index configuration values for the constraint-backing range in [discrete] -[[administration-constraints-failure-to-create-an-already-existing-unique-property-constraint-relationships]] -=== Failure to create an already existing relationship uniqueness constraint +[[constraints-create-an-already-existing-relationship-uniqueness-constraint]] +=== Creating an already existing constraint will fail .+CREATE CONSTRAINT+ @@ -476,8 +477,8 @@ Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', sche [discrete] -[[administration-constraints-failure-to-create-a-unique-property-constraint-relationships-on-same-schema-as-existing-index]] -=== Failure to create a relationship uniqueness constraint on same schema as existing index +[[constraints-create-a-relationship-uniqueness-constraint-on-same-schema-as-existing-index]] +=== Creating a constraint on same schema as an existing index will fail .+CREATE CONSTRAINT+ @@ -508,8 +509,8 @@ A constraint cannot be created until the index has been dropped. [discrete] -[[administration-constraints-create-a-relationship-that-complies-with-unique-property-constraints]] -=== Create a relationship that complies with uniqueness constraints +[[constraints-create-a-relationship-that-complies-with-a-uniqueness-constraint]] +=== Creating a relationship that complies with an existing constraint .+CREATE RELATIONSHIP+ @@ -543,8 +544,8 @@ Labels added: 2 [discrete] -[[administration-constraints-create-a-relationship-that-violates-a-unique-property-constraint]] -=== Create a relationship that violates a uniqueness constraint +[[constraints-create-a-relationship-that-violates-a-uniqueness-constraint]] +=== Creating a relationship that violates an existing constraint will fail .+CREATE RELATIONSHIP+ @@ -576,8 +577,8 @@ Relationship(0) already exists with type `FRIENDS_WITH` and property `nickname` [discrete] -[[administration-constraints-failure-to-create-a-unique-property-constraint-due-to-conflicting-relationships]] -=== Failure to create a uniqueness constraint due to conflicting relationships +[[constraints-fail-to-create-a-uniqueness-constraint-due-to-conflicting-relationships]] +=== Creating a constraint when there exist conflicting relationships will fail .+CREATE CONSTRAINT+ @@ -610,21 +611,20 @@ Both Relationship(0) and Relationship(1) have the type `FRIENDS_WITH` and proper [role=enterprise-edition] -[[administration-constraints-prop-exist-nodes]] +[[constraints-examples-node-property-existence]] == Node property existence constraints -* xref::constraints/examples.adoc#administration-constraints-create-a-node-property-existence-constraint[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-property-existence-constraint-only-if-it-does-not-already-exist[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-an-already-existing-node-property-existence-constraint[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-that-complies-with-property-existence-constraints[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-that-violates-a-property-existence-constraint[] -* xref::constraints/examples.adoc#administration-constraints-removing-an-existence-constrained-node-property[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-node-property-existence-constraint-due-to-existing-node[] -//* xref::constraints/examples.adoc# +* xref::constraints/examples.adoc#constraints-create-a-node-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-property-existence-constraint-if-not-exist[] +* xref::constraints/examples.adoc#constraints-create-an-already-existing-node-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-that-complies-with-a-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-that-violates-a-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-removing-an-existence-constrained-node-property[] +* xref::constraints/examples.adoc#constraints-fail-to-create-a-property-existence-constraint-due-to-existing-node[] [discrete] -[[administration-constraints-create-a-node-property-existence-constraint]] +[[constraints-create-a-node-property-existence-constraint]] === Create a node property existence constraint When creating a node property existence constraint, a name can be provided. @@ -658,9 +658,10 @@ For the node property existence constraints they will say `Node property existen ====== + [discrete] -[[administration-constraints-create-a-node-property-existence-constraint-only-if-it-does-not-already-exist]] -=== Create a node property existence constraint only if it does not already exist +[[constraints-create-a-node-property-existence-constraint-if-not-exist]] +=== Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. This will ensure no error is thrown if any other constraint with the given name or another node property existence constraint on the same schema already existed. @@ -696,8 +697,8 @@ Assuming a constraint with the name `constraint_name` already existed: [discrete] -[[administration-constraints-failure-to-create-an-already-existing-node-property-existence-constraint]] -=== Failure to create an already existing node property existence constraint +[[constraints-create-an-already-existing-node-property-existence-constraint]] +=== Creating an already existing constraint will fail .+CREATE CONSTRAINT+ @@ -729,8 +730,8 @@ Constraint( id=3, name='preExistingNodePropExist', type='NODE PROPERTY EXISTENCE [discrete] -[[administration-constraints-create-a-node-that-complies-with-property-existence-constraints]] -=== Create a node that complies with property existence constraints +[[constraints-create-a-node-that-complies-with-a-property-existence-constraint]] +=== Creating a node that complies with an existing constraint .+CREATE NODE+ @@ -763,8 +764,8 @@ Labels added: 1 [discrete] -[[administration-constraints-create-a-node-that-violates-a-property-existence-constraint]] -=== Create a node that violates a property existence constraint +[[constraints-create-a-node-that-violates-a-property-existence-constraint]] +=== Creating a node that violates an existing constraint will fail .+CREATE NODE+ @@ -794,8 +795,8 @@ Node(0) with label `Book` must have the property `isbn` [discrete] -[[administration-constraints-removing-an-existence-constrained-node-property]] -=== Removing an existence constrained node property +[[constraints-removing-an-existence-constrained-node-property]] +=== Removing an existence constrained node property will fail .+REMOVE PROPERTY+ @@ -827,8 +828,8 @@ Node(0) with label `Book` must have the property `isbn` [discrete] -[[administration-constraints-failure-to-create-a-node-property-existence-constraint-due-to-existing-node]] -=== Failure to create a node property existence constraint due to existing node +[[constraints-fail-to-create-a-property-existence-constraint-due-to-existing-node]] +=== Creating a constraint when there exist conflicting nodes will fail .+CREATE CONSTRAINT+ @@ -859,20 +860,20 @@ Node(0) with label `Book` must have the property `isbn` [role=enterprise-edition] -[[administration-constraints-prop-exist-rels]] +[[constraints-examples-relationship-property-existence]] == Relationship property existence constraints -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-property-existence-constraint[] -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-property-existence-constraint-only-if-it-does-not-already-exist[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-an-already-existing-relationship-property-existence-constraint[] -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-complies-with-property-existence-constraints[] -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-violates-a-property-existence-constraint[] -* xref::constraints/examples.adoc#administration-constraints-removing-an-existence-constrained-relationship-property[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-relationship-property-existence-constraint-due-to-existing-relationship[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-property-existence-constraint-if-not-exist[] +* xref::constraints/examples.adoc#constraints-create-an-already-existing-relationship-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-that-complies-with-a-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-that-violates-a-property-existence-constraint[] +* xref::constraints/examples.adoc#constraints-removing-an-existence-constrained-relationship-property[] +* xref::constraints/examples.adoc#constraints-fail-to-create-a-property-existence-constraint-due-to-existing-relationship[] [discrete] -[[administration-constraints-create-a-relationship-property-existence-constraint]] +[[constraints-create-a-relationship-property-existence-constraint]] === Create a relationship property existence constraint When creating a relationship property existence constraint, a name can be provided. @@ -908,8 +909,8 @@ For the relationship property existence constraints they will say `Relationship [discrete] -[[administration-constraints-create-a-relationship-property-existence-constraint-only-if-it-does-not-already-exist]] -=== Create a relationship property existence constraint only if it does not already exist +[[constraints-create-a-relationship-property-existence-constraint-if-not-exist]] +=== Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. This will ensure no error is thrown if any other constraint with the given name or another relationship property existence constraint on the same schema already existed. @@ -945,8 +946,8 @@ Assuming a constraint with the name `constraint_name` already existed: [discrete] -[[administration-constraints-failure-to-create-an-already-existing-relationship-property-existence-constraint]] -=== Failure to create an already existing relationship property existence constraint +[[constraints-create-an-already-existing-relationship-property-existence-constraint]] +=== Creating an already existing constraint will fail .+CREATE CONSTRAINT+ @@ -977,8 +978,8 @@ There already exists a constraint called 'relPropExist'. [discrete] -[[administration-constraints-create-a-relationship-that-complies-with-property-existence-constraints]] -=== Create a relationship that complies with property existence constraints +[[constraints-create-a-relationship-that-complies-with-a-property-existence-constraint]] +=== Creating a relationship that complies with an existing constraint .+CREATE RELATIONSHIP+ @@ -1012,8 +1013,8 @@ Labels added: 2 [discrete] -[[administration-constraints-create-a-relationship-that-violates-a-property-existence-constraint]] -=== Create a relationship that violates a property existence constraint +[[constraints-create-a-relationship-that-violates-a-property-existence-constraint]] +=== Creating a relationship that violates an existing constraint will fail .+CREATE RELATIONSHIP+ @@ -1043,8 +1044,8 @@ Relationship(0) with type `LIKED` must have the property `day` [discrete] -[[administration-constraints-removing-an-existence-constrained-relationship-property]] -=== Removing an existence constrained relationship property +[[constraints-removing-an-existence-constrained-relationship-property]] +=== Removing an existence constrained relationship property will fail .+REMOVE PROPERTY+ @@ -1075,8 +1076,8 @@ Relationship(0) with type `LIKED` must have the property `day` [discrete] -[[administration-constraints-failure-to-create-a-relationship-property-existence-constraint-due-to-existing-relationship]] -=== Failure to create a relationship property existence constraint due to existing relationship +[[constraints-fail-to-create-a-property-existence-constraint-due-to-existing-relationship]] +=== Creating a constraint when there exist conflicting relationships will fail .+CREATE CONSTRAINT+ @@ -1107,22 +1108,22 @@ Relationship(0) with type `LIKED` must have the property `day` [role=enterprise-edition] -[[administration-constraints-node-key]] +[[constraints-examples-node-key]] == Node key constraints -* xref::constraints/examples.adoc#administration-constraints-create-a-node-key-constraint[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-key-constraint-only-if-it-does-not-already-exist[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-key-constraint-with-specified-index-provider[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-node-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-node-key-constraint-with-the-same-name-as-existing-index[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-that-complies-with-node-key-constraints[] -* xref::constraints/examples.adoc#administration-constraints-create-a-node-that-violates-a-node-key-constraint[] -* xref::constraints/examples.adoc#administration-constraints-removing-a-node-key-constrained-property[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-node-key-constraint-due-to-existing-node[] +* xref::constraints/examples.adoc#constraints-create-a-node-key-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-key-constraint-if-not-exist[] +* xref::constraints/examples.adoc#constraints-create-a-node-key-constraint-with-index-provider[] +* xref::constraints/examples.adoc#constraints-node-key-and-uniqueness-constraint-on-the-same-schema[] +* xref::constraints/examples.adoc#constraints-create-a-node-key-constraint-with-the-same-name-as-existing-index[] +* xref::constraints/examples.adoc#constraints-create-a-node-that-complies-with-a-node-key-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-node-that-violates-a-node-key-constraint[] +* xref::constraints/examples.adoc#constraints-removing-a-node-key-constrained-property[] +* xref::constraints/examples.adoc#constraints-fail-to-create-a-node-key-constraint-due-to-existing-node[] [discrete] -[[administration-constraints-create-a-node-key-constraint]] +[[constraints-create-a-node-key-constraint]] === Create a node key constraint When creating a node key constraint, a name can be provided. @@ -1152,8 +1153,8 @@ Node key constraints added: 1 [discrete] -[[administration-constraints-create-a-node-key-constraint-only-if-it-does-not-already-exist]] -=== Create a node key constraint only if it does not already exist +[[constraints-create-a-node-key-constraint-if-not-exist]] +=== Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. This will ensure no error is thrown if any other constraint with the given name or another node key constraint on the same schema already existed. @@ -1189,8 +1190,8 @@ Assuming a node key constraint on `(:Person {firstname, surname})` already exist [discrete] -[[administration-constraints-create-a-node-key-constraint-with-specified-index-provider]] -=== Create a node key constraint with specified index provider +[[constraints-create-a-node-key-constraint-with-index-provider]] +=== Specifying an index provider when creating a constraint To create a node key constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. @@ -1229,8 +1230,8 @@ There is no valid index configuration values for the constraint-backing range in [discrete] -[[administration-constraints-failure-to-create-a-node-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema]] -=== Failure to create a node key constraint when a uniqueness constraint exists on the same schema +[[constraints-node-key-and-uniqueness-constraint-on-the-same-schema]] +=== Node key and uniqueness constraints are not allowed on the same schema .+CREATE CONSTRAINT+ @@ -1261,8 +1262,8 @@ Constraint( id=4, name='preExistingUnique', type='UNIQUENESS', schema=(:Person { [discrete] -[[administration-constraints-failure-to-create-a-node-key-constraint-with-the-same-name-as-existing-index]] -=== Failure to create a node key constraint with the same name as existing index +[[constraints-create-a-node-key-constraint-with-the-same-name-as-existing-index]] +=== Creating a constraint on same name as an existing index will fail .+CREATE CONSTRAINT+ @@ -1293,8 +1294,8 @@ There already exists an index called 'bookTitle'. [discrete] -[[administration-constraints-create-a-node-that-complies-with-node-key-constraints]] -=== Create a node that complies with node key constraints +[[constraints-create-a-node-that-complies-with-a-node-key-constraint]] +=== Creating a node that complies with an existing constraint .+CREATE NODE+ @@ -1327,8 +1328,8 @@ Labels added: 1 [discrete] -[[administration-constraints-create-a-node-that-violates-a-node-key-constraint]] -=== Create a node that violates a node key constraint +[[constraints-create-a-node-that-violates-a-node-key-constraint]] +=== Creating a node that violates an existing constraint will fail .+CREATE NODE+ @@ -1358,8 +1359,8 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) [discrete] -[[administration-constraints-removing-a-node-key-constrained-property]] -=== Removing a +NODE KEY+-constrained property +[[constraints-removing-a-node-key-constrained-property]] +=== Removing a +NODE KEY+-constrained property will fail .+REMOVE PROPERTY+ @@ -1390,8 +1391,8 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) [discrete] -[[administration-constraints-failure-to-create-a-node-key-constraint-due-to-existing-node]] -=== Failure to create a node key constraint due to existing node +[[constraints-fail-to-create-a-node-key-constraint-due-to-existing-node]] +=== Creating a constraint when there exist conflicting node will fail .+CREATE CONSTRAINT+ @@ -1423,22 +1424,22 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) [role=enterprise-edition] -[[administration-constraints-rel-key]] +[[constraints-examples-relationship-key]] == Relationship key constraints -* xref::constraints/examples.adoc#administration-constraints-create-a-rel-key-constraint[] -* xref::constraints/examples.adoc#administration-constraints-create-a-rel-key-constraint-only-if-it-does-not-already-exist[] -* xref::constraints/examples.adoc#administration-constraints-create-a-rel-key-constraint-with-specified-index-provider[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-rel-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-rel-key-constraint-with-the-same-name-as-existing-index[] -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-complies-with-rel-key-constraints[] -* xref::constraints/examples.adoc#administration-constraints-create-a-relationship-that-violates-a-rel-key-constraint[] -* xref::constraints/examples.adoc#administration-constraints-removing-a-rel-key-constrained-property[] -* xref::constraints/examples.adoc#administration-constraints-failure-to-create-a-rel-key-constraint-due-to-existing-relationship[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint-if-not-exist[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint-with-index-provider[] +* xref::constraints/examples.adoc#constraints-relationship-key-and-uniqueness-constraint-on-the-same-schema[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint-with-the-same-name-as-existing-index[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-that-complies-with-a-relationship-key-constraint[] +* xref::constraints/examples.adoc#constraints-create-a-relationship-that-violates-a-relationship-key-constraint[] +* xref::constraints/examples.adoc#constraints-removing-a-relationship-key-constrained-property[] +* xref::constraints/examples.adoc#constraints-fail-to-create-a-relationship-key-constraint-due-to-existing-relationship[] [discrete] -[[administration-constraints-create-a-rel-key-constraint]] +[[constraints-create-a-relationship-key-constraint]] === Create a relationship key constraint When creating a relationship key constraint, a name can be provided. @@ -1468,8 +1469,8 @@ Relationship key constraints added: 1 [discrete] -[[administration-constraints-create-a-rel-key-constraint-only-if-it-does-not-already-exist]] -=== Create a relationship key constraint only if it does not already exist +[[constraints-create-a-relationship-key-constraint-if-not-exist]] +=== Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. This will ensure no error is thrown if any other constraint with the given name or another relationship key constraint on the same schema already existed. @@ -1505,8 +1506,8 @@ Assuming a relationship key constraint on `()-[:ROAD {startPoint, endPoint}]-()` [discrete] -[[administration-constraints-create-a-rel-key-constraint-with-specified-index-provider]] -=== Create a relationship key constraint with specified index provider +[[constraints-create-a-relationship-key-constraint-with-index-provider]] +=== Specifying an index provider when creating a constraint To create a relationship key constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. @@ -1545,8 +1546,8 @@ There is no valid index configuration values for the constraint-backing range in [discrete] -[[administration-constraints-failure-to-create-a-rel-key-constraint-when-a-unique-property-constraint-exists-on-the-same-schema]] -=== Failure to create a relationship key constraint when a uniqueness constraint exists on the same schema +[[constraints-relationship-key-and-uniqueness-constraint-on-the-same-schema]] +=== Relationship key and uniqueness constraints are not allowed on the same schema .+CREATE CONSTRAINT+ @@ -1577,8 +1578,8 @@ Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', sche [discrete] -[[administration-constraints-failure-to-create-a-rel-key-constraint-with-the-same-name-as-existing-index]] -=== Failure to create a relationship key constraint with the same name as existing index +[[constraints-create-a-relationship-key-constraint-with-the-same-name-as-existing-index]] +=== Creating a constraint on same name as an existing index will fail .+CREATE CONSTRAINT+ @@ -1609,8 +1610,8 @@ There already exists an index called 'intersections'. [discrete] -[[administration-constraints-create-a-relationship-that-complies-with-rel-key-constraints]] -=== Create a relationship that complies with relationship key constraints +[[constraints-create-a-relationship-that-complies-with-a-relationship-key-constraint]] +=== Creating a relationship that complies with an existing constraint .+CREATE RELATIONSHIP+ @@ -1644,8 +1645,8 @@ Properties set: 2 [discrete] -[[administration-constraints-create-a-relationship-that-violates-a-rel-key-constraint]] -=== Create a relationship that violates a relationship key constraint +[[constraints-create-a-relationship-that-violates-a-relationship-key-constraint]] +=== Creating a relationship that violates an existing constraint will fail .+CREATE RELATIONSHIP+ @@ -1677,8 +1678,8 @@ Relationship(0) with type `INTERSECTION` must have the property `coordinates` [discrete] -[[administration-constraints-removing-a-rel-key-constrained-property]] -=== Removing a +RELATIONSHIP KEY+-constrained property +[[constraints-removing-a-relationship-key-constrained-property]] +=== Removing a +RELATIONSHIP KEY+-constrained property will fail .+REMOVE PROPERTY+ @@ -1710,8 +1711,8 @@ Relationship(0) with type `ROAD` must have the properties (`startPoint`, `endPoi [discrete] -[[administration-constraints-failure-to-create-a-rel-key-constraint-due-to-existing-relationship]] -=== Failure to create a relationship key constraint due to existing relationship +[[constraints-fail-to-create-a-relationship-key-constraint-due-to-existing-relationship]] +=== Creating a constraint when there exist conflicting relationships will fail .+CREATE CONSTRAINT+ @@ -1744,20 +1745,20 @@ Both Relationship(0) and Relationship(1) have the type `INTERSECTION` and proper ====== -[[administration-constraints-drop-constraint]] +[[constraints-examples-drop-constraint]] == Drop a constraint by name -* xref::constraints/examples.adoc#administration-constraints-drop-a-constraint[] -* xref::constraints/examples.adoc#administration-constraints-drop-a-non-existing-constraint[] +* xref::constraints/examples.adoc#constraints-drop-a-constraint[] +* xref::constraints/examples.adoc#constraints-drop-a-non-existing-constraint[] [discrete] -[[administration-constraints-drop-a-constraint]] +[[constraints-drop-a-constraint]] === Drop a constraint A constraint can be dropped using the name with the `DROP CONSTRAINT constraint_name` command. It is the same command for uniqueness, property existence and node/relationship key constraints. -The name of the constraint can be found using the xref::constraints/syntax.adoc#administration-constraints-syntax-list[`SHOW CONSTRAINTS` command], given in the output column `name`. +The name of the constraint can be found using the xref::constraints/syntax.adoc#constraints-syntax-list[`SHOW CONSTRAINTS` command], given in the output column `name`. .+DROP CONSTRAINT+ @@ -1786,7 +1787,7 @@ Named constraints removed: 1 [discrete] -[[administration-constraints-drop-a-non-existing-constraint]] +[[constraints-drop-a-non-existing-constraint]] === Drop a non-existing constraint If it is uncertain if any constraint with a given name exists and you want to drop it if it does but not get an error should it not, use `IF EXISTS`. @@ -1812,15 +1813,15 @@ DROP CONSTRAINT missing_constraint_name IF EXISTS ====== -[[administration-constraints-list-constraint]] +[[constraints-examples-list-constraint]] == Listing constraints -* xref::constraints/examples.adoc#administration-constraints-listing-all-constraints[] -* xref::constraints/examples.adoc#administration-constraints-listing-constraints-with-filtering[] +* xref::constraints/examples.adoc#constraints-listing-all-constraints[] +* xref::constraints/examples.adoc#constraints-listing-constraints-with-filtering[] [discrete] -[[administration-constraints-listing-all-constraints]] +[[constraints-listing-all-constraints]] === Listing all constraints To list all constraints with the default output columns, the `SHOW CONSTRAINTS` command can be used. @@ -1829,7 +1830,7 @@ If all columns are required, use `SHOW CONSTRAINTS YIELD *`. [NOTE] ==== One of the output columns from `SHOW CONSTRAINTS` is the name of the constraint. -This can be used to drop the constraint with the xref::constraints/syntax.adoc#administration-constraints-syntax-drop[`DROP CONSTRAINT` command]. +This can be used to drop the constraint with the xref::constraints/syntax.adoc#constraints-syntax-drop[`DROP CONSTRAINT` command]. ==== @@ -1868,11 +1869,11 @@ The `type` for node uniqueness constraint will be updated to `NODE_UNIQUENESS` i [discrete] -[[administration-constraints-listing-constraints-with-filtering]] +[[constraints-listing-constraints-with-filtering]] === Listing constraints with filtering One way of filtering the output from `SHOW CONSTRAINTS` by constraint type is the use of type keywords, -listed in the xref::constraints/syntax.adoc#administration-constraints-syntax-list-type-filter[syntax for listing constraints type filter table]. +listed in the xref::constraints/syntax.adoc#constraints-syntax-list-type-filter[syntax for listing constraints type filter table]. For example, to show only uniqueness constraints, use `SHOW UNIQUENESS CONSTRAINTS`. Another more flexible way of filtering the output is to use the `WHERE` clause. An example is to only show constraints on relationships. diff --git a/modules/ROOT/pages/constraints/index.adoc b/modules/ROOT/pages/constraints/index.adoc index 4dff78b1a..c2012cad2 100644 --- a/modules/ROOT/pages/constraints/index.adoc +++ b/modules/ROOT/pages/constraints/index.adoc @@ -1,6 +1,6 @@ :description: This section explains how to manage constraints used for ensuring data integrity. -[[administration-constraints]] +[[constraints]] = Constraints [abstract] diff --git a/modules/ROOT/pages/constraints/syntax.adoc b/modules/ROOT/pages/constraints/syntax.adoc index 90671ffc6..6c4c21197 100644 --- a/modules/ROOT/pages/constraints/syntax.adoc +++ b/modules/ROOT/pages/constraints/syntax.adoc @@ -1,6 +1,6 @@ :description: Syntax for how to manage constraints used for ensuring data integrity. -[[administration-constraints-syntax]] +[[constraints-syntax]] = Syntax :check-mark: icon:check[] @@ -9,7 +9,7 @@ The syntax descriptions use xref:access-control/index.adoc#access-control-syntax[the style] from access control. ==== -[[administration-constraints-syntax-create]] +[[constraints-syntax-create]] == Syntax for creating constraints Best practice when creating a constraint is to give the constraint a name. @@ -30,7 +30,7 @@ There is no supported index configuration for range indexes. Creating a constraint requires the xref::access-control/database-administration.adoc#access-control-database-administration-constraints[`CREATE CONSTRAINT` privilege]. ==== -[[administration-constraints-syntax-create-node-unique]] +[[constraints-syntax-create-node-unique]] [discrete] === Create a node uniqueness constraint @@ -55,7 +55,7 @@ REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] UNIQUE Index provider can be specified using the `OPTIONS` clause. -[[administration-constraints-syntax-create-rel-unique]] +[[constraints-syntax-create-rel-unique]] [discrete] === Create a relationship uniqueness constraint @@ -80,7 +80,7 @@ REQUIRE (r.propertyName_1, ..., r.propertyName_n) IS [REL[ATIONSHIP]] UNIQUE Index provider can be specified using the `OPTIONS` clause. -[[administration-constraints-syntax-create-node-exists]] +[[constraints-syntax-create-node-exists]] [discrete] === Create a node property existence constraint label:enterprise-edition[] @@ -100,7 +100,7 @@ There are no supported `OPTIONS` values for existence constraints, but an empty ==== -[[administration-constraints-syntax-create-rel-exists]] +[[constraints-syntax-create-rel-exists]] [discrete] === Create a relationship property existence constraint label:enterprise-edition[] @@ -120,7 +120,7 @@ There are no supported `OPTIONS` values for existence constraints, but an empty ==== -[[administration-constraints-syntax-create-node-key]] +[[constraints-syntax-create-node-key]] [discrete] === Create a node key constraint label:enterprise-edition[] @@ -145,7 +145,7 @@ REQUIRE (n.propertyName_1, ..., n.propertyName_n) IS [NODE] KEY Index provider can be specified using the `OPTIONS` clause. -[[administration-constraints-syntax-create-rel-key]] +[[constraints-syntax-create-rel-key]] [discrete] === Create a relationship key constraint label:enterprise-edition[] @@ -170,7 +170,7 @@ REQUIRE (r.propertyName_1, ..., r.propertyName_n) IS [REL[ATIONSHIP]] KEY Index provider can be specified using the `OPTIONS` clause. -[[administration-constraints-syntax-drop]] +[[constraints-syntax-drop]] == Syntax for dropping constraints Dropping a constraint is done by specifying the name of the constraint. @@ -189,7 +189,7 @@ Dropping a constraint requires the xref::access-control/database-administration. ==== -[[administration-constraints-syntax-list]] +[[constraints-syntax-list]] == Syntax for listing constraints List constraints in the database, either all or filtered on constraint type. @@ -242,7 +242,7 @@ YIELD { * | field[, ...] } [ORDER BY field[, ...]] [SKIP n] [LIMIT n] The type filtering keywords filters the returned constraints on constraint type: -[[administration-constraints-syntax-list-type-filter]] +[[constraints-syntax-list-type-filter]] .Type filters [options="header", width="100%", cols="4m,6a"] |=== diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index dbd54b691..e91f8879a 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -3259,7 +3259,7 @@ label:new[] DROP CONSTRAINT name ---- a| -xref:constraints/syntax.adoc#administration-constraints-syntax-drop[New command] for dropping a constraint by name, no matter the type. +xref:constraints/syntax.adoc#constraints-syntax-drop[New command] for dropping a constraint by name, no matter the type. a| @@ -3371,7 +3371,7 @@ An example of this is `CALL db.index.explicit.searchNodes('my_index','email:me*' | `MATCH (n)-[x:A\|:B\|:C*]-() RETURN n` | Syntax | Deprecated | Replaced by `MATCH (n)-[x:A\|B\|C*]-() RETURN n` | link:/docs/java-reference/5/extending-neo4j/aggregation-functions#extending-neo4j-aggregation-functions[User-defined aggregation functions] | Functionality | Added | | xref:indexes-for-search-performance.adoc[Composite indexes] | Index | Added | -| xref:constraints/examples.adoc#administration-constraints-node-key[Node Key] | Index | Added | Neo4j Enterprise Edition only +| xref:constraints/examples.adoc#constraints-examples-node-key[Node Key] | Index | Added | Neo4j Enterprise Edition only | `CYPHER runtime=compiled` (Compiled runtime) | Functionality | Added | Neo4j Enterprise Edition only | xref:functions/list.adoc#functions-reverse-list[reverse()] | Function | Extended | Now also allows a list as input | xref:functions/aggregating.adoc#functions-max[max()], xref:functions/aggregating.adoc#functions-min[min()] | Function | Extended | Now also supports aggregation over a set containing both strings and numbers diff --git a/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc b/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc index 9cbf5fd18..2ebe1f7ec 100644 --- a/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc +++ b/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc @@ -75,9 +75,9 @@ All users have full access rights. | Constraints a| -xref::constraints/examples.adoc#administration-constraints-prop-exist-nodes[Existence constraints], xref::constraints/examples.adoc#administration-constraints-unique-nodes[uniqueness constraints], and xref::constraints/examples.adoc#administration-constraints-node-key[`NODE KEY` constraints]. +xref::constraints/examples.adoc#constraints-examples-node-property-existence[Existence constraints], xref::constraints/examples.adoc#constraints-examples-node-uniqueness[uniqueness constraints], and xref::constraints/examples.adoc#constraints-examples-node-key[`NODE KEY` constraints]. a| -Only xref::constraints/examples.adoc#administration-constraints-unique-nodes[uniqueness constraints]. +Only xref::constraints/examples.adoc#constraints-examples-node-uniqueness[uniqueness constraints]. |=== diff --git a/modules/ROOT/pages/keyword-glossary.adoc b/modules/ROOT/pages/keyword-glossary.adoc index 242062a0c..238a96168 100644 --- a/modules/ROOT/pages/keyword-glossary.adoc +++ b/modules/ROOT/pages/keyword-glossary.adoc @@ -42,27 +42,27 @@ Typically used when modifying or importing large amounts of data. | Writing | Create nodes and relationships. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-node-exists[CREATE CONSTRAINT [existence\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE n.property IS NOT NULL [OPTIONS {}\]] +| xref::constraints/syntax.adoc#constraints-syntax-create-node-exists[CREATE CONSTRAINT [existence\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE n.property IS NOT NULL [OPTIONS {}\]] | Schema | Create a constraint ensuring that all nodes with a particular label have a certain property. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-rel-exists[CREATE CONSTRAINT [existence\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE r.property IS NOT NULL [OPTIONS {}\]] +| xref::constraints/syntax.adoc#constraints-syntax-create-rel-exists[CREATE CONSTRAINT [existence\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE r.property IS NOT NULL [OPTIONS {}\]] | Schema | Create a constraint that ensures all relationships with a particular type have a certain property. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-node-key[CREATE CONSTRAINT [node_key\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS [NODE\] KEY [OPTIONS {optionKey: optionValue[, ...\]}\]] +| xref::constraints/syntax.adoc#constraints-syntax-create-node-key[CREATE CONSTRAINT [node_key\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS [NODE\] KEY [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema | Create a constraint that ensures all nodes with a particular label have all the specified properties and that the combination of property values is unique; i.e. ensures existence and uniqueness. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-rel-key[CREATE CONSTRAINT [rel_key\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE (r.prop1[, ..., r.propN\]) IS [REL[ATIONSHIP\]\] KEY [OPTIONS {optionKey: optionValue[, ...\]}\]] +| xref::constraints/syntax.adoc#constraints-syntax-create-rel-key[CREATE CONSTRAINT [rel_key\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE (r.prop1[, ..., r.propN\]) IS [REL[ATIONSHIP\]\] KEY [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema | Create a constraint that ensures all relationships with a particular type have all the specified properties and that the combination of property values is unique; i.e. ensures existence and uniqueness. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-node-unique[CREATE CONSTRAINT [uniqueness\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS [NODE\] UNIQUE [OPTIONS {optionKey: optionValue[, ...\]}\]] +| xref::constraints/syntax.adoc#constraints-syntax-create-node-unique[CREATE CONSTRAINT [uniqueness\] [IF NOT EXISTS\] FOR (n:Label) REQUIRE (n.prop1[, ..., n.propN\]) IS [NODE\] UNIQUE [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema | Create a constraint that ensures the uniqueness of the combination of node label and property values for a particular property key combination across all nodes. -| xref::constraints/syntax.adoc#administration-constraints-syntax-create-rel-unique[CREATE CONSTRAINT [uniqueness\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE (r.prop1[, ..., r.propN\]) IS [REL[ATIONSHIP\]\] UNIQUE [OPTIONS {optionKey: optionValue[, ...\]}\]] +| xref::constraints/syntax.adoc#constraints-syntax-create-rel-unique[CREATE CONSTRAINT [uniqueness\] [IF NOT EXISTS\] FOR ()-"["r:REL_TYPE"\]"-() REQUIRE (r.prop1[, ..., r.propN\]) IS [REL[ATIONSHIP\]\] UNIQUE [OPTIONS {optionKey: optionValue[, ...\]}\]] | Schema | Create a constraint that ensures the uniqueness of the combination of relationship type and property values for a particular property key combination across all relationships. @@ -176,7 +176,7 @@ Either the pattern already exists, or it needs to be created. | Writing | Update labels on nodes and properties on nodes and relationships. -| xref::constraints/syntax.adoc#administration-constraints-syntax-list[SHOW [ALL\|UNIQUE\|NODE [PROPERTY\] EXIST[ENCE\]\|REL[ATIONSHIP\] [PROPERTY\] EXIST[ENCE\]\|[PROPERTY\] EXIST[ENCE\]\|NODE KEY\] CONSTRAINT[S\]] +| xref::constraints/syntax.adoc#constraints-syntax-list[SHOW [ALL\|UNIQUE\|NODE [PROPERTY\] EXIST[ENCE\]\|REL[ATIONSHIP\] [PROPERTY\] EXIST[ENCE\]\|[PROPERTY\] EXIST[ENCE\]\|NODE KEY\] CONSTRAINT[S\]] | Schema | List constraints in the database, either all or filtered on type. From 1217cb91b9f32a0bae9fe9617e17acd89036a6cc Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Fri, 25 Nov 2022 11:25:22 +0100 Subject: [PATCH 06/12] More review comment fixes and things I noticed missing (or fixes wrongly) --- modules/ROOT/pages/constraints/examples.adoc | 50 +++++++------------ ...ions-additions-removals-compatibility.adoc | 7 ++- .../introduction/neo4j-databases-graphs.adoc | 10 +++- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index a853b6d5e..1992ec760 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -12,6 +12,8 @@ Examples of how to manage constraints used for ensuring data integrity. [[constraints-examples-node-uniqueness]] == Node uniqueness constraints +A node uniqueness constraint ensures that all nodes with a particular label have a set of defined properties whose combined value is unique when existing. + * xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint[] * xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint-if-not-exist[] * xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint-with-index-provider[] @@ -27,7 +29,6 @@ Examples of how to manage constraints used for ensuring data integrity. === Create a node uniqueness constraint When creating a uniqueness constraint, a name can be provided. -The constraint ensures that your database will never contain more than one node with the specified label and property value. .+CREATE CONSTRAINT+ @@ -62,13 +63,7 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown if any other constraint with the given name or another node uniqueness constraint on the same schema already existed. -The uniqueness constraint ensures that your database will never contain more than one node with the specified label and property value. - -[NOTE] -==== -No constraint will be created if any other constraint with the given name or another node uniqueness constraint on the same schema already exists. -==== +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node uniqueness constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -324,6 +319,8 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. [[constraints-examples-relationship-uniqueness]] == Relationship uniqueness constraints +A relationship uniqueness constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique when existing. + * xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints[] * xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints-if-not-exist[] * xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints-with-index-provider[] @@ -339,7 +336,6 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. === Create a relationship uniqueness constraint When creating a uniqueness constraint, a name can be provided. -The uniqueness constraint ensures that your database will never contain more than one relationship with the specified relationship type and property value. .+CREATE CONSTRAINT+ @@ -369,13 +365,7 @@ Relationship uniqueness constraints added: 1 === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown if any other constraint with the given name or another relationship uniqueness constraint on the same schema already existed. -The uniqueness constraint ensures that your database will never contain more than one relationship with the specified relationship type and property value. - -[NOTE] -==== -No constraint will be created if any other constraint with the given name or another relationship uniqueness constraint on the same schema already exists. -==== +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship uniqueness constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -614,6 +604,8 @@ Both Relationship(0) and Relationship(1) have the type `FRIENDS_WITH` and proper [[constraints-examples-node-property-existence]] == Node property existence constraints +A node property existence constraint ensures that all nodes with a certain label have a certain property. + * xref::constraints/examples.adoc#constraints-create-a-node-property-existence-constraint[] * xref::constraints/examples.adoc#constraints-create-a-node-property-existence-constraint-if-not-exist[] * xref::constraints/examples.adoc#constraints-create-an-already-existing-node-property-existence-constraint[] @@ -628,7 +620,6 @@ Both Relationship(0) and Relationship(1) have the type `FRIENDS_WITH` and proper === Create a node property existence constraint When creating a node property existence constraint, a name can be provided. -The constraint ensures that all nodes with a certain label have a certain property. .+CREATE CONSTRAINT+ @@ -664,9 +655,7 @@ For the node property existence constraints they will say `Node property existen === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown if any other constraint with the given name or another node property existence constraint on the same schema already existed. -The node property existence constraint ensures that all nodes with a certain label have a certain property. -No constraint will be created if any other constraint with the given name or another node property existence constraint on the same schema already exists. +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node property existence constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -863,6 +852,8 @@ Node(0) with label `Book` must have the property `isbn` [[constraints-examples-relationship-property-existence]] == Relationship property existence constraints +A relationship property existence constraint ensures all relationships with a certain type have a certain property. + * xref::constraints/examples.adoc#constraints-create-a-relationship-property-existence-constraint[] * xref::constraints/examples.adoc#constraints-create-a-relationship-property-existence-constraint-if-not-exist[] * xref::constraints/examples.adoc#constraints-create-an-already-existing-relationship-property-existence-constraint[] @@ -877,7 +868,6 @@ Node(0) with label `Book` must have the property `isbn` === Create a relationship property existence constraint When creating a relationship property existence constraint, a name can be provided. -The constraint ensures all relationships with a certain type have a certain property. .+CREATE CONSTRAINT+ @@ -913,9 +903,7 @@ For the relationship property existence constraints they will say `Relationship === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown if any other constraint with the given name or another relationship property existence constraint on the same schema already existed. -The relationship property existence constraint ensures all relationships with a certain type have a certain property. -No constraint will be created if any other constraint with the given name or another relationship property existence constraint on the same schema already exists. +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship property existence constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -1111,6 +1099,8 @@ Relationship(0) with type `LIKED` must have the property `day` [[constraints-examples-node-key]] == Node key constraints +A node key constraint ensures that all nodes with a particular label have a set of defined properties whose combined value is unique and all properties in the set are present. + * xref::constraints/examples.adoc#constraints-create-a-node-key-constraint[] * xref::constraints/examples.adoc#constraints-create-a-node-key-constraint-if-not-exist[] * xref::constraints/examples.adoc#constraints-create-a-node-key-constraint-with-index-provider[] @@ -1127,7 +1117,6 @@ Relationship(0) with type `LIKED` must have the property `day` === Create a node key constraint When creating a node key constraint, a name can be provided. -The constraint ensures that all nodes with a particular label have a set of defined properties whose combined value is unique and all properties in the set are present. .+CREATE CONSTRAINT+ @@ -1157,9 +1146,7 @@ Node key constraints added: 1 === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown if any other constraint with the given name or another node key constraint on the same schema already existed. -The node key constraint ensures that all nodes with a particular label have a set of defined properties whose combined value is unique and all properties in the set are present. -No constraint will be created if any other constraint with the given name or another node key constraint on the same schema already exists. +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node key constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -1427,6 +1414,8 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) [[constraints-examples-relationship-key]] == Relationship key constraints +A relationship key constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique and all properties in the set are present. + * xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint[] * xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint-if-not-exist[] * xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint-with-index-provider[] @@ -1443,7 +1432,6 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) === Create a relationship key constraint When creating a relationship key constraint, a name can be provided. -The constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique and all properties in the set are present. .+CREATE CONSTRAINT+ @@ -1473,9 +1461,7 @@ Relationship key constraints added: 1 === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown if any other constraint with the given name or another relationship key constraint on the same schema already existed. -The relationship key constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique and all properties in the set are present. -No constraint will be created if any other constraint with the given name or another relationship key constraint on the same schema already exists. +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship key constraint on the same schema already existed. .+CREATE CONSTRAINT+ diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index e91f8879a..ae75b7238 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -103,11 +103,12 @@ label:new[] [source, cypher, role="noheader"] ---- CREATE CONSTRAINT name FOR ()-[r:TYPE]-() REQUIRE r.prop IS UNIQUE + CREATE CONSTRAINT name FOR ()-[r:TYPE]-() REQUIRE r.prop IS RELATIONSHIP KEY ---- a| -Added relationship key and uniqueness constraints. +Added relationship xref:constraints/syntax.adoc#constraints-syntax-create-rel-key[key] and xref:constraints/syntax.adoc#constraints-syntax-create-rel-unique[uniqueness] constraints. a| label:functionality[] @@ -115,9 +116,13 @@ label:new[] [source, cypher, role="noheader"] ---- SHOW NODE UNIQUE[NESS] CONSTRAINTS + SHOW REL[ATIONSHIP] UNIQUE[NESS] CONSTRAINTS + SHOW UNIQUE[NESS] CONSTRAINTS + SHOW REL[ATIONSHIP] KEY CONSTRAINTS + SHOW KEY CONSTRAINTS ---- a| diff --git a/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc b/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc index 2ebe1f7ec..280be9dbb 100644 --- a/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc +++ b/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc @@ -75,9 +75,15 @@ All users have full access rights. | Constraints a| -xref::constraints/examples.adoc#constraints-examples-node-property-existence[Existence constraints], xref::constraints/examples.adoc#constraints-examples-node-uniqueness[uniqueness constraints], and xref::constraints/examples.adoc#constraints-examples-node-key[`NODE KEY` constraints]. +All constraints: +xref::constraints/examples.adoc#constraints-examples-node-property-existence[node existence constraints], +xref::constraints/examples.adoc#constraints-examples-relationship-property-existence[relationship existence constraints], +xref::constraints/examples.adoc#constraints-examples-node-uniqueness[node uniqueness constraints], +xref::constraints/examples.adoc#constraints-examples-relationship-uniqueness[relationship uniqueness constraints], +xref::constraints/examples.adoc#constraints-examples-node-key[node key constraints], and +xref::constraints/examples.adoc#constraints-examples-relationship-key[relationship key constraints]. a| -Only xref::constraints/examples.adoc#constraints-examples-node-uniqueness[uniqueness constraints]. +Only xref::constraints/examples.adoc#constraints-examples-node-uniqueness[node] and xref::constraints/examples.adoc#constraints-examples-relationship-uniqueness[relationship] uniqueness constraints. |=== From ecf2d05815999de4abd1bf8a19a1259e77a047fb Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Fri, 25 Nov 2022 11:40:43 +0100 Subject: [PATCH 07/12] Explain set-up comments --- modules/ROOT/pages/constraints/examples.adoc | 39 +++++++++++++++++++ .../pages/indexes-for-search-performance.adoc | 20 ++++++++++ 2 files changed, 59 insertions(+) diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index 1992ec760..f437fda7e 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -153,6 +153,7 @@ There is no valid index configuration values for the constraint-backing range in Create a uniqueness constraint on the property `title` on nodes with the `Book` label, when that constraint already exists. //// +Set-up to get expected behavior: CREATE CONSTRAINT preExistingUnique FOR (book:Book) REQUIRE book.title IS UNIQUE //// @@ -190,6 +191,7 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. Create a uniqueness constraint on the property `wordCount` on nodes with the `Book` label, when an index already exists on that label and property combination. //// +Set-up to get expected behavior: CREATE INDEX FOR (book:Book) ON (book.wordCount) //// @@ -222,6 +224,7 @@ A constraint cannot be created until the index has been dropped. Create a `Book` node with an `isbn` that is not already in the database. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE //// @@ -256,6 +259,7 @@ Labels added: 1 Create a `Book` node with an `isbn` that is already used in the database. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE CREATE (book:Book {isbn: '1449356265', title: 'Graph Databases'}) //// @@ -288,6 +292,7 @@ Node(0) already exists with label `Book` and property `isbn` = '1449356265' Create a uniqueness constraint on the property `isbn` on nodes with the `Book` label when there are two nodes with the same `isbn`. //// +Set-up to get expected behavior: CREATE (book:Book {isbn: '1449356265', title: 'Graph Databases'}) CREATE (book:Book {isbn: '1449356265', title: 'Graph Databases'}) //// @@ -445,6 +450,7 @@ There is no valid index configuration values for the constraint-backing range in Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when that constraint already exists. //// +Set-up to get expected behavior: CREATE CONSTRAINT preExistingUnique FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE //// @@ -477,6 +483,7 @@ Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', sche Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when an index already exists on that relationship type and property combination. //// +Set-up to get expected behavior: CREATE INDEX FOR ()-[friend:FRIENDS_WITH]-() ON (friend.nickname) //// @@ -509,6 +516,7 @@ A constraint cannot be created until the index has been dropped. Create a `FRIENDS_WITH` relationship with an `nickname` that is not already in the database. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE //// @@ -544,6 +552,7 @@ Labels added: 2 Create a `FRIENDS_WITH` relationship with an `nickname` that is already used in the database. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE CREATE (:Person {name: 'Emma'}), (:Person {name: 'Josefin'})-[:FRIENDS_WITH {nickname: 'Mimi'}]->(:Person {name: 'Emilia'}) //// @@ -577,6 +586,7 @@ Relationship(0) already exists with type `FRIENDS_WITH` and property `nickname` Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type when there are two relationships with the same `nickname`. //// +Set-up to get expected behavior: CREATE (emma:Person {name: 'Emma'}), (josefin:Person {name: 'Josefin'}), (emilia:Person {name: 'Emilia'}) CREATE (josefin)-[:FRIENDS_WITH {nickname: 'Mimi'}]->(emilia), (emma)-[:FRIENDS_WITH {nickname: 'Mimi'}]->(emilia) //// @@ -662,6 +672,7 @@ This will ensure no error is thrown and no constraint created if any other const ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT constraint_name FOR (book:Book) REQUIRE book.isbn IS UNIQUE //// @@ -696,6 +707,7 @@ Assuming a constraint with the name `constraint_name` already existed: Create a node property existence constraint on the property `title` on nodes with the `Book` label, when that constraint already exists. //// +Set-up to get expected behavior: CREATE CONSTRAINT preExistingNodePropExist FOR (book:Book) REQUIRE book.title IS NOT NULL //// @@ -729,6 +741,7 @@ Constraint( id=3, name='preExistingNodePropExist', type='NODE PROPERTY EXISTENCE Create a `Book` node with an `isbn` property. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS NOT NULL //// @@ -763,6 +776,7 @@ Labels added: 1 Trying to create a `Book` node without an `isbn` property, given a property existence constraint on `:Book(isbn)`. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS NOT NULL //// @@ -794,6 +808,7 @@ Node(0) with label `Book` must have the property `isbn` Trying to remove the `isbn` property from an existing node `book`, given a property existence constraint on `:Book(isbn)`. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS NOT NULL CREATE (book:Book {isbn: '1449356265', title: 'Graph Databases'}) //// @@ -827,6 +842,7 @@ Node(0) with label `Book` must have the property `isbn` Create a constraint on the property `isbn` on nodes with the `Book` label when there already exists a node without an `isbn`. //// +Set-up to get expected behavior: CREATE (book:Book {title: 'Graph Databases'}) //// @@ -910,6 +926,7 @@ This will ensure no error is thrown and no constraint created if any other const ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT constraint_name FOR (book:Book) REQUIRE book.isbn IS NOT NULL //// @@ -944,6 +961,7 @@ Assuming a constraint with the name `constraint_name` already existed: Create a named relationship property existence constraint on the property `week` on relationships with the `LIKED` type, when a constraint with the given name already exists. //// +Set-up to get expected behavior: CREATE CONSTRAINT relPropExist FOR ()-[like:LIKED]-() REQUIRE like.since IS NOT NULL //// @@ -976,6 +994,7 @@ There already exists a constraint called 'relPropExist'. Create a `LIKED` relationship with a `day` property. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[like:LIKED]-() REQUIRE like.day IS NOT NULL //// @@ -1011,6 +1030,7 @@ Labels added: 2 Trying to create a `LIKED` relationship without a `day` property, given a property existence constraint `:LIKED(day)`. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[like:LIKED]-() REQUIRE like.day IS NOT NULL //// @@ -1042,6 +1062,7 @@ Relationship(0) with type `LIKED` must have the property `day` Trying to remove the `day` property from an existing relationship `like` of type `LIKED`, given a property existence constraint `:LIKED(day)`. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[like:LIKED]-() REQUIRE like.day IS NOT NULL CREATE (user:User)-[like:LIKED {day: 'yesterday'}]->(book:Book) //// @@ -1074,6 +1095,7 @@ Relationship(0) with type `LIKED` must have the property `day` Create a constraint on the property `day` on relationships with the `LIKED` type when there already exists a relationship without a property named `day`. //// +Set-up to get expected behavior: CREATE (user:User)-[like:LIKED]->(book:Book) //// @@ -1153,6 +1175,7 @@ This will ensure no error is thrown and no constraint created if any other const ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (n:Person) REQUIRE (n.firstname, n.surname) IS NODE KEY //// @@ -1227,6 +1250,7 @@ There is no valid index configuration values for the constraint-backing range in Create a node key constraint on the properties `firstname` and `age` on nodes with the `Person` label, when a uniqueness constraint already exists on the same label and property combination. //// +Set-up to get expected behavior: CREATE CONSTRAINT preExistingUnique FOR (p:Person) REQUIRE (p.firstname, p.age) IS UNIQUE //// @@ -1259,6 +1283,7 @@ Constraint( id=4, name='preExistingUnique', type='UNIQUENESS', schema=(:Person { Create a named node key constraint on the property `title` on nodes with the `Book` label, when an index already exists with the given name. //// +Set-up to get expected behavior: CREATE INDEX bookTitle FOR (book:ComicBook) ON (book.title) //// @@ -1291,6 +1316,7 @@ There already exists an index called 'bookTitle'. Create a `Person` node with both a `firstname` and `surname` property. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (n:Person) REQUIRE (n.firstname, n.surname) IS NODE KEY //// @@ -1325,6 +1351,7 @@ Labels added: 1 Trying to create a `Person` node without a `surname` property, given a node key constraint on `:Person(firstname, surname)`, will fail. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (n:Person) REQUIRE (n.firstname, n.surname) IS NODE KEY //// @@ -1356,6 +1383,7 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) Trying to remove the `surname` property from an existing node `Person`, given a `NODE KEY` constraint on `:Person(firstname, surname)`. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (n:Person) REQUIRE (n.firstname, n.surname) IS NODE KEY CREATE (p:Person {firstname: 'John', surname: 'Wood', age: 55}) //// @@ -1388,6 +1416,7 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) Trying to create a node key constraint on the property `surname` on nodes with the `Person` label will fail when a node without a `surname` already exists in the database. //// +Set-up to get expected behavior: CREATE (p:Person {firstname: 'John', age: 55}) //// @@ -1468,6 +1497,7 @@ This will ensure no error is thrown and no constraint created if any other const ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS RELATIONSHIP KEY //// @@ -1542,6 +1572,7 @@ There is no valid index configuration values for the constraint-backing range in Create a relationship key constraint on the properties `startPoint` and `endPoint` on relationships with the `ROAD` relationship type, when a uniqueness constraint already exists on the same relationship type and property combination. //// +Set-up to get expected behavior: CREATE CONSTRAINT preExistingUnique FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS UNIQUE //// @@ -1574,6 +1605,7 @@ Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', sche Create a named relationship key constraint on the property `coordinates` on relationships with the `INTERSECTION` relationship type, when an index already exists with the given name. //// +Set-up to get expected behavior: CREATE INDEX intersections FOR ()-[intersect:Roundabout]-() ON (intersect.coordinates) //// @@ -1606,6 +1638,7 @@ There already exists an index called 'intersections'. Create a `ROAD` relationship with both a `startPoint` and `endPoint` property. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS REL KEY CREATE (:Intersection {name: 'a', coordinates: point({x: 1, y:2})}), (:Intersection {name: 'b', coordinates: point({x: 2, y:5})}) //// @@ -1641,6 +1674,7 @@ Properties set: 2 Trying to create a `INTERSECTION` relationship without a `coordinates` property, given a relationship key constraint on `:INTERSECTION(coordinates)`, will fail. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY CREATE (:Road {name: 'a'}), (:Road {name: 'b'}) //// @@ -1674,6 +1708,7 @@ Relationship(0) with type `INTERSECTION` must have the property `coordinates` Trying to remove the `endPoint` property from an existing relationship `ROAD`, given a `RELATIONSHIP KEY` constraint on `:ROAD(startPoint, endPoint)`. //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS REL KEY CREATE (a:Intersection {name: 'a', coordinates: point({x: 1, y:2})}), (b:Intersection {name: 'b', coordinates: point({x: 2, y:5})}) CREATE (a)-[:ROAD {startPoint: a.coordinates, endPoint: b.coordinates}]->(b) @@ -1707,6 +1742,7 @@ Relationship(0) with type `ROAD` must have the properties (`startPoint`, `endPoi Trying to create a relationship key constraint on the property `coordinates` on relationships with the `INTERSECTION` relationship type will fail when two relationships with identical `coordinates` already exists in the database. //// +Set-up to get expected behavior: CREATE (a:Road {name: 'a'}), (b:Road {name: 'b'}) CREATE (a)-[:INTERSECTION {coordinates: point({x:1, y:2})}]->(b) CREATE (a)<-[:INTERSECTION {coordinates: point({x:1, y:2})}]-(b) @@ -1751,6 +1787,7 @@ The name of the constraint can be found using the xref::constraints/syntax.adoc# ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT constraint_name FOR (n:Person) REQUIRE (n.name) IS NOT NULL //// @@ -1824,6 +1861,7 @@ This can be used to drop the constraint with the xref::constraints/syntax.adoc#c ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT isbnConstraint FOR (n:Book) REQUIRE (n.isbn) IS UNIQUE CREATE CONSTRAINT roadConstraint FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS UNIQUE //// @@ -1869,6 +1907,7 @@ An example is to only show constraints on relationships. ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (n:Book) REQUIRE (n.isbn) IS UNIQUE CREATE CONSTRAINT FOR (book:Book) REQUIRE book.title IS NOT NULL CREATE CONSTRAINT `constraint_f076a74d` FOR ()-[r:KNOWS]-() REQUIRE r.since IS NOT NULL diff --git a/modules/ROOT/pages/indexes-for-search-performance.adoc b/modules/ROOT/pages/indexes-for-search-performance.adoc index bea730a12..59a2511ff 100644 --- a/modules/ROOT/pages/indexes-for-search-performance.adoc +++ b/modules/ROOT/pages/indexes-for-search-performance.adoc @@ -441,6 +441,7 @@ Note that the index is not immediately available, but is created in the backgrou ====== //// +Set-up to get expected behavior: CREATE (_0:`Person` {`age`:35, `country`:"UK", `firstname`:"John", `highScore`:54321, `middlename`:"Ron", `name`:"john", `surname`:"Smith"}) CREATE (_1:`Person` {`age`:40, `country`:"Sweden", `firstname`:"Andy", `highScore`:12345, `middlename`:"Mark", `name`:"andy", `surname`:"Jones"}) //// @@ -486,6 +487,7 @@ Note that the index is not immediately available, but is created in the backgrou ====== //// +Set-up to get expected behavior: CREATE (_0:`Person` {`age`:35, `country`:"UK", `firstname`:"John", `highScore`:54321, `middlename`:"Ron", `name`:"john", `surname`:"Smith"}) CREATE (_1:`Person` {`age`:40, `country`:"Sweden", `firstname`:"Andy", `highScore`:12345, `middlename`:"Mark", `name`:"andy", `surname`:"Jones"}) CREATE (_0)-[:`KNOWS` {`lastMet`:2021, `lastMetIn`:"Stockholm", `metIn`:"Malmo", `since`:1992}]->(_1) @@ -525,6 +527,7 @@ If it is not known whether an index exists or not, add `IF NOT EXISTS` to ensure ====== //// +Set-up to get expected behavior: CREATE RANGE index `node_range_index_name` for (n:`Person`) ON (n.`surname`) CREATE (_0:`Person` {`age`:35, `country`:"UK", `firstname`:"John", `highScore`:54321, `middlename`:"Ron", `name`:"john", `surname`:"Smith"}) @@ -610,6 +613,7 @@ Note that the composite index is not immediately available, but is created in th The following statement will create a named composite range index on all nodes labeled with `Person` and which have both an `age` and `country` property: //// +Set-up to get expected behavior: CREATE (_0:`Person` {`age`:35, `country`:"UK", `firstname`:"John", `highScore`:54321, `middlename`:"Ron", `name`:"john", `surname`:"Smith"}) CREATE (_1:`Person` {`age`:40, `country`:"Sweden", `firstname`:"Andy", `highScore`:12345, `middlename`:"Mark", `name`:"andy", `surname`:"Jones"}) ---- @@ -659,6 +663,7 @@ Note that the composite index is not immediately available, but is created in th The following statement will create a named composite range index on all relationships labeled with `PURCHASED` and which have both a `date` and `amount` property: //// +Set-up to get expected behavior: CREATE (_0:`Person` {`age`:35, `country`:"UK", `firstname`:"John", `highScore`:54321, `middlename`:"Ron", `name`:"john", `surname`:"Smith"}) CREATE (_1:`Person` {`age`:40, `country`:"Sweden", `firstname`:"Andy", `highScore`:12345, `middlename`:"Mark", `name`:"andy", `surname`:"Jones"}) CREATE (_1)-[:`KNOWS`]->(_0) @@ -708,6 +713,7 @@ The index is not immediately available, but is created in the background. ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -760,6 +766,7 @@ The index is not immediately available, but is created in the background. ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -810,6 +817,7 @@ Only one valid value exists for the index provider, `token-lookup-1.0`, which is // hence the `node label lookup index` and `relationship type lookup index` variations above. //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -943,6 +951,7 @@ If it is not known whether an index exists or not, add `IF NOT EXISTS` to ensure ====== //// +Set-up to get expected behavior: CREATE POINT index for (n:`Person`) ON (n.`sublocation`) //// @@ -1124,6 +1133,7 @@ The index is not immediately available, but is created in the background. ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -1176,6 +1186,7 @@ The index is not immediately available, but is created in the background. ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -1220,6 +1231,7 @@ If it is not known whether an index exists or not, add `IF NOT EXISTS` to ensure ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -1260,6 +1272,7 @@ The valid values for the index provider are `text-2.0` and `text-1.0` (deprecate ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -1296,6 +1309,7 @@ Create an index on the property `title` on nodes with the `Book` label, when tha ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -1331,6 +1345,7 @@ Create a named index on the property `numberOfPages` on nodes with the `Book` la ====== //// +Set-up to get expected behavior: CREATE (n0:Label1:Label2 {prop1: 3, prop2: 'Green') CREATE (n1:Label1:Label3 {prop1: 5, prop2: 'Pink') CREATE (n2:Label1 {prop1: 7, prop2: 'Blue') @@ -1366,6 +1381,7 @@ Create an index on the property `isbn` on nodes with the `Book` label, when an i ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT FOR (book:Book) REQUIRE (book.isbn) IS UNIQUE //// @@ -1397,6 +1413,7 @@ Create a named index on the property `numberOfPages` on nodes with the `Book` la ====== //// +Set-up to get expected behavior: CREATE CONSTRAINT bookRecommendations FOR (book:Book) REQUIRE (book.recommend) IS NOT NULL //// @@ -1499,6 +1516,7 @@ If all columns are required, use `SHOW INDEXES YIELD *`. ====== //// +Set-up to get expected behavior: CREATE RANGE INDEX `index_664b28a2` for (n:`Person`) ON (n.`middlename`); CREATE RANGE INDEX `index_58a1c03e` for (n:`Person`) ON (n.`location`); CREATE RANGE INDEX `index_8a688dca` for (n:`Person`) ON (n.`highScore`); @@ -1561,6 +1579,7 @@ An example is to only show indexes not belonging to constraints. ====== //// +Set-up to get expected behavior: CREATE RANGE INDEX `index_664b28a2` for (n:`Person`) ON (n.`middlename`); CREATE RANGE INDEX `index_8a688dca` for (n:`Person`) ON (n.`highScore`); CREATE RANGE INDEX `index_b87724c3` for (n:`Person`) ON (n.`firstname`); @@ -1628,6 +1647,7 @@ The name of the index can be found using the xref::indexes-for-search-performanc ====== //// +Set-up to get expected behavior: CREATE index `index_example` for (n:`Example`) ON (n.`example`); //// From d43473aec7e6454a8f8910f99b8edcc45bb10edf Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Mon, 5 Dec 2022 16:57:22 +0100 Subject: [PATCH 08/12] Fix misspelling --- modules/ROOT/pages/constraints/examples.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index f437fda7e..ae64692d9 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -1751,7 +1751,7 @@ CREATE (a)<-[:INTERSECTION {coordinates: point({x:1, y:2})}]-(b) .Query [source, cypher, indent=0] ---- -CREATE CONSTRAINT intersectionConstriant FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY +CREATE CONSTRAINT intersectionConstraint FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY ---- In this case the relationship key constraint can not be created because it is violated by existing data. From 1ccb5b60647ad39d982f3cd2eaf3948e7ea70085 Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Tue, 6 Dec 2022 09:29:03 +0100 Subject: [PATCH 09/12] Fix duplicated 5.3 deprecations/additions/removals section after rebase --- ...ions-additions-removals-compatibility.adoc | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index ae75b7238..e632e7b0e 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -12,6 +12,29 @@ Replacement syntax for deprecated and removed features are also indicated. [[cypher-deprecations-additions-removals-5.3]] == Version 5.3 +=== Deprecated features + +[cols="2", options="header"] +|=== +| Feature +| Details + +a| +//not sure what category this should be, it is more information about a coming breaking change than actual deprecation +label:returnValues[] +label:deprecated[] +[source, cypher, role="noheader"] +---- +SHOW NODE UNIQUENESS CONSTRAINTS YIELD type +---- +a| + +Current constraint type for node uniqueness constraints, `UNIQUENESS`, will be updated to `NODE_UNIQUENESS` in 6.0. + +This will also be reflected in updates to some error messages and query statistics. + +|=== + === Updated features [cols="2", options="header"] @@ -64,32 +87,6 @@ A `COUNT` subquery now supports any non-writing query. For example, it now suppo |=== -[[cypher-deprecations-additions-removals-5.3]] -== Version 5.3 - -=== Deprecated features - -[cols="2", options="header"] -|=== -| Feature -| Details - -a| -//not sure what category this should be, it is more information about a coming breaking change than actual deprecation -label:returnValues[] -label:deprecated[] -[source, cypher, role="noheader"] ----- -SHOW NODE UNIQUENESS CONSTRAINTS YIELD type ----- -a| - -Current constraint type for node uniqueness constraints, `UNIQUENESS`, will be updated to `NODE_UNIQUENESS` in 6.0. - -This will also be reflected in updates to some error messages and query statistics. - -|=== - === New features [cols="2", options="header"] From 1a657753b3f13019a74d0ca90e7c66f4a7abefbe Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Tue, 6 Dec 2022 10:18:53 +0100 Subject: [PATCH 10/12] More misspelling fixes --- modules/ROOT/pages/constraints/examples.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index ae64692d9..6cc14f4e2 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -1760,7 +1760,7 @@ We may choose to remove the offending relationships and then re-apply the constr .Error message [source, "error message", role="noheader"] ---- -Unable to create Constraint( name='intersectionConstriant', type='RELATIONSHIP KEY', schema=()-[:INTERSECTION {coordinates}]-() ): +Unable to create Constraint( name='intersectionConstraint', type='RELATIONSHIP KEY', schema=()-[:INTERSECTION {coordinates}]-() ): Both Relationship(0) and Relationship(1) have the type `INTERSECTION` and property `coordinates` = {geometry: {type: "Point", coordinates: [1.0, 2.0], crs: {type: link, properties: {href: "http://spatialreference.org/ref/sr-org/7203/", code: 7203}}}} ---- From 462a64023c9d2bc527e3d24598076ea38ee48dbb Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Wed, 14 Dec 2022 09:15:29 +0100 Subject: [PATCH 11/12] Change constraint name to node/relationship property uniqueness constraints after discussion with Valerio and Emma --- modules/ROOT/pages/clauses/merge.adoc | 38 ++++++------- modules/ROOT/pages/constraints/examples.adoc | 54 +++++++++---------- modules/ROOT/pages/constraints/index.adoc | 18 +++---- modules/ROOT/pages/constraints/syntax.adoc | 14 ++--- ...ions-additions-removals-compatibility.adoc | 18 +++---- .../execution-plans/operator-summary.adoc | 4 +- .../ROOT/pages/execution-plans/operators.adoc | 14 ++--- modules/ROOT/pages/introduction/index.adoc | 2 +- .../introduction/neo4j-databases-graphs.adoc | 6 +-- 9 files changed, 84 insertions(+), 84 deletions(-) diff --git a/modules/ROOT/pages/clauses/merge.adoc b/modules/ROOT/pages/clauses/merge.adoc index ca88599c1..0ecdba3fa 100644 --- a/modules/ROOT/pages/clauses/merge.adoc +++ b/modules/ROOT/pages/clauses/merge.adoc @@ -26,11 +26,11 @@ Either the pattern already exists, or it needs to be created. ** xref::clauses/merge.adoc#merge-merge-on-an-undirected-relationship[Merge on an undirected relationship] ** xref::clauses/merge.adoc#merge-merge-on-a-relationship-between-two-existing-nodes[Merge on a relationship between two existing nodes] ** xref::clauses/merge.adoc#merge-merge-on-a-relationship-between-an-existing-node-and-a-merged-node-derived-from-a-node-property[Merge on a relationship between an existing node and a merged node derived from a node property] -* xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using uniqueness constraints with `MERGE`] -** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-creates-a-new-node-if-no-node-is-found[Merge using uniqueness constraints creates a new node if no node is found] -** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-matches-an-existing-node[Merge using uniqueness constraints matches an existing node] -** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-partial-matches[Merge with uniqueness constraints and partial matches] -** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-conflicting-matches[Merge with uniqueness constraints and conflicting matches] +* xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using property uniqueness constraints with `MERGE`] +** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-creates-a-new-node-if-no-node-is-found[Merge using property uniqueness constraints creates a new node if no node is found] +** xref::clauses/merge.adoc#merge-merge-using-unique-constraints-matches-an-existing-node[Merge using property uniqueness constraints matches an existing node] +** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-partial-matches[Merge with property uniqueness constraints and partial matches] +** xref::clauses/merge.adoc#merge-merge-with-unique-constraints-and-conflicting-matches[Merge with property uniqueness constraints and conflicting matches] * xref::clauses/merge.adoc#merge-using-map-parameters-with-merge[Using map parameters with `MERGE`] [[query-merge-introduction]] @@ -55,8 +55,8 @@ If partial matches are needed, this can be accomplished by splitting a pattern u [IMPORTANT] ==== Under concurrent updates, `MERGE` only guarantees existence of the `MERGE` pattern, but not uniqueness. -To guarantee uniqueness of nodes with certain properties, a xref::constraints/index.adoc[uniqueness constraint] should be used. -See xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using uniqueness constraints with `MERGE`] to see how `MERGE` can be used in combination with a uniqueness constraint. +To guarantee uniqueness of nodes with certain properties, a xref::constraints/index.adoc[property uniqueness constraint] should be used. +See xref::clauses/merge.adoc#query-merge-using-unique-constraints[Using property uniqueness constraints with `MERGE`] to see how `MERGE` can be used in combination with a property uniqueness constraint. ==== As with `MATCH`, `MERGE` can match multiple occurrences of a pattern. @@ -489,15 +489,15 @@ Labels added: 5 [[query-merge-using-unique-constraints]] -== Using uniqueness constraints with `MERGE` +== Using property uniqueness constraints with `MERGE` -Cypher prevents getting conflicting results from `MERGE` when using patterns that involve uniqueness constraints. +Cypher prevents getting conflicting results from `MERGE` when using patterns that involve property uniqueness constraints. In this case, there must be at most one node that matches that pattern. -For example, given two uniqueness constraints on `:Person(id)` and `:Person(ssn)`, a query such as `MERGE (n:Person {id: 12, ssn: 437})` will fail, if there are two different nodes (one with `id` 12 and one with `ssn` 437) or if there is only one node with only one of the properties. +For example, given two property uniqueness constraints on `:Person(id)` and `:Person(ssn)`, a query such as `MERGE (n:Person {id: 12, ssn: 437})` will fail, if there are two different nodes (one with `id` 12 and one with `ssn` 437) or if there is only one node with only one of the properties. In other words, there must be exactly one node that matches the pattern, or no matching nodes. -Note that the following examples assume the existence of uniqueness constraints that have been created using: +Note that the following examples assume the existence of property uniqueness constraints that have been created using: [source, cypher, indent=0] ---- @@ -507,9 +507,9 @@ CREATE CONSTRAINT FOR (n:Person) REQUIRE n.role IS UNIQUE; [[merge-merge-using-unique-constraints-creates-a-new-node-if-no-node-is-found]] -=== Merge using uniqueness constraints creates a new node if no node is found +=== Merge using property uniqueness constraints creates a new node if no node is found -Merge using uniqueness constraints creates a new node if no node is found. +Merge using property uniqueness constraints creates a new node if no node is found. .Query [source, cypher, indent=0] @@ -534,9 +534,9 @@ Labels added: 1 [[merge-merge-using-unique-constraints-matches-an-existing-node]] -=== Merge using uniqueness constraints matches an existing node +=== Merge using property uniqueness constraints matches an existing node -Merge using uniqueness constraints matches an existing node. +Merge using property uniqueness constraints matches an existing node. .Query [source, cypher, indent=0] @@ -557,9 +557,9 @@ The `'oliver'` node already exists, so `MERGE` just matches it. [[merge-merge-with-unique-constraints-and-partial-matches]] -=== Merge with uniqueness constraints and partial matches +=== Merge with property uniqueness constraints and partial matches -Merge using uniqueness constraints fails when finding partial matches. +Merge using property uniqueness constraints fails when finding partial matches. .Query [source, cypher, indent=0] @@ -588,9 +588,9 @@ SET michael.role = 'Gordon Gekko' [[merge-merge-with-unique-constraints-and-conflicting-matches]] -=== Merge with uniqueness constraints and conflicting matches +=== Merge with property uniqueness constraints and conflicting matches -Merge using uniqueness constraints fails when finding conflicting matches. +Merge using property uniqueness constraints fails when finding conflicting matches. .Query [source, cypher, indent=0] diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index 6cc14f4e2..b5718621e 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -10,9 +10,9 @@ Examples of how to manage constraints used for ensuring data integrity. [[constraints-examples-node-uniqueness]] -== Node uniqueness constraints +== Node property uniqueness constraints -A node uniqueness constraint ensures that all nodes with a particular label have a set of defined properties whose combined value is unique when existing. +A node property uniqueness constraint ensures that all nodes with a particular label have a set of defined properties whose combined value is unique when existing. * xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint[] * xref::constraints/examples.adoc#constraints-create-a-node-uniqueness-constraint-if-not-exist[] @@ -26,9 +26,9 @@ A node uniqueness constraint ensures that all nodes with a particular label have [discrete] [[constraints-create-a-node-uniqueness-constraint]] -=== Create a node uniqueness constraint +=== Create a node property uniqueness constraint -When creating a uniqueness constraint, a name can be provided. +When creating a property uniqueness constraint, a name can be provided. .+CREATE CONSTRAINT+ @@ -63,7 +63,7 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node uniqueness constraint on the same schema already existed. +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node property uniqueness constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -76,7 +76,7 @@ CREATE CONSTRAINT constraint_name IF NOT EXISTS FOR (book:Book) REQUIRE book.isbn IS UNIQUE ---- -Assuming no constraint with the given name or other node uniqueness constraint on the same schema exists: +Assuming no constraint with the given name or other node property uniqueness constraint on the same schema exists: .Result [queryresult] @@ -99,7 +99,7 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [[constraints-create-a-node-uniqueness-constraint-with-index-provider]] === Specifying an index provider when creating a constraint -To create a uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. +To create a property uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. The index type of the backing index is set with the `indexProvider` option. @@ -150,7 +150,7 @@ There is no valid index configuration values for the constraint-backing range in .+CREATE CONSTRAINT+ ====== -Create a uniqueness constraint on the property `title` on nodes with the `Book` label, when that constraint already exists. +Create a property uniqueness constraint on the property `title` on nodes with the `Book` label, when that constraint already exists. //// Set-up to get expected behavior: @@ -188,7 +188,7 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. .+CREATE CONSTRAINT+ ====== -Create a uniqueness constraint on the property `wordCount` on nodes with the `Book` label, when an index already exists on that label and property combination. +Create a property uniqueness constraint on the property `wordCount` on nodes with the `Book` label, when an index already exists on that label and property combination. //// Set-up to get expected behavior: @@ -289,7 +289,7 @@ Node(0) already exists with label `Book` and property `isbn` = '1449356265' .+CREATE CONSTRAINT+ ====== -Create a uniqueness constraint on the property `isbn` on nodes with the `Book` label when there are two nodes with the same `isbn`. +Create a property uniqueness constraint on the property `isbn` on nodes with the `Book` label when there are two nodes with the same `isbn`. //// Set-up to get expected behavior: @@ -322,9 +322,9 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. [[constraints-examples-relationship-uniqueness]] -== Relationship uniqueness constraints +== Relationship property uniqueness constraints -A relationship uniqueness constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique when existing. +A relationship property uniqueness constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique when existing. * xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints[] * xref::constraints/examples.adoc#constraints-create-a-relationship-uniqueness-constraints-if-not-exist[] @@ -338,9 +338,9 @@ A relationship uniqueness constraint ensures that all relationships with a parti [discrete] [[constraints-create-a-relationship-uniqueness-constraints]] -=== Create a relationship uniqueness constraint +=== Create a relationship property uniqueness constraint -When creating a uniqueness constraint, a name can be provided. +When creating a property uniqueness constraint, a name can be provided. .+CREATE CONSTRAINT+ @@ -370,7 +370,7 @@ Relationship uniqueness constraints added: 1 === Handling existing constraints when creating a constraint Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship uniqueness constraint on the same schema already existed. +This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship property uniqueness constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -383,7 +383,7 @@ CREATE CONSTRAINT constraint_name IF NOT EXISTS FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE ---- -Assuming no constraint with the given name or other relationship uniqueness constraint on the same schema exists: +Assuming no constraint with the given name or other relationship property uniqueness constraint on the same schema exists: .Result [queryresult] @@ -401,7 +401,7 @@ Relationship uniqueness constraints added: 1 [[constraints-create-a-relationship-uniqueness-constraints-with-index-provider]] === Specifying an index provider when creating a constraint -To create a uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. +To create a property uniqueness constraint with a specific index provider for the backing index, the `OPTIONS` clause is used. The index type of the backing index is set with the `indexProvider` option. @@ -447,7 +447,7 @@ There is no valid index configuration values for the constraint-backing range in .+CREATE CONSTRAINT+ ====== -Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when that constraint already exists. +Create a property uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when that constraint already exists. //// Set-up to get expected behavior: @@ -480,7 +480,7 @@ Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', sche .+CREATE CONSTRAINT+ ====== -Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when an index already exists on that relationship type and property combination. +Create a property uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type, when an index already exists on that relationship type and property combination. //// Set-up to get expected behavior: @@ -583,7 +583,7 @@ Relationship(0) already exists with type `FRIENDS_WITH` and property `nickname` .+CREATE CONSTRAINT+ ====== -Create a uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type when there are two relationships with the same `nickname`. +Create a property uniqueness constraint on the property `nickname` on relationships with the `FRIENDS_WITH` relationship type when there are two relationships with the same `nickname`. //// Set-up to get expected behavior: @@ -1241,13 +1241,13 @@ There is no valid index configuration values for the constraint-backing range in [discrete] [[constraints-node-key-and-uniqueness-constraint-on-the-same-schema]] -=== Node key and uniqueness constraints are not allowed on the same schema +=== Node key and property uniqueness constraints are not allowed on the same schema .+CREATE CONSTRAINT+ ====== -Create a node key constraint on the properties `firstname` and `age` on nodes with the `Person` label, when a uniqueness constraint already exists on the same label and property combination. +Create a node key constraint on the properties `firstname` and `age` on nodes with the `Person` label, when a property uniqueness constraint already exists on the same label and property combination. //// Set-up to get expected behavior: @@ -1563,13 +1563,13 @@ There is no valid index configuration values for the constraint-backing range in [discrete] [[constraints-relationship-key-and-uniqueness-constraint-on-the-same-schema]] -=== Relationship key and uniqueness constraints are not allowed on the same schema +=== Relationship key and property uniqueness constraints are not allowed on the same schema .+CREATE CONSTRAINT+ ====== -Create a relationship key constraint on the properties `startPoint` and `endPoint` on relationships with the `ROAD` relationship type, when a uniqueness constraint already exists on the same relationship type and property combination. +Create a relationship key constraint on the properties `startPoint` and `endPoint` on relationships with the `ROAD` relationship type, when a property uniqueness constraint already exists on the same relationship type and property combination. //// Set-up to get expected behavior: @@ -1885,8 +1885,8 @@ SHOW CONSTRAINTS [NOTE] ==== -The `type` column returns `UNIQUENESS` for the node uniqueness constraint and `RELATIONSHIP_UNIQUENESS` for the relationship uniqueness constraint. -The `type` for node uniqueness constraint will be updated to `NODE_UNIQUENESS` in 6.0. +The `type` column returns `UNIQUENESS` for the node property uniqueness constraint and `RELATIONSHIP_UNIQUENESS` for the relationship property uniqueness constraint. +The `type` for node property uniqueness constraint will be updated to `NODE_UNIQUENESS` in 6.0. ==== ====== @@ -1898,7 +1898,7 @@ The `type` for node uniqueness constraint will be updated to `NODE_UNIQUENESS` i One way of filtering the output from `SHOW CONSTRAINTS` by constraint type is the use of type keywords, listed in the xref::constraints/syntax.adoc#constraints-syntax-list-type-filter[syntax for listing constraints type filter table]. -For example, to show only uniqueness constraints, use `SHOW UNIQUENESS CONSTRAINTS`. +For example, to show only property uniqueness constraints, use `SHOW UNIQUENESS CONSTRAINTS`. Another more flexible way of filtering the output is to use the `WHERE` clause. An example is to only show constraints on relationships. diff --git a/modules/ROOT/pages/constraints/index.adoc b/modules/ROOT/pages/constraints/index.adoc index c2012cad2..639d15841 100644 --- a/modules/ROOT/pages/constraints/index.adoc +++ b/modules/ROOT/pages/constraints/index.adoc @@ -14,14 +14,14 @@ This section explains how to manage constraints used for ensuring data integrity The following constraint types are available: *Unique node property constraints*:: -Unique node property constraints, or node uniqueness constraints, ensure that property values are unique for all nodes with a specific label. -For uniqueness constraints on multiple properties, the combination of the property values is unique. -Node uniqueness constraints do not require all nodes to have a unique value for the properties listed -- nodes without all properties are not subject to this rule. +Unique node property constraints, or node property uniqueness constraints, ensure that property values are unique for all nodes with a specific label. +For property uniqueness constraints on multiple properties, the combination of the property values is unique. +Node property uniqueness constraints do not require all nodes to have a unique value for the properties listed -- nodes without all properties are not subject to this rule. *Unique relationship property constraints*:: -Unique relationship property constraints, or relationship uniqueness constraints, ensure that property values are unique for all relationships with a specific type. -For uniqueness constraints on multiple properties, the combination of the property values is unique. -Relationship uniqueness constraints do not require all relationships to have a unique value for the properties listed -- relationships without all properties are not subject to this rule. +Unique relationship property constraints, or relationship property uniqueness constraints, ensure that property values are unique for all relationships with a specific type. +For property uniqueness constraints on multiple properties, the combination of the property values is unique. +Relationship property uniqueness constraints do not require all relationships to have a unique value for the properties listed -- relationships without all properties are not subject to this rule. *Node property existence constraints* label:enterprise-edition[]:: Node property existence constraints ensure that a property exists for all nodes with a specific label. @@ -73,11 +73,11 @@ Databases containing one of these constraint types cannot be opened using Neo4j Creating a constraint has the following implications on indexes: -* Adding a node key, relationship key, or uniqueness constraint on a single property also adds an index on that property and therefore, an index of the same index type, label/relationship type, and property combination cannot be added separately. -* Adding a node key, relationship key, or uniqueness constraint for a set of properties also adds an index on those properties and therefore, an index of the same index type, label/relationship type, and properties combination cannot be added separately. +* Adding a node key, relationship key, or property uniqueness constraint on a single property also adds an index on that property and therefore, an index of the same index type, label/relationship type, and property combination cannot be added separately. +* Adding a node key, relationship key, or property uniqueness constraint for a set of properties also adds an index on those properties and therefore, an index of the same index type, label/relationship type, and properties combination cannot be added separately. * Cypher will use these indexes for lookups just like other indexes. Refer to xref::indexes-for-search-performance.adoc[] for more details on indexes. -* If a node key, relationship key, or uniqueness constraint is dropped and the backing index is still required, the index need to be created explicitly. +* If a node key, relationship key, or property uniqueness constraint is dropped and the backing index is still required, the index need to be created explicitly. Additionally, the following is true for constraints: diff --git a/modules/ROOT/pages/constraints/syntax.adoc b/modules/ROOT/pages/constraints/syntax.adoc index 6c4c21197..ae53f592f 100644 --- a/modules/ROOT/pages/constraints/syntax.adoc +++ b/modules/ROOT/pages/constraints/syntax.adoc @@ -32,9 +32,9 @@ Creating a constraint requires the xref::access-control/database-administration. [[constraints-syntax-create-node-unique]] [discrete] -=== Create a node uniqueness constraint +=== Create a node property uniqueness constraint -This command creates a uniqueness constraint on nodes with the specified label and properties. +This command creates a property uniqueness constraint on nodes with the specified label and properties. [source, syntax, role="noheader", indent=0] ---- @@ -57,9 +57,9 @@ Index provider can be specified using the `OPTIONS` clause. [[constraints-syntax-create-rel-unique]] [discrete] -=== Create a relationship uniqueness constraint +=== Create a relationship property uniqueness constraint -This command creates a uniqueness constraint on relationships with the specified relationship type and properties. +This command creates a property uniqueness constraint on relationships with the specified relationship type and properties. [source, syntax, role="noheader", indent=0] ---- @@ -253,13 +253,13 @@ The type filtering keywords filters the returned constraints on constraint type: This is the default if none is given. |NODE UNIQUE[NESS] -| Returns the node uniqueness constraints. +| Returns the node property uniqueness constraints. |REL[ATIONSHIP] UNIQUE[NESS] -| Returns the relationship uniqueness constraints. +| Returns the relationship property uniqueness constraints. |UNIQUE[NESS] -| Returns all uniqueness constraints, for both nodes and relationships. +| Returns all property uniqueness constraints, for both nodes and relationships. |NODE [PROPERTY] EXIST[ENCE] | Returns the node property existence constraints. diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index e632e7b0e..85b97550a 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -29,7 +29,7 @@ SHOW NODE UNIQUENESS CONSTRAINTS YIELD type ---- a| -Current constraint type for node uniqueness constraints, `UNIQUENESS`, will be updated to `NODE_UNIQUENESS` in 6.0. +Current constraint type for node property uniqueness constraints, `UNIQUENESS`, will be updated to `NODE_UNIQUENESS` in 6.0. This will also be reflected in updates to some error messages and query statistics. @@ -127,8 +127,8 @@ a| Added filtering for the new constraint types to `SHOW CONSTRAINTS`. Includes filtering for the node part, relationship part, or both parts of each type (`NODE KEY` filtering already exists previously). -The existing `UNIQUE` filter will now return both node and relationship uniqueness constraints. -All uniqueness constraint type filters now allow both `UNIQUE` and `UNIQUENESS` keywords. +The existing `UNIQUE` filter will now return both node and relationship property uniqueness constraints. +All property uniqueness constraint type filters now allow both `UNIQUE` and `UNIQUENESS` keywords. |=== @@ -473,7 +473,7 @@ CREATE CONSTRAINT OPTIONS "{" btree-option: btree-value[, ...] "}" ---- a| -Node key and uniqueness constraints backed by B-tree indexes are removed. +Node key and property uniqueness constraints backed by B-tree indexes are removed. Replaced by: [source, cypher, role="noheader"] @@ -1458,7 +1458,7 @@ CREATE CONSTRAINT OPTIONS "{" btree-option: btree-value[, ...] "}" ---- a| -Node key and uniqueness constraints with B-tree options are deprecated. +Node key and property uniqueness constraints with B-tree options are deprecated. Replaced by: [source, cypher, role="noheader"] @@ -1570,7 +1570,7 @@ REQUIRE (n.propertyName_1, …, n.propertyName_n) IS UNIQUE [OPTIONS "{" option: value[, ...] "}"] ---- a| -Uniqueness constraints now allow multiple properties, ensuring that the combination of property values are unique. +Property uniqueness constraints now allow multiple properties, ensuring that the combination of property values are unique. a| label:functionality[] @@ -1583,7 +1583,7 @@ ON (n:LabelName) ASSERT (n.propertyName_1, …, n.propertyName_n) IS UNIQUE ---- a| -Uniqueness constraints now allow multiple properties. +Property uniqueness constraints now allow multiple properties. Replaced by: [source, cypher, role="noheader"] @@ -1650,7 +1650,7 @@ CREATE CONSTRAINT OPTIONS "{" indexProvider: 'range-1.0' "}" ---- a| -Allows creating node key and uniqueness constraints backed by range indexes by providing the range index provider in the `OPTIONS` map. +Allows creating node key and property uniqueness constraints backed by range indexes by providing the range index provider in the `OPTIONS` map. a| @@ -2595,7 +2595,7 @@ label:new[] CREATE CONSTRAINT ... IS UNIQUE [OPTIONS {...}] ---- a| -Allows setting index provider and index configuration for the backing index when creating a uniqueness constraint. +Allows setting index provider and index configuration for the backing index when creating a property uniqueness constraint. a| label:syntax[] diff --git a/modules/ROOT/pages/execution-plans/operator-summary.adoc b/modules/ROOT/pages/execution-plans/operator-summary.adoc index 40e7dc3bf..06762ad46 100644 --- a/modules/ROOT/pages/execution-plans/operator-summary.adoc +++ b/modules/ROOT/pages/execution-plans/operator-summary.adoc @@ -53,13 +53,13 @@ Tests for the absence of a pattern predicate. | | xref::execution-plans/operators.adoc#query-plan-assert-same-node[AssertSameNode] -| Used to ensure that no uniqueness constraints are violated. +| Used to ensure that no property uniqueness constraints are violated. | | | | xref::execution-plans/operators.adoc#query-plan-asserting-multi-node-index-seek[AssertingMultiNodeIndexSeek] -| Used to ensure that no uniqueness constraints are violated. +| Used to ensure that no property uniqueness constraints are violated. | | | diff --git a/modules/ROOT/pages/execution-plans/operators.adoc b/modules/ROOT/pages/execution-plans/operators.adoc index ce5f2ab0b..126f98472 100644 --- a/modules/ROOT/pages/execution-plans/operators.adoc +++ b/modules/ROOT/pages/execution-plans/operators.adoc @@ -1141,9 +1141,9 @@ Total database accesses: 0, total allocated memory: 184 == Asserting Multi Node Index Seek // AssertingMultiNodeIndexSeek -The `AssertingMultiNodeIndexSeek` operator is used to ensure that no uniqueness constraints are violated. +The `AssertingMultiNodeIndexSeek` operator is used to ensure that no property uniqueness constraints are violated. The example looks for the presence of a team with the supplied name and id, and if one does not exist, it will be created. -Owing to the existence of two uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. +Owing to the existence of two property uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. .AssertingMultiNodeIndexSeek @@ -2635,9 +2635,9 @@ Total database accesses: 487, total allocated memory: 5256 == Assert Same Node // AssertSameNode -The `AssertSameNode` operator is used to ensure that no uniqueness constraints are violated in the slotted and interpreted runtime. +The `AssertSameNode` operator is used to ensure that no property uniqueness constraints are violated in the slotted and interpreted runtime. The example looks for the presence of a team with the supplied name and id, and if one does not exist, it will be created. -Owing to the existence of two uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. +Owing to the existence of two property uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. .AssertSameNode @@ -4888,11 +4888,11 @@ The `CreateConstraint` operator creates a constraint. This constraint can have any of the available constraint types: -* Uniqueness constraints +* Property uniqueness constraints * Property existence constraints label:enterprise-edition[] * Node or relationship key constraints label:enterprise-edition[] -The following query will create a uniqueness constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label. +The following query will create a property uniqueness constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label. .CreateConstraint @@ -4933,7 +4933,7 @@ Total database accesses: ? To not get an error creating the same constraint twice, we use the `DoNothingIfExists` operator for constraints. This will make sure no other constraint with the given name or another constraint of the same type and schema already exists before the specific `CreateConstraint` operator creates the constraint. If it finds a constraint with the given name or with the same type and schema it will stop the execution and no new constraint is created. -The following query will create a uniqueness constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label only if no constraint named `uniqueness` or uniqueness constraint on `+(:Country {name})+` already exists. +The following query will create a property uniqueness constraint with the name `uniqueness` on the `name` property of nodes with the `Country` label only if no constraint named `uniqueness` or property uniqueness constraint on `+(:Country {name})+` already exists. .DoNothingIfExists(CONSTRAINT) diff --git a/modules/ROOT/pages/introduction/index.adoc b/modules/ROOT/pages/introduction/index.adoc index 6f60a1bda..8c9146443 100644 --- a/modules/ROOT/pages/introduction/index.adoc +++ b/modules/ROOT/pages/introduction/index.adoc @@ -53,7 +53,7 @@ And these are examples of clauses that are used to update the graph: * `SET` (and `REMOVE`): Set values to properties and add labels on nodes using `SET` and use `REMOVE` to remove them. -* `MERGE`: Match existing or create new nodes and patterns. This is especially useful together with uniqueness constraints. +* `MERGE`: Match existing or create new nodes and patterns. This is especially useful together with property uniqueness constraints. .Cypher Query diff --git a/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc b/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc index 280be9dbb..fa3dce9f6 100644 --- a/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc +++ b/modules/ROOT/pages/introduction/neo4j-databases-graphs.adoc @@ -78,12 +78,12 @@ a| All constraints: xref::constraints/examples.adoc#constraints-examples-node-property-existence[node existence constraints], xref::constraints/examples.adoc#constraints-examples-relationship-property-existence[relationship existence constraints], -xref::constraints/examples.adoc#constraints-examples-node-uniqueness[node uniqueness constraints], -xref::constraints/examples.adoc#constraints-examples-relationship-uniqueness[relationship uniqueness constraints], +xref::constraints/examples.adoc#constraints-examples-node-uniqueness[node property uniqueness constraints], +xref::constraints/examples.adoc#constraints-examples-relationship-uniqueness[relationship property uniqueness constraints], xref::constraints/examples.adoc#constraints-examples-node-key[node key constraints], and xref::constraints/examples.adoc#constraints-examples-relationship-key[relationship key constraints]. a| -Only xref::constraints/examples.adoc#constraints-examples-node-uniqueness[node] and xref::constraints/examples.adoc#constraints-examples-relationship-uniqueness[relationship] uniqueness constraints. +Only xref::constraints/examples.adoc#constraints-examples-node-uniqueness[node] and xref::constraints/examples.adoc#constraints-examples-relationship-uniqueness[relationship] property uniqueness constraints. |=== From 0b72db851dfcae1a7ec1a8fbc0f4a001ff05a1e7 Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Tue, 20 Dec 2022 13:55:37 +0100 Subject: [PATCH 12/12] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jens Pryce-Åklundh <112686610+JPryce-Aklundh@users.noreply.github.com> --- modules/ROOT/pages/clauses/merge.adoc | 2 +- modules/ROOT/pages/constraints/examples.adoc | 96 ++++++++++--------- modules/ROOT/pages/constraints/index.adoc | 8 +- modules/ROOT/pages/constraints/syntax.adoc | 3 +- ...ions-additions-removals-compatibility.adoc | 2 +- .../ROOT/pages/execution-plans/operators.adoc | 4 +- modules/ROOT/pages/introduction/index.adoc | 3 +- 7 files changed, 64 insertions(+), 54 deletions(-) diff --git a/modules/ROOT/pages/clauses/merge.adoc b/modules/ROOT/pages/clauses/merge.adoc index 0ecdba3fa..751bb34f7 100644 --- a/modules/ROOT/pages/clauses/merge.adoc +++ b/modules/ROOT/pages/clauses/merge.adoc @@ -494,7 +494,7 @@ Labels added: 5 Cypher prevents getting conflicting results from `MERGE` when using patterns that involve property uniqueness constraints. In this case, there must be at most one node that matches that pattern. -For example, given two property uniqueness constraints on `:Person(id)` and `:Person(ssn)`, a query such as `MERGE (n:Person {id: 12, ssn: 437})` will fail, if there are two different nodes (one with `id` 12 and one with `ssn` 437) or if there is only one node with only one of the properties. +For example, given two property uniqueness constraints on `:Person(id)` and `:Person(ssn)`, a query such as `MERGE (n:Person {id: 12, ssn: 437})` will fail, if there are two different nodes (one with `id` 12 and one with `ssn` 437), or if there is only one node with only one of the properties. In other words, there must be exactly one node that matches the pattern, or no matching nodes. Note that the following examples assume the existence of property uniqueness constraints that have been created using: diff --git a/modules/ROOT/pages/constraints/examples.adoc b/modules/ROOT/pages/constraints/examples.adoc index b5718621e..0a440f566 100644 --- a/modules/ROOT/pages/constraints/examples.adoc +++ b/modules/ROOT/pages/constraints/examples.adoc @@ -52,7 +52,7 @@ Unique constraints added: 1 [NOTE] ==== -The statistics will be updated to say `Node uniqueness constraints` in 6.0. +The statistics will be updated to say `Node uniqueness constraints` in Neo4j version 6.0. ==== ====== @@ -62,8 +62,8 @@ The statistics will be updated to say `Node uniqueness constraints` in 6.0. [[constraints-create-a-node-uniqueness-constraint-if-not-exist]] === Handling existing constraints when creating a constraint -Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node property uniqueness constraint on the same schema already existed. +Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the `CREATE` command. +This will ensure that no error is thrown and no constraint is created if any other constraint with the given name or another node property uniqueness constraint on the same schema already exists. .+CREATE CONSTRAINT+ @@ -89,7 +89,7 @@ Unique constraints added: 1 [NOTE] ==== -The statistics will be updated to say `Node uniqueness constraints` in 6.0. +The statistics will be updated to say `Node uniqueness constraints` in Neo4j version 6.0. ==== ====== @@ -134,7 +134,7 @@ Unique constraints added: 1 [NOTE] ==== -The statistics will be updated to say `Node uniqueness constraints` in 6.0. +The statistics will be updated to say `Node uniqueness constraints` in Neo4j version 6.0. ==== ====== @@ -174,7 +174,7 @@ Constraint( id=4, name='preExistingUnique', type='UNIQUENESS', schema=(:Book {ti [NOTE] ==== -The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. +The constraint type will be updated to say `NODE_UNIQUENESS` in Neo4j version 6.0. ==== ====== @@ -182,7 +182,7 @@ The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. [discrete] [[constraints-create-a-node-uniqueness-constraint-on-same-schema-as-existing-index]] -=== Creating a constraint on same schema as an existing index will fail +=== Creating a constraint on the same schema as an existing index will fail .+CREATE CONSTRAINT+ @@ -304,7 +304,7 @@ CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE ---- In this case the constraint can not be created because it is violated by existing data. -You may choose to use xref::indexes-for-search-performance.adoc[] instead or remove the offending nodes and then re-apply the constraint. +Either use xref::indexes-for-search-performance.adoc[] instead, or remove the offending nodes and then re-apply the constraint. .Error message [source, "error message", role="noheader"] @@ -315,7 +315,7 @@ Both Node(0) and Node(1) have the label `Book` and property `isbn` = '1449356265 [NOTE] ==== -The constraint type will be updated to say `NODE_UNIQUENESS` in 6.0. +The constraint type will be updated to say `NODE_UNIQUENESS` in Neo4j version 6.0. ==== ====== @@ -369,8 +369,9 @@ Relationship uniqueness constraints added: 1 [[constraints-create-a-relationship-uniqueness-constraints-if-not-exist]] === Handling existing constraints when creating a constraint -Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship property uniqueness constraint on the same schema already existed. +Creating an already existing constraint will fail. +To avoid such an error, `IF NOT EXISTS` can be added to the `CREATE` command. +This will ensure that no error is thrown and no constraint is created if any other constraint with the given name or another relationship property uniqueness constraint on the same schema already exists. .+CREATE CONSTRAINT+ @@ -436,7 +437,7 @@ Relationship uniqueness constraints added: 1 ====== -There is no valid index configuration values for the constraint-backing range indexes. +There are no valid index configuration values for the constraint-backing range indexes. [discrete] @@ -460,7 +461,7 @@ CREATE CONSTRAINT preExistingUnique FOR ()-[friend:FRIENDS_WITH]-() REQUIRE frie CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE ---- -In this case the constraint can not be created because it already exists. +In this case, the constraint cannot be created because it already exists. .Error message [source, "error message", role="noheader"] @@ -474,7 +475,7 @@ Constraint( id=4, name='preExistingUnique', type='RELATIONSHIP_UNIQUENESS', sche [discrete] [[constraints-create-a-relationship-uniqueness-constraint-on-same-schema-as-existing-index]] -=== Creating a constraint on same schema as an existing index will fail +=== Creating a constraint on the same schema as an existing index will fail .+CREATE CONSTRAINT+ @@ -493,7 +494,7 @@ CREATE INDEX FOR ()-[friend:FRIENDS_WITH]-() ON (friend.nickname) CREATE CONSTRAINT FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE ---- -In this case the constraint can not be created because there already exists an index covering that schema. +In this case, the constraint cannot be created because there already exists an index covering that schema. .Error message [source, "error message", role="noheader"] @@ -564,7 +565,7 @@ MATCH (emma:Person {name: 'Emma'}), (emilia:Person {name: 'Emilia'}) CREATE (emma)-[:FRIENDS_WITH {nickname: 'Mimi'}]->(emilia) ---- -In this case the relationship is not created in the graph. +In this case, the relationship is not created in the graph. .Error message [source, "error message", role="noheader"] @@ -597,8 +598,8 @@ CREATE (josefin)-[:FRIENDS_WITH {nickname: 'Mimi'}]->(emilia), (emma)-[:FRIENDS_ CREATE CONSTRAINT friends FOR ()-[friend:FRIENDS_WITH]-() REQUIRE friend.nickname IS UNIQUE ---- -In this case the constraint can not be created because it is violated by existing data. -You may choose to use xref::indexes-for-search-performance.adoc[] instead or remove the offending relationships and then re-apply the constraint. +In this case, the constraint cannot be created because it is violated by existing data. +Either use xref::indexes-for-search-performance.adoc[] instead, or remove the offending relationships and then re-apply the constraint. .Error message [source, "error message", role="noheader"] @@ -653,8 +654,8 @@ Property existence constraints added: 1 [NOTE] ==== -The statistics for property existence constraints wil be split between nodes and relationships in 6.0. -For the node property existence constraints they will say `Node property existence constraints`. +The statistics for property existence constraints will be split between nodes and relationships in Neo4j version 6.0. +For the node property existence constraints, they will say `Node property existence constraints`. ==== ====== @@ -664,8 +665,9 @@ For the node property existence constraints they will say `Node property existen [[constraints-create-a-node-property-existence-constraint-if-not-exist]] === Handling existing constraints when creating a constraint -Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node property existence constraint on the same schema already existed. +Creating an already existing constraint will fail. +To avoid such an error, `IF NOT EXISTS` can be added to the `CREATE` command. +This will ensure that no error is thrown and no constraint is created if any other constraint with the given name or another node property existence constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -852,7 +854,8 @@ CREATE (book:Book {title: 'Graph Databases'}) CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS NOT NULL ---- -In this case the constraint can't be created because it is violated by existing data. We may choose to remove the offending nodes and then re-apply the constraint. +In this case the constraint can't be created because it is violated by existing data. +Remove the offending nodes and then re-apply the constraint. .Error message [source, "error message", role="noheader"] @@ -868,7 +871,7 @@ Node(0) with label `Book` must have the property `isbn` [[constraints-examples-relationship-property-existence]] == Relationship property existence constraints -A relationship property existence constraint ensures all relationships with a certain type have a certain property. +A relationship property existence constraint ensures that all relationships with a certain type have a certain property. * xref::constraints/examples.adoc#constraints-create-a-relationship-property-existence-constraint[] * xref::constraints/examples.adoc#constraints-create-a-relationship-property-existence-constraint-if-not-exist[] @@ -907,8 +910,8 @@ Property existence constraints added: 1 [NOTE] ==== -The statistics for property existence constraints wil be split between nodes and relationships in 6.0. -For the relationship property existence constraints they will say `Relationship property existence constraints`. +The statistics for property existence constraints will be split between nodes and relationships in Neo4j version 6.0. +For the relationship property existence constraints, they will say `Relationship property existence constraints`. ==== ====== @@ -918,8 +921,9 @@ For the relationship property existence constraints they will say `Relationship [[constraints-create-a-relationship-property-existence-constraint-if-not-exist]] === Handling existing constraints when creating a constraint -Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship property existence constraint on the same schema already existed. +Creating an already existing constraint will fail. +To avoid such an error, `IF NOT EXISTS` can be added to the `CREATE` command. +This will ensure that no error is thrown and no constraint is created if any other constraint with the given name or another relationship property existence constraint on the same schema already existed. .+CREATE CONSTRAINT+ @@ -1105,7 +1109,8 @@ CREATE (user:User)-[like:LIKED]->(book:Book) CREATE CONSTRAINT FOR ()-[like:LIKED]-() REQUIRE like.day IS NOT NULL ---- -In this case the constraint can not be created because it is violated by existing data. We may choose to remove the offending relationships and then re-apply the constraint. +In this case the constraint can not be created because it is violated by existing data. +Remove the offending relationships and then re-apply the constraint. .Error message [source, "error message", role="noheader"] @@ -1167,8 +1172,9 @@ Node key constraints added: 1 [[constraints-create-a-node-key-constraint-if-not-exist]] === Handling existing constraints when creating a constraint -Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another node key constraint on the same schema already existed. +Creating an already existing constraint will fail. +To avoid such an error, `IF NOT EXISTS` can be added to the `CREATE` command. +This will ensure that no error is thrown and no constraint is created if any other constraint with the given name or another node key constraint on the same schema already exists. .+CREATE CONSTRAINT+ @@ -1427,7 +1433,7 @@ CREATE CONSTRAINT FOR (n:Person) REQUIRE (n.firstname, n.surname) IS NODE KEY ---- In this case the node key constraint can not be created because it is violated by existing data. -We may choose to remove the offending nodes and then re-apply the constraint. +Either use xref::indexes-for-search-performance.adoc[] instead, or remove the offending nodes and then re-apply the constraint. .Error message [source, "error message", role="noheader"] @@ -1443,7 +1449,8 @@ Node(0) with label `Person` must have the properties (`firstname`, `surname`) [[constraints-examples-relationship-key]] == Relationship key constraints -A relationship key constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique and all properties in the set are present. +A relationship key constraint ensures that all relationships with a particular relationship type have a set of defined properties whose combined value is unique. +It also ensures that all properties in the set are present. * xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint[] * xref::constraints/examples.adoc#constraints-create-a-relationship-key-constraint-if-not-exist[] @@ -1489,8 +1496,9 @@ Relationship key constraints added: 1 [[constraints-create-a-relationship-key-constraint-if-not-exist]] === Handling existing constraints when creating a constraint -Creating an already existing constraint will fail. To avoid such an error, `IF NOT EXISTS` can be added to the create command. -This will ensure no error is thrown and no constraint created if any other constraint with the given name or another relationship key constraint on the same schema already existed. +Creating an already existing constraint will fail. +To avoid such an error, `IF NOT EXISTS` can be added to the `CREATE` command. +This will ensure that no error is thrown and no constraint is created if any other constraint with the given name or another relationship key constraint on the same schema already exists. .+CREATE CONSTRAINT+ @@ -1582,7 +1590,7 @@ CREATE CONSTRAINT preExistingUnique FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r. CREATE CONSTRAINT FOR ()-[r:ROAD]-() REQUIRE (r.startPoint, r.endPoint) IS REL KEY ---- -In this case the constraint can not be created because there already exist a conflicting constraint on that relationship type and property combination. +In this case, the constraint cannot be created because there already exists a conflicting constraint on that relationship type and property combination. .Error message [source, "error message", role="noheader"] @@ -1616,7 +1624,7 @@ CREATE CONSTRAINT intersections FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY ---- -In this case the constraint can't be created because there already exists an index with the given name. +In this case, the constraint cannot be created because there already exists an index with the given name. .Error message [source, "error message", role="noheader"] @@ -1686,7 +1694,7 @@ MATCH (a:Road {name: 'a'}), (b:Road {name: 'b'}) CREATE (a)-[:INTERSECTION]->(b) ---- -In this case the relationship is not created in the graph. +In this case, the relationship is not created in the graph. .Error message [source, "error message", role="noheader"] @@ -1720,7 +1728,7 @@ CREATE (a)-[:ROAD {startPoint: a.coordinates, endPoint: b.coordinates}]->(b) MATCH ()-[r:ROAD {startPoint: point({x: 1, y:2}), endPoint: point({x: 2, y:5})}]->() REMOVE r.endPoint ---- -In this case the property is not removed. +In this case, the property is not removed. .Error message [source, "error message", role="noheader"] @@ -1754,8 +1762,8 @@ CREATE (a)<-[:INTERSECTION {coordinates: point({x:1, y:2})}]-(b) CREATE CONSTRAINT intersectionConstraint FOR ()-[r:INTERSECTION]-() REQUIRE (r.coordinates) IS REL KEY ---- -In this case the relationship key constraint can not be created because it is violated by existing data. -We may choose to remove the offending relationships and then re-apply the constraint. +In this case, the relationship key constraint cannot be created because it is violated by existing data. +Either use xref::indexes-for-search-performance.adoc[] instead, or remove the offending relationships and then re-apply the constraint. .Error message [source, "error message", role="noheader"] @@ -1779,7 +1787,7 @@ Both Relationship(0) and Relationship(1) have the type `INTERSECTION` and proper === Drop a constraint A constraint can be dropped using the name with the `DROP CONSTRAINT constraint_name` command. -It is the same command for uniqueness, property existence and node/relationship key constraints. +It is the same command for uniqueness, property existence, and node/relationship key constraints. The name of the constraint can be found using the xref::constraints/syntax.adoc#constraints-syntax-list[`SHOW CONSTRAINTS` command], given in the output column `name`. @@ -1814,7 +1822,7 @@ Named constraints removed: 1 === Drop a non-existing constraint If it is uncertain if any constraint with a given name exists and you want to drop it if it does but not get an error should it not, use `IF EXISTS`. -It is the same command for uniqueness, property existence and node/relationship key constraints. +It is the same command for uniqueness, property existence, and node/relationship key constraints. .+DROP CONSTRAINT+ ====== @@ -1886,7 +1894,7 @@ SHOW CONSTRAINTS [NOTE] ==== The `type` column returns `UNIQUENESS` for the node property uniqueness constraint and `RELATIONSHIP_UNIQUENESS` for the relationship property uniqueness constraint. -The `type` for node property uniqueness constraint will be updated to `NODE_UNIQUENESS` in 6.0. +The `type` for node property uniqueness constraint will be updated to `NODE_UNIQUENESS` in Neo4j version 6.0. ==== ====== diff --git a/modules/ROOT/pages/constraints/index.adoc b/modules/ROOT/pages/constraints/index.adoc index 639d15841..472dc110e 100644 --- a/modules/ROOT/pages/constraints/index.adoc +++ b/modules/ROOT/pages/constraints/index.adoc @@ -16,12 +16,12 @@ The following constraint types are available: *Unique node property constraints*:: Unique node property constraints, or node property uniqueness constraints, ensure that property values are unique for all nodes with a specific label. For property uniqueness constraints on multiple properties, the combination of the property values is unique. -Node property uniqueness constraints do not require all nodes to have a unique value for the properties listed -- nodes without all properties are not subject to this rule. +Node property uniqueness constraints do not require all nodes to have a unique value for the properties listed (nodes without all properties are not subject to this rule). *Unique relationship property constraints*:: Unique relationship property constraints, or relationship property uniqueness constraints, ensure that property values are unique for all relationships with a specific type. For property uniqueness constraints on multiple properties, the combination of the property values is unique. -Relationship property uniqueness constraints do not require all relationships to have a unique value for the properties listed -- relationships without all properties are not subject to this rule. +Relationship property uniqueness constraints do not require all relationships to have a unique value for the properties listed (relationships without all properties are not subject to this rule). *Node property existence constraints* label:enterprise-edition[]:: Node property existence constraints ensure that a property exists for all nodes with a specific label. @@ -73,8 +73,8 @@ Databases containing one of these constraint types cannot be opened using Neo4j Creating a constraint has the following implications on indexes: -* Adding a node key, relationship key, or property uniqueness constraint on a single property also adds an index on that property and therefore, an index of the same index type, label/relationship type, and property combination cannot be added separately. -* Adding a node key, relationship key, or property uniqueness constraint for a set of properties also adds an index on those properties and therefore, an index of the same index type, label/relationship type, and properties combination cannot be added separately. +* Adding a node key, relationship key, or property uniqueness constraint on a single property also adds an index on that property, and therefore, an index of the same index type, label/relationship type, and property combination cannot be added separately. +* Adding a node key, relationship key, or property uniqueness constraint for a set of properties also adds an index on those properties, and therefore, an index of the same index type, label/relationship type, and properties combination cannot be added separately. * Cypher will use these indexes for lookups just like other indexes. Refer to xref::indexes-for-search-performance.adoc[] for more details on indexes. * If a node key, relationship key, or property uniqueness constraint is dropped and the backing index is still required, the index need to be created explicitly. diff --git a/modules/ROOT/pages/constraints/syntax.adoc b/modules/ROOT/pages/constraints/syntax.adoc index ae53f592f..4ca00d0dd 100644 --- a/modules/ROOT/pages/constraints/syntax.adoc +++ b/modules/ROOT/pages/constraints/syntax.adoc @@ -16,7 +16,8 @@ Best practice when creating a constraint is to give the constraint a name. This name must be unique among both indexes and constraints. If a name is not explicitly given, a unique name will be auto-generated. -The create constraint command is optionally idempotent. This means its default behavior is to throw an error if an attempt is made to create the same constraint twice. +The `CREATE CONSTRAINT` command is optionally idempotent. +This means its default behavior is to throw an error if an attempt is made to create the same constraint twice. With the `IF NOT EXISTS` flag, no error is thrown and nothing happens should a constraint with the same name or same schema and constraint type already exist. It may still throw an error if conflicting data, indexes, or constraints exist. Examples of this are nodes with missing properties, indexes with the same name, or constraints with same schema but a different conflicting constraint type. diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index 85b97550a..0e48d7ebd 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -29,7 +29,7 @@ SHOW NODE UNIQUENESS CONSTRAINTS YIELD type ---- a| -Current constraint type for node property uniqueness constraints, `UNIQUENESS`, will be updated to `NODE_UNIQUENESS` in 6.0. +The current constraint type for node property uniqueness constraints, `UNIQUENESS`, will be updated to `NODE_UNIQUENESS` in Neo4j version 6.0. This will also be reflected in updates to some error messages and query statistics. diff --git a/modules/ROOT/pages/execution-plans/operators.adoc b/modules/ROOT/pages/execution-plans/operators.adoc index 126f98472..cd9c4f9e1 100644 --- a/modules/ROOT/pages/execution-plans/operators.adoc +++ b/modules/ROOT/pages/execution-plans/operators.adoc @@ -1143,7 +1143,7 @@ Total database accesses: 0, total allocated memory: 184 The `AssertingMultiNodeIndexSeek` operator is used to ensure that no property uniqueness constraints are violated. The example looks for the presence of a team with the supplied name and id, and if one does not exist, it will be created. -Owing to the existence of two property uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. +Owing to the existence of two property uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` operator must be the very same node or the constraints would be violated. .AssertingMultiNodeIndexSeek @@ -2637,7 +2637,7 @@ Total database accesses: 487, total allocated memory: 5256 The `AssertSameNode` operator is used to ensure that no property uniqueness constraints are violated in the slotted and interpreted runtime. The example looks for the presence of a team with the supplied name and id, and if one does not exist, it will be created. -Owing to the existence of two property uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` must be the very same node, or the constraints would be violated. +Owing to the existence of two property uniqueness constraints on `:Team(name)` and `:Team(id)`, any node that would be found by the `UniqueIndexSeek` operator must be the very same node or the constraints would be violated. .AssertSameNode diff --git a/modules/ROOT/pages/introduction/index.adoc b/modules/ROOT/pages/introduction/index.adoc index 8c9146443..2ae29a020 100644 --- a/modules/ROOT/pages/introduction/index.adoc +++ b/modules/ROOT/pages/introduction/index.adoc @@ -53,7 +53,8 @@ And these are examples of clauses that are used to update the graph: * `SET` (and `REMOVE`): Set values to properties and add labels on nodes using `SET` and use `REMOVE` to remove them. -* `MERGE`: Match existing or create new nodes and patterns. This is especially useful together with property uniqueness constraints. +* `MERGE`: Match existing or create new nodes and patterns. +This is especially useful together with property uniqueness constraints. .Cypher Query