Skip to content

Commit b85ed47

Browse files
cheat sheet tags
1 parent 09ce639 commit b85ed47

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

modules/ROOT/pages/constraints/create-constraints.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ For the full command syntax to create a property uniqueness constraint, see xref
3838
======
3939
4040
.Create a constraint requiring `Book` nodes to have unique `isbn` properties
41+
// tag::schema_constraints_property_uniqueness[]
4142
[source, cypher]
4243
----
4344
CREATE CONSTRAINT book_isbn
4445
FOR (book:Book) REQUIRE book.isbn IS UNIQUE
4546
----
47+
// end::schema_constraints_property_uniqueness[]
4648
4749
.Result
4850
[source, queryresult]
@@ -106,11 +108,13 @@ Added 1 constraint.
106108
======
107109
108110
.Create a constraint requiring `PREQUEL_OF` relationships to have unique combinations of `order` and `author` properties
111+
// tag::schema_constraints_composite_property_uniqueness[]
109112
[source, cypher]
110113
----
111114
CREATE CONSTRAINT prequels
112115
FOR ()-[prequel:PREQUEL_OF]-() REQUIRE (prequel.order, prequel.author) IS UNIQUE
113116
----
117+
// end::schema_constraints_composite_property_uniqueness[]
114118
115119
.Result
116120
[source, queryresult]
@@ -183,11 +187,13 @@ It is not possible to create composite existence constraints on several properti
183187
======
184188
185189
.Create a constraint requiring `Author` nodes to have a `name` property
190+
// tag::schema_constraints_property_existence[]
186191
[source, cypher]
187192
----
188193
CREATE CONSTRAINT author_name
189194
FOR (author:Author) REQUIRE author.name IS NOT NULL
190195
----
196+
// end::schema_constraints_property_existence[]
191197
192198
.Result
193199
[source, queryresult]
@@ -301,11 +307,13 @@ Added 1 constraint.
301307
======
302308
303309
.Create a constraint requiring `order` properties on `PART_OF` relationships to be of type `INTEGER`
310+
// tag::schema_constraints_property_type[]
304311
[source, cypher]
305312
----
306313
CREATE CONSTRAINT part_of
307314
FOR ()-[part:PART_OF]-() REQUIRE part.order IS :: INTEGER
308315
----
316+
// end::schema_constraints_property_type[]
309317
310318
.Result
311319
[source, queryresult]
@@ -324,11 +332,13 @@ A closed dynamic union allows a node or relationship property to maintain some t
324332
======
325333
326334
.Create a constraint requiring `tagline` properties on `Movie` nodes to be either of type `STRING` or `LIST<STRING NOT NULL>`
335+
// tag::schema_constraints_property_type_dynamic_union[]
327336
[source, cypher]
328337
----
329338
CREATE CONSTRAINT movie_tagline
330339
FOR (movie:Movie) REQUIRE movie.tagline IS :: STRING | LIST<STRING NOT NULL>
331340
----
341+
// end::schema_constraints_property_type_dynamic_union[]
332342
333343
.Result
334344
[source, queryresult]
@@ -471,11 +481,13 @@ For the full command syntax to create a key constraint, see xref:constraints/syn
471481
======
472482
473483
.Create a constraint requiring `Director` nodes to have a unique `imdbId` property as a node key.
484+
// tag::schema_constraints_key[]
474485
[source, cypher]
475486
----
476487
CREATE CONSTRAINT director_imdbId
477488
FOR (director:Director) REQUIRE (director.imdbId) IS NODE KEY
478489
----
490+
// end::schema_constraints_key[]
479491
480492
.Result
481493
[source, queryresult]
@@ -539,11 +551,13 @@ Added 1 constraint.
539551
======
540552
541553
.Create a constraint requiring `KNOWS` relationships to have a unique combination of `since` and `how` properties as a relationship key
554+
// tag::schema_constraints_composite_key[]
542555
[source, cypher]
543556
----
544557
CREATE CONSTRAINT knows_since_how
545558
FOR ()-[knows:KNOWS]-() REQUIRE (knows.since, knows.how) IS RELATIONSHIP KEY
546559
----
560+
// end::schema_constraints_composite_key[]
547561
548562
.Result
549563
[source, queryresult]
@@ -609,11 +623,13 @@ All constraint types can be created with a parameterized name.
609623
----
610624
611625
.Create a node property uniqueness constraint with a parameterized name
626+
// tag::schema_constraints_parameter[]
612627
[source, cypher]
613628
----
614629
CREATE CONSTRAINT $name
615630
FOR (book:Book) REQUIRE book.prop1 IS UNIQUE
616631
----
632+
// end::schema_constraints_parameter[]
617633
618634
.Result
619635
[source, queryresult]

modules/ROOT/pages/constraints/drop-constraints.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ FOR ()-[wrote:WROTE]-() REQUIRE wrote.published IS NOT NULL
5959
======
6060
6161
.Drop the constraint `book_isbn`
62+
// tag::schema_constraints_drop[]
6263
[source, cypher]
6364
----
6465
DROP CONSTRAINT book_isbn
6566
----
67+
// end::schema_constraints_drop[]
6668
6769
.Result
6870
[source, queryresult]
@@ -90,10 +92,12 @@ Constraints can be dropped with a parameterized name.
9092
----
9193
9294
.Drop a constraint with a parameterized name
95+
// tag::schema_constraints_drop_parameter[]
9396
[source, cypher]
9497
----
9598
DROP CONSTRAINT $name
9699
----
100+
// end::schema_constraints_drop_parameter[]
97101
98102
.Result
99103
[source, queryresult]

modules/ROOT/pages/constraints/list-constraints.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ FOR ()-[wrote:WROTE]-() REQUIRE wrote.published IS NOT NULL
5656
======
5757
5858
.Query
59+
// tag::schema_constraints_show[]
5960
[source, cypher, test-exclude-cols=id]
6061
----
6162
SHOW CONSTRAINTS
6263
----
64+
// end::schema_constraints_show[]
6365
6466
.Result
6567
[source, queryresult]
@@ -94,10 +96,12 @@ SHOW CONSTRAINTS
9496
To return the full details of the constraints on a database, use `SHOW CONSTRAINTS YIELD *`
9597
9698
.List all constraints with `YIELD *`
99+
// tag::schema_constraints_show_full[]
97100
[source, cypher, test-exclude-cols=id]
98101
----
99102
SHOW CONSTRAINTS YIELD *
100103
----
104+
// end::schema_constraints_show_full[]
101105
102106
.Result
103107
[source, queryresult]
@@ -135,10 +139,12 @@ The filtering of rows can be done using constraint type keywords or a `WHERE` cl
135139
======
136140
137141
.List only key constraints
142+
// tag::schema_constraints_show_type_filter[]
138143
[source, cypher, test-exclude-cols=id]
139144
----
140145
SHOW KEY CONSTRAINTS
141146
----
147+
// end::schema_constraints_show_type_filter[]
142148
143149
.Result
144150
[source, queryresult]
@@ -194,11 +200,13 @@ WHERE entityType = 'RELATIONSHIP'
194200
It is possible to return only specific columns of the available constraints using the `YIELD` clause:
195201
196202
.List only the `name`, `type`, and `createStatement` columns
203+
// tag::schema_constraints_show_specific_columns[]
197204
[source, cypher, test-exclude-cols=id]
198205
----
199206
SHOW CONSTRAINTS
200207
YIELD name, type, createStatement
201208
----
209+
// end::schema_constraints_show_specific_columns[]
202210
203211
.Result
204212
[source, queryresult]

0 commit comments

Comments
 (0)