Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
16 changes: 16 additions & 0 deletions modules/ROOT/pages/schema/constraints/create-constraints.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ For the full command syntax to create a property uniqueness constraint, see xref
======

.Create a constraint requiring `Book` nodes to have unique `isbn` properties
// tag::schema_constraints_property_uniqueness[]
[source, cypher]
----
CREATE CONSTRAINT book_isbn
FOR (book:Book) REQUIRE book.isbn IS UNIQUE
----
// end::schema_constraints_property_uniqueness[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -106,11 +108,13 @@ Added 1 constraint.
======

.Create a constraint requiring `PREQUEL_OF` relationships to have unique combinations of `order` and `author` properties
// tag::schema_constraints_composite_property_uniqueness[]
[source, cypher]
----
CREATE CONSTRAINT prequels
FOR ()-[prequel:PREQUEL_OF]-() REQUIRE (prequel.order, prequel.author) IS UNIQUE
----
// end::schema_constraints_composite_property_uniqueness[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -183,11 +187,13 @@ It is not possible to create composite existence constraints on several properti
======

.Create a constraint requiring `Author` nodes to have a `name` property
// tag::schema_constraints_property_existence[]
[source, cypher]
----
CREATE CONSTRAINT author_name
FOR (author:Author) REQUIRE author.name IS NOT NULL
----
// end::schema_constraints_property_existence[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -301,11 +307,13 @@ Added 1 constraint.
======

.Create a constraint requiring `order` properties on `PART_OF` relationships to be of type `INTEGER`
// tag::schema_constraints_property_type[]
[source, cypher]
----
CREATE CONSTRAINT part_of
FOR ()-[part:PART_OF]-() REQUIRE part.order IS :: INTEGER
----
// end::schema_constraints_property_type[]

.Result
[source, queryresult]
Expand All @@ -324,11 +332,13 @@ A closed dynamic union allows a node or relationship property to maintain some t
======

.Create a constraint requiring `tagline` properties on `Movie` nodes to be either of type `STRING` or `LIST<STRING NOT NULL>`
// tag::schema_constraints_property_type_dynamic_union[]
[source, cypher]
----
CREATE CONSTRAINT movie_tagline
FOR (movie:Movie) REQUIRE movie.tagline IS :: STRING | LIST<STRING NOT NULL>
----
// end::schema_constraints_property_type_dynamic_union[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -471,11 +481,13 @@ For the full command syntax to create a key constraint, see xref:schema/syntax.a
======

.Create a constraint requiring `Director` nodes to have a unique `imdbId` property as a node key.
// tag::schema_constraints_key[]
[source, cypher]
----
CREATE CONSTRAINT director_imdbId
FOR (director:Director) REQUIRE (director.imdbId) IS NODE KEY
----
// end::schema_constraints_key[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -539,11 +551,13 @@ Added 1 constraint.
======

.Create a constraint requiring `KNOWS` relationships to have a unique combination of `since` and `how` properties as a relationship key
// tag::schema_constraints_composite_key[]
[source, cypher]
----
CREATE CONSTRAINT knows_since_how
FOR ()-[knows:KNOWS]-() REQUIRE (knows.since, knows.how) IS RELATIONSHIP KEY
----
// end::schema_constraints_composite_key[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -609,11 +623,13 @@ All constraint types can be created with a parameterized name.
----

.Create a node property uniqueness constraint with a parameterized name
// tag::schema_constraints_parameter[]
[source, cypher]
----
CREATE CONSTRAINT $name
FOR (book:Book) REQUIRE book.prop1 IS UNIQUE
----
// end::schema_constraints_parameter[]

.Result
[source, queryresult]
Expand Down
4 changes: 4 additions & 0 deletions modules/ROOT/pages/schema/constraints/drop-constraints.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ FOR ()-[wrote:WROTE]-() REQUIRE wrote.published IS NOT NULL
======

.Drop the constraint `book_isbn`
// tag::schema_constraints_drop[]
[source, cypher]
----
DROP CONSTRAINT book_isbn
----
// end::schema_constraints_drop[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -102,10 +104,12 @@ Constraints can be dropped with a parameterized name.
----

.Drop a constraint with a parameterized name
// tag::schema_constraints_drop_parameter[]
[source, cypher]
----
DROP CONSTRAINT $name
----
// end::schema_constraints_drop_parameter[]

.Result
[source, queryresult]
Expand Down
8 changes: 8 additions & 0 deletions modules/ROOT/pages/schema/constraints/list-constraints.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ FOR ()-[wrote:WROTE]-() REQUIRE wrote.published IS NOT NULL
======

.Query
// tag::schema_constraints_show[]
[source, cypher, test-exclude-cols=id]
----
SHOW CONSTRAINTS
----
// end::schema_constraints_show[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -104,10 +106,12 @@ SHOW CONSTRAINTS
To return the full details of the constraints on a database, use `SHOW CONSTRAINTS YIELD *`

.List all constraints with `YIELD *`
// tag::schema_constraints_show_full[]
[source, cypher, test-exclude-cols=id]
----
SHOW CONSTRAINTS YIELD *
----
// end::schema_constraints_show_full[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -145,10 +149,12 @@ The filtering of rows can be done using constraint type keywords or a `WHERE` cl
======

.List only key constraints
// tag::schema_constraints_show_type_filter[]
[source, cypher, test-exclude-cols=id]
----
SHOW KEY CONSTRAINTS
----
// end::schema_constraints_show_type_filter[]

.Result
[source, queryresult]
Expand Down Expand Up @@ -204,11 +210,13 @@ WHERE entityType = 'RELATIONSHIP'
It is possible to return only specific columns of the available constraints using the `YIELD` clause:

.List only the `name`, `type`, and `createStatement` columns
// tag::schema_constraints_show_specific_columns[]
[source, cypher, test-exclude-cols=id]
----
SHOW CONSTRAINTS
YIELD name, type, createStatement
----
// end::schema_constraints_show_specific_columns[]

.Result
[source, queryresult]
Expand Down
16 changes: 16 additions & 0 deletions modules/ROOT/pages/schema/graph-types/alter-element-types.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ ALTER CURRENT GRAPH TYPE ALTER {
}
----

////
Cheat sheet example (necessary to exclude <1> tag in the cheat sheet):

// tag::schema_graph_types_alter[]
[source, cypher]
----
ALTER CURRENT GRAPH TYPE ADD {
ALTER {
(:Robot => :Resident&Machine {application :: STRING NOT NULL, id :: INTEGER NOT NULL}),
(:Resident)-[:LIVES_IN => {since :: ANY NOT NULL}]->(:City)
}
----
// end::schema_graph_types_alter[]

////

<1> Nodes with a `Robot` label must now also have a `Machine` label.
`Robot` nodes are also required to have an `id` property of type `INTEGER`.
<2> `since` properties on `LIVES_IN` relationships can now be of `ANY` type (they were previously constrained to be of type `DATE`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ ALTER CURRENT GRAPH TYPE SET {
To fully drop a xref:schema/graph-types/set-graph-types.adoc#node-element-types[node] or xref:schema/graph-types/set-graph-types.adoc#relationship-element-types[relationship element type], it is only necessary to define its identifying node label/relationship type appended with `\=>`.

.Drop node and relationship element types
// tag::schema_graph_types_drop_elements[]
[source, cypher]
----
ALTER CURRENT GRAPH TYPE DROP {
(:Pet => ),
()-[:LIVES_IN => ]->()
}
----
// end::schema_graph_types_drop_elements[]

You can also define the full element type when dropping an element type.
Partial definitions, however, are not allowed.
Expand Down Expand Up @@ -121,13 +123,15 @@ Property existence and property type constraints defined on non-identifying node
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
// tag::schema_graph_types_drop_constraints[]
[source, cypher]
----
ALTER CURRENT GRAPH TYPE DROP {
CONSTRAINT animal_id,
CONSTRAINT constraint_302a3693
}
----
// end::schema_graph_types_drop_constraints[]

These constraints can also be dropped from the graph type using the xref:schema/constraints/drop-constraints.adoc[`DROP CONSTRAINT`] command.

Expand All @@ -144,10 +148,12 @@ To drop a full graph type, use the `ALTER CURRENT GRAPH TYPE SET` command.
This will replace the existing graph type with a new (possibly empty) graph type.

.Drop full graph type and replace it with an empty graph type
// tag::schema_graph_types_drop_full[]
[source, cypher]
----
ALTER CURRENT GRAPH TYPE SET { }
----
// end::schema_graph_types_drop_full[]

.Drop full graph type and replace with a new graph type
[source, cypher]
Expand Down
17 changes: 17 additions & 0 deletions modules/ROOT/pages/schema/graph-types/extend-graph-types.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Extending a graph type requires the following privileges:
====

.Set graph type
// tag::schema_graph_types_set[]
[source, cypher]
----
ALTER CURRENT GRAPH TYPE SET {
Expand All @@ -28,6 +29,7 @@ ALTER CURRENT GRAPH TYPE SET {
CONSTRAINT resident_address FOR (resident:Resident) REQUIRE resident.address :: STRING
}
----
// end::schema_graph_types_set[]

[NOTE]
For details about the different elements a graph type can contain, see xref:schema/graph-types/set-graph-types.adoc[].
Expand All @@ -44,6 +46,21 @@ ALTER CURRENT GRAPH TYPE ADD {
<1> This adds a node element type with an identifying label also used by an existing key constraint in the graph type (`company_name`).
This addition is possible for property uniqueness and key constraints originally not defined on an identifying label, but not for property existence and property type constraints.

////
Cheat sheet example (necessary to exclude <1> tag in the cheat sheet):

// tag::schema_graph_types_add[]
[source, cypher]
----
ALTER CURRENT GRAPH TYPE ADD {
(:Company => {name :: STRING, address :: STRING IS UNIQUE}),
(:Person)-[:WORKS_FOR => {role :: STRING}]->(:Company)
}
----
// end::schema_graph_types_add[]

////

The extension adds one node element type and one relationship element type to the graph type.
It is implemented with the following constraints:

Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/schema/graph-types/list-graph-types.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ ALTER CURRENT GRAPH TYPE SET {
----

.Show the full graph type
// tag::schema_graph_types_show[]
[source, cypher]
----
SHOW CURRENT GRAPH TYPE
----
// end::schema_graph_types_show[]

.Result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image not sure we need that much space on the end but sure :P

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also applies to the next result)

[source, "queryresult"]
Expand Down