Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
54cab09
up to set graph type on a populated database
JPryce-Aklundh Sep 18, 2025
b226603
constraints slice, graph type set, add and alter
JPryce-Aklundh Sep 22, 2025
3315534
show and drop
JPryce-Aklundh Sep 22, 2025
f598cc9
add show constraints details
JPryce-Aklundh Sep 22, 2025
e625176
syntax, fixes, and additions
JPryce-Aklundh Sep 23, 2025
5f55cae
post-review corrections (non-graph types pages)
JPryce-Aklundh Sep 23, 2025
462834c
post-review corrections 2 (syntax page)
JPryce-Aklundh Sep 24, 2025
e0ae07f
rename alter and fix prefered wording
JPryce-Aklundh Sep 24, 2025
6f44951
preferred variants
JPryce-Aklundh Sep 24, 2025
024aaa2
post review corrections 3 (more syntax)
JPryce-Aklundh Sep 24, 2025
51142ac
post review corrections 4 (main graph types pages)
JPryce-Aklundh Sep 25, 2025
bf58dc3
forgotten DROP improvements
JPryce-Aklundh Sep 25, 2025
463f2f8
fix formatting
JPryce-Aklundh Sep 25, 2025
85613b8
table formatting
JPryce-Aklundh Sep 25, 2025
a8da38e
additional entry on additions page
JPryce-Aklundh Sep 25, 2025
b70d620
post review corrections 5 (misc)
JPryce-Aklundh Sep 25, 2025
beac214
add page aliases (given similar restructure in 5 manual)
JPryce-Aklundh Sep 26, 2025
450b90b
cheat sheet tags
JPryce-Aklundh Sep 30, 2025
7c975eb
fix incorrect tags
JPryce-Aklundh Sep 30, 2025
631cb3f
Update modules/ROOT/pages/schema/graph-types/alter-element-types.adoc
rsill-neo4j Oct 2, 2025
ba55ab6
Merge branch 'dev' into graph-types
rsill-neo4j Oct 2, 2025
7ebebbb
Apply suggestions from code review
rsill-neo4j Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ When altering a graph type, only those node or relationship element types to be
====
Altering element types in a graph type requires the following privileges:

* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-constraints[`CREATE CONSTRAINT`]
* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-constraints[`CREATE CONSTRAINT`]
* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-constraints[`DROP CONSTRAINT`]
* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-tokens[`NAME MANAGEMENT`] (if graph type includes node labels, relationship types, or properties not already in the graph)
====
Expand All @@ -33,7 +33,7 @@ ALTER CURRENT GRAPH TYPE SET {
----

[NOTE]
For details about all the elements included in the above graph type, see xref:schema/graph-types/set-graph-types.adoc[].
For details about the different elements a graph type can contain, see xref:schema/graph-types/set-graph-types.adoc[].

.Alter node and relationship element types in a graph type
[source, cypher]
Expand Down Expand Up @@ -97,8 +97,6 @@ For more information about how graph types are implemented, see xref:schema/grap

The behavior of key and property uniqueness constraints on identifying node labels and relationship types, as well as constraints on non-identifying node labels and relationship types with regard to the `ALTER CURRENT GRAPH TYPE ALTER` command follows that of xref:schema/constraints/index.adoc[Neo4j constraints]; they can be created and dropped, but they cannot be altered through a single command (they must, in that case, be dropped and recreated to fit the desired alteration).

It is not allowed to add key and property uniqueness constraints to node or relationship element types when altering a graph type. Nor can they be converted into another one through alteration.

It is not allowed to add key and property uniqueness constraints to node or relationship element types when altering a graph type.
Nor can they be converted into another one through alteration.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ ALTER CURRENT GRAPH TYPE SET {
(:Robot => :Resident&Machine {application :: STRING NOT NULL, id :: INTEGER NOT NULL}),
(:City => {name :: STRING NOT NULL, population :: INTEGER}),
(:Resident)-[:LIVES_IN => {since :: ANY NOT NULL}]->(:City),
CONSTRAINT company_name FOR (c:Company) REQUIRE c.name IS KEY,
CONSTRAINT resident_address FOR (resident:Resident) REQUIRE resident.address :: STRING,
CONSTRAINT ownership_id FOR ()-[owner:OWNER_OF]->() REQUIRE owner.ownershipId IS UNIQUE,
(:Company => {name :: STRING, address :: STRING IS UNIQUE}),
(:Person)-[:WORKS_FOR => {role :: STRING}]->(:Company)
(:Person)-[:WORKS_FOR => {role :: STRING}]->(:Company),
CONSTRAINT company_name FOR (c:Company) REQUIRE c.name IS KEY,
CONSTRAINT animal_id FOR (a:Animal) REQUIRE a.id IS UNIQUE,
CONSTRAINT resident_address FOR (resident:Resident) REQUIRE resident.address :: STRING
}
----

Expand Down Expand Up @@ -116,15 +116,15 @@ ALTER CURRENT GRAPH TYPE DROP {
[[drop-constraints-on-identifying-and-non-identifying-labels-and-types]]
== Drop constraints on identifying and non-identifying node labels and relationship types

Key and property uniqueness constraints can only be dropped by using the `CONSTRAINT [name]` syntax in the `ALTER CURRENT GRAPH TYPE DROP` command, regardless if they were defined on an identifying or non-identifying label.
Key and property uniqueness constraints can only be dropped by using the `CONSTRAINT name` syntax in the `ALTER CURRENT GRAPH TYPE DROP` command, regardless if they were defined on an identifying or non-identifying label.
Property existence and property type constraints defined on non-identifying node labels and relationship types are also dropped in this way.
The names of constraints are returned by the xref:schema/constraints/list-constraints.adoc[`SHOW CONSTRAINTS`] command.
The names of constraints are returned by the xref:schema/constraints/list-constraints.adoc[`SHOW CONSTRAINTS`] command or as part of their definitions in xref:schema/graph-types/list-graph-types.adoc[`SHOW CURRENT GRAPH TYPE`].

.Drop explicitly named and generated name key and property uniqueness constraint
[source, cypher]
----
ALTER CURRENT GRAPH TYPE DROP {
CONSTRAINT ownership_id,
CONSTRAINT animal_id,
CONSTRAINT constraint_302a3693
}
----
Expand Down
11 changes: 6 additions & 5 deletions modules/ROOT/pages/schema/graph-types/extend-graph-types.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This command cannot alter existing elements in a graph type but adds entirely ne
====
Extending a graph type requires the following privileges:

* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-constraints[`CREATE CONSTRAINT`]
* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-constraints[`CREATE CONSTRAINT`]
* link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-tokens[`NAME MANAGEMENT`] (if graph type includes node labels, relationship types, or properties not already in the graph)
====

Expand All @@ -30,13 +30,13 @@ ALTER CURRENT GRAPH TYPE SET {
----

[NOTE]
For details about all the elements included in the above graph type, see xref:schema/graph-types/set-graph-types.adoc[].
For details about the different elements a graph type can contain, see xref:schema/graph-types/set-graph-types.adoc[].

.Extend a graph type by adding new element types
[source, cypher]
----
ALTER CURRENT GRAPH TYPE ADD {
(:Company => {name :: STRING, address :: STRING IS KEY}), // <1>
(:Company => {name :: STRING, address :: STRING IS UNIQUE}), // <1>
(:Person)-[:WORKS_FOR => {role :: STRING}]->(:Company)
}
----
Expand All @@ -63,7 +63,7 @@ It is implemented with the following constraints:

| `(:Company)`
| Node property key
| `address IS KEY`
| `address IS UNIQUE`

| `()-[:WORKS_FOR]\->()`
| Relationship property type
Expand All @@ -82,7 +82,7 @@ For more information about how graph types are implemented, see xref:schema/grap

The graph type now includes the added node and relationship element type:

.Set graph type - with added node and relationship element types
.Current graph type -- with added node and relationship element types
[source]
----
(p:Person => :Resident {name :: STRING, ssn :: INTEGER})
Expand Down Expand Up @@ -119,3 +119,4 @@ This is not valid.
The reverse (adding a node or relationship element type with an identifying label/type already defined by a property type or property existence constraint) is also not possible.
<3> This attempts to add a node element type with an identifying label already used as an implied label in a node element type in the existing graph type (`Pet`).
This is not valid.
The reverse (adding a node element type with an implied label that is already used as an identifying label in an existing node element type) is also not possible.
Loading