Skip to content

Commit 46ef713

Browse files
l-heemannLojjsrenetapopova
authored andcommitted
Graph reference updates for Cypher 25 / Neo4j 2025.06 (#2443)
Documentation for: CIP-212 neo-technology/neo4j#31208 neo-technology/neo4j#31418 --------- Co-authored-by: Louise Berglund <[email protected]> Co-authored-by: Reneta Popova <[email protected]>
1 parent e454388 commit 46ef713

File tree

5 files changed

+234
-32
lines changed

5 files changed

+234
-32
lines changed

modules/ROOT/pages/database-administration/aliases/manage-aliases-composite-databases.adoc

Lines changed: 186 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Starting with Neo4j 2025.04, a database alias can also be set as the default dat
99
////
1010
[source, cypher, role=test-setup]
1111
----
12-
CREATE DATABASE `sci-fi-books`;
13-
CREATE COMPOSITE DATABASE `library`;
14-
CREATE ALIAS `library`.`sci-fi` FOR DATABASE `sci-fi-books`;
15-
CREATE ALIAS `library`.`romance` FOR DATABASE `romance-books` AT 'neo4j+s://location:7687' USER alice PASSWORD 'password';
16-
CREATE COMPOSITE DATABASE garden;
17-
CREATE DATABASE `perennial-flowers`;
12+
CYPHER 25 CREATE DATABASE `sci-fi-books`;
13+
CYPHER 25 CREATE COMPOSITE DATABASE `library`;
14+
CYPHER 25 CREATE ALIAS `library.sci-fi` FOR DATABASE `sci-fi-books`;
15+
CYPHER 25 CREATE ALIAS `library.romance` FOR DATABASE `romance-books` AT 'neo4j+s://location:7687' USER alice PASSWORD 'password';
16+
CYPHER 25 CREATE COMPOSITE DATABASE garden;
17+
CYPHER 25 CREATE DATABASE `perennial-flowers`;
1818
----
1919
////
2020

@@ -58,7 +58,7 @@ For a description of all the returned columns of this command, and for ways in w
5858

5959
Both local and remote database aliases can be part of a xref::database-administration/composite-databases/concepts.adoc[composite database].
6060

61-
The database alias is made of two parts, separated by a dot: the namespace and the alias name.
61+
The database alias consists of two parts, separated by a dot: the namespace and the alias name.
6262

6363
The namespace must be the name of the composite database.
6464

@@ -220,15 +220,175 @@ SHOW DATABASE garden YIELD name, type, constituents
220220
----
221221

222222
[[alias-management-escaping]]
223-
== Database alias names and escaping
223+
== Database alias names that contain dots
224224

225225
Naming database aliases in composite databases follows the same rule as xref:database-administration/aliases/naming-aliases.adoc[naming aliases for standard databases].
226226
However, when it comes to escaping names using backticks, there are some additional things to consider:
227227

228-
=== Quoting database alias and composite database names
228+
Dots in alias names are ambiguous.
229+
They could either be interpreted as part of the name itself, or as the dot that separates a composite namespace from the alias name.
230+
231+
[role=label--new-2025.06]
232+
=== Conflicting names
233+
In versions earlier than Neo4j 2025.06, it is possible to create conflicting aliases, such as the constituent alias `flowers` within the composite database `garden` as well as the non-composite local alias `garden.flowers`.
234+
Both of these are referred to by the same name, `garden.flowers`.
235+
236+
Neo4j 2025.06 and later versions ensure that no such conflicts exist and throw an exception when attempting to create a new alias with the same name as an existing alias.
237+
238+
[.tabbed-example]
239+
=====
240+
[role=include-with-cypher-5]
241+
======
242+
Creating a regular alias with the same name as an existing composite constituent is disallowed:
243+
244+
.Query
245+
[source, cypher]
246+
----
247+
CYPHER 5 CREATE COMPOSITE DATABASE `garden`
248+
CYPHER 5 CREATE ALIAS `garden`.`flowers` FOR DATABASE `northwind-graph`
249+
CYPHER 5 CREATE ALIAS `garden.flowers` FOR DATABASE `northwind-graph`
250+
----
251+
252+
.Error message
253+
[source, output, role="noheader"]
254+
----
255+
Failed to create the specified database alias 'garden.flowers': Database name or alias already exists.
256+
----
257+
The exception has the GQLSTATUS code link:{neo4j-docs-base-uri}/status-codes/current/errors/gql-errors/42001[42001 - invalid syntax] with the cause link:{neo4j-docs-base-uri}/status-codes/current/errors/gql-errors/42N11[42N11 - graph reference already exists].
258+
259+
======
260+
261+
[role=include-with-cypher-25]
262+
======
263+
264+
Creating a regular alias with the same name as an existing composite constituent is disallowed.
265+
In Cypher 25, the two names are considered the same since the parts are not quoted separately as they would be in Cypher 5.
266+
267+
.Query
268+
[source, cypher]
269+
----
270+
CYPHER 25 CREATE COMPOSITE DATABASE `garden`
271+
CYPHER 25 CREATE ALIAS `garden.flowers` FOR DATABASE `northwind-graph`
272+
CYPHER 25 CREATE ALIAS `garden.flowers` FOR DATABASE `northwind-graph`
273+
----
274+
275+
.Error message
276+
[source, output, role="noheader"]
277+
----
278+
Failed to create the specified database alias 'garden.flowers': Database name or alias already exists.
279+
----
280+
The exception has the GQLSTATUS code link:{neo4j-docs-base-uri}/status-codes/current/errors/gql-errors/42001[42001 - invalid syntax] with the cause link:{neo4j-docs-base-uri}/status-codes/current/errors/gql-errors/42N11[42N11 - graph reference already exists].
281+
======
282+
=====
283+
284+
[.tabbed-example]
285+
=====
286+
[role=include-with-cypher-5]
287+
======
288+
Creating a composite constituent with the same name as an existing non-composite alias is disallowed.
289+
This example scenario is already prevented on the second line; thus, the constituent on the third line cannot be created.
290+
291+
.Query
292+
[source, cypher]
293+
----
294+
CYPHER 5 CREATE ALIAS `garden.flowers` FOR DATABASE `northwind-graph`
295+
CYPHER 5 CREATE COMPOSITE DATABASE `garden`
296+
CYPHER 5 CREATE ALIAS `garden`.`flowers` FOR DATABASE `northwind-graph`
297+
----
298+
299+
.Error message
300+
[source, output, role="noheader"]
301+
----
302+
Cannot create database 'garden' because another database 'garden.flowers' exists with an ambiguous name.
303+
----
304+
The exception has the GQLSTATUS code link:{neo4j-docs-base-uri}/status-codes/current/errors/gql-errors/42N87[42N87 - database or alias with similar name exists].
305+
======
306+
307+
[role=include-with-cypher-25]
308+
======
309+
310+
Creating a composite constituent with the same name as an existing non-composite alias is disallowed.
311+
This example scenario is already prevented on the second line; thus, the constituent on the third line cannot be created.
312+
The Cypher 25 syntax makes no distinction between the names to clarify that they are considered equivalent.
313+
314+
.Query
315+
[source, cypher]
316+
----
317+
CYPHER 25 CREATE ALIAS `garden.flowers` FOR DATABASE `northwind-graph`
318+
CYPHER 25 CREATE COMPOSITE DATABASE `garden`
319+
CYPHER 25 CREATE ALIAS `garden.flowers` FOR DATABASE `northwind-graph`
320+
----
321+
322+
.Error message
323+
[source, output, role="noheader"]
324+
----
325+
Cannot create database 'garden' because another database 'garden.flowers' exists with an ambiguous name.
326+
----
327+
The exception has GQLSTATUS code link:{neo4j-docs-base-uri}/status-codes/current/errors/gql-errors/42N87[42N87 - database or alias with similar name exists].
328+
======
329+
=====
330+
331+
332+
333+
[role=label--new-2025.06]
334+
=== Cypher 25 specific behaviour
335+
==== Accessing an existing alias with dots
336+
337+
Cypher 25 relies on the guarantee that no conflicting names are allowed in Neo4j 2025.06 and later.
338+
The following queries all act on the same alias, regardless of whether that alias is a composite constituent or not.
339+
The special quoting of separate name parts that is necessary in Cypher 5 is not permitted in Cypher 25.
340+
341+
.Parameters
342+
[source, javascript]
343+
----
344+
{
345+
"name": "my.garden.beautiful.flowers"
346+
}
347+
----
348+
.Query
349+
[source, cypher]
350+
----
351+
CYPHER 25 ALTER ALIAS `my.garden.beautiful.flowers` SET DATABASE PROPERTIES { perennial: true }
352+
CYPHER 25 ALTER ALIAS $name SET DATABASE PROPERTIES { perennial: true }
353+
CYPHER 25 USE `my.garden.beautiful.flowers` RETURN 1
354+
----
355+
356+
==== Creating a new alias with dots
357+
358+
During `CREATE`, Cypher 25 splits the given name on each dot, left to right, and checks if a corresponding composite database exists.
359+
If no composite database is found, Cypher 25 falls back to creating a regular non-composite alias.
360+
361+
For example:
362+
363+
.Query
364+
[source, cypher]
365+
----
366+
CYPHER 25 CREATE COMPOSITE DATABASE `my.garden`
367+
CYPHER 25 CREATE ALIAS `my.garden.beautiful.flowers` FOR DATABASE `northwind-graph`
368+
----
369+
370+
The query attempts to create the following aliases in the given order:
371+
372+
. Constituent alias `garden.beautiful.flowers` within composite database `my`.
373+
. Constituent alias `beautiful.flowers` within composite database `my.garden`.
374+
. Constituent alias `flowers` within composite database `my.garden.beautiful`.
375+
. Regular non-composite alias `my.garden.beautiful.flowers`.
376+
377+
When it finds the composite database `my.garden`, it creates the constituent alias `beautiful.flowers` within that composite.
378+
379+
380+
381+
=== Cypher 5 specific behaviour
382+
383+
==== Quoting database alias and composite database names
229384

230385
The composite database name and the database alias name need to be quoted individually.
231386
Backticks may be added regardless of whether the name contains special characters or not, so it is good practice to always backtick both names, e.g. `++`composite`++.++`alias`++`.
387+
[NOTE]
388+
====
389+
Separating composite database name and alias name with backticks is no longer supported in Cypher 25.
390+
See <<_cypher_25_specific_behaviour, Cypher 25 specific behaviour>> for details.
391+
====
232392

233393
The following example creates a database alias named `my alias with spaces` as a constituent in the composite database named `my-composite-database-with-dashes`:
234394

@@ -242,18 +402,18 @@ CREATE DATABASE `northwind-graph`;
242402
.Query
243403
[source, cypher]
244404
----
245-
CREATE ALIAS `my-composite-database-with-dashes`.`my alias with spaces` FOR DATABASE `northwind-graph`
405+
CYPHER 5 CREATE ALIAS `my-composite-database-with-dashes`.`my alias with spaces` FOR DATABASE `northwind-graph`
246406
----
247407

248408
When not quoted individually, a database alias with the full name `my alias with.dots and spaces` gets created instead:
249409

250410
.Query
251411
[source, cypher]
252412
----
253-
CREATE ALIAS `my alias with.dots and spaces` FOR DATABASE `northwind-graph`
413+
CYPHER 5 CREATE ALIAS `my alias with.dots and spaces` FOR DATABASE `northwind-graph`
254414
----
255415

256-
=== Handling multiple dots
416+
==== Handling multiple dots
257417

258418
//Examples where dots are not separators between composite name and alias name are impossible to test, because the right escaping cannot be inferred automatically.
259419

@@ -263,18 +423,20 @@ Though these always need to be quoted in order to avoid ambiguity with the compo
263423
.Query
264424
[source, cypher, role=test-skip]
265425
----
266-
CREATE ALIAS `my.alias.with.dots` FOR DATABASE `northwind-graph`
426+
CYPHER 5 CREATE ALIAS `my.alias.with.dots` FOR DATABASE `northwind-graph`
267427
----
268428

269429
.Query
270430
[source, cypher, role=test-skip]
271431
----
272-
CREATE ALIAS `my.composite.database.with.dots`.`my.other.alias.with.dots` FOR DATABASE `northwind-graph`
432+
CYPHER 5 CREATE ALIAS `my.composite.database.with.dots`.`my.other.alias.with.dots` FOR DATABASE `northwind-graph`
273433
----
274434

275-
276-
[role=label--deprecated]
277-
=== Single dots and local database aliases
435+
==== Single dots and local database aliases
436+
[NOTE]
437+
====
438+
As of Neo4j 2025.06, this feature is no longer deprecated.
439+
====
278440

279441
There is a special case for local database aliases with a single dot without any existing composite database.
280442
If a composite database `some` exists, the query below will create a database alias named `alias` within the composite database `some`.
@@ -283,10 +445,10 @@ If no such database exists, however, the same query will instead create a databa
283445
.Query
284446
[source, cypher]
285447
----
286-
CREATE ALIAS some.alias FOR DATABASE `northwind-graph`
448+
CYPHER 5 CREATE ALIAS some.alias FOR DATABASE `northwind-graph`
287449
----
288450

289-
=== Handling parameters
451+
==== Handling parameters
290452

291453
When using parameters, names cannot be quoted.
292454
When the given parameter includes dots, the first dot will be considered the divider for the composite database.
@@ -304,7 +466,7 @@ Consider the query with parameter:
304466
.Query
305467
[source, cypher]
306468
----
307-
CREATE ALIAS $aliasname FOR DATABASE `northwind-graph`
469+
CYPHER 5 CREATE ALIAS $aliasname FOR DATABASE `northwind-graph`
308470
----
309471

310472
If the composite database `mysimplecompositedatabase` exists, then a database alias `myalias` will be created in that composite database.
@@ -326,7 +488,7 @@ If `mycompositedatabase` does not exist, the command will create a database alia
326488

327489
In these cases, it is recommended to avoid parameters and explicitly quote the composite database name and alias name separately to avoid ambiguity.
328490

329-
=== Handling parameters
491+
==== Handling parameters
330492

331493
Further special handling with parameters is needed for database aliases and similarly named composite databases.
332494

@@ -335,8 +497,8 @@ Consider the setup:
335497
.Query
336498
[source, cypher, role="noheader test-skip"]
337499
----
338-
CREATE COMPOSITE DATABASE foo
339-
CREATE ALIAS `foo.bar` FOR DATABASE `northwind-graph`
500+
CYPHER 5 CREATE COMPOSITE DATABASE foo
501+
CYPHER 5 CREATE ALIAS `foo.bar` FOR DATABASE `northwind-graph`
340502
----
341503

342504
The alias `foo.bar` does not belong to the composite database `foo`.
@@ -354,7 +516,7 @@ Dropping this alias using parameters fails with an error about a missing alias:
354516
.Query
355517
[source, cypher, role=test-fail]
356518
----
357-
DROP ALIAS $aliasname FOR DATABASE
519+
CYPHER 5 DROP ALIAS $aliasname FOR DATABASE
358520
----
359521

360522
.Error message

modules/ROOT/pages/database-administration/aliases/naming-aliases.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ The following naming rules apply:
1010
* A name is a valid identifier.
1111
* Name length can be up to 65534 characters.
1212
* Names cannot end with dots.
13-
* Unquoted dots signify that the database alias belongs to a composite database, separating the composite database name and the alias name.
1413
* Names that begin with an underscore or with the prefix `system` are reserved for internal use.
1514
* Non-alphabetic characters, including numbers, symbols, dots, and whitespace characters, can be used in names, but must be quoted using backticks.
15+
* Dots (`.`) are interpreted as a delimiter between a composite database and a constituent alias name if a matching composite database exists.
16+
Otherwise, Neo4j interprets the dot as simply part of the database name.
1617
1718
The name restrictions and escaping rules apply to all the different database alias commands.
1819

1920
[NOTE]
2021
====
2122
Having dots (`.`) in the database alias names is not recommended.
2223
This is due to the difficulty of determining if a dot is part of the database alias name or a delimiter for a database alias in a composite database.
23-
For more details, see xref:database-administration/aliases/manage-aliases-composite-databases.adoc#alias-management-escaping[names and escaping for database aliases targeting composite databases].
24+
For more details, see xref:database-administration/aliases/manage-aliases-composite-databases.adoc#alias-management-escaping[database alias names that contain dots].
2425
====

modules/ROOT/pages/database-administration/composite-databases/list-composite-databases.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
////
77
[source, cypher, role=test-setup]
88
----
9-
CREATE COMPOSITE DATABASE `library`;
10-
CREATE DATABASE `sci-fi`;
11-
CREATE ALIAS `library`.`sci-fi` FOR DATABASE `sci-fi`;
9+
CYPHER 25 CREATE COMPOSITE DATABASE `library`;
10+
CYPHER 25 CREATE DATABASE `sci-fi`;
11+
CYPHER 25 CREATE ALIAS `library.sci-fi` FOR DATABASE `sci-fi`;
1212
----
1313
////
1414

modules/ROOT/pages/database-administration/composite-databases/querying-composite-databases.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ The examples featured in this section make use of the two Cypher clauses: link:{
1414

1515
The following set-up is required to recreate the examples on this page:
1616

17+
[.tabbed-example]
18+
====
19+
[role=include-with-cypher-5]
20+
=====
1721
.Create a standard database `movies2022`
1822
[source, cypher]
1923
----
@@ -42,6 +46,43 @@ CREATE ALIAS `cineasts`.`upcoming`
4246
USER neo4j
4347
PASSWORD 'password'
4448
----
49+
[NOTE]
50+
Cypher 5 is the version that is in use in Neo4j up to and including version 2025.05.
51+
For details, see xref:introduction.adoc#_cypher_versions[Cypher® versions].
52+
=====
53+
[role=include-with-cypher-25 label--new-2025.06]
54+
=====
55+
.Create a standard database `movies2022`
56+
[source, cypher]
57+
----
58+
CREATE DATABASE movies2022
59+
----
60+
61+
.Create a composite database `cineasts`
62+
[source, cypher]
63+
----
64+
CREATE COMPOSITE DATABASE cineasts
65+
----
66+
67+
.Create database alias `cineasts.latest` for a local database in a composite database
68+
[source, cypher]
69+
----
70+
CREATE ALIAS `cineasts.latest`
71+
FOR DATABASE movies2022
72+
----
73+
74+
.Create database alias `cineasts.upcoming` for a remote database in a composite database
75+
[source, cypher]
76+
----
77+
CREATE ALIAS `cineasts.upcoming`
78+
FOR DATABASE upcoming
79+
AT 'neo4j+s://location:7687'
80+
USER neo4j
81+
PASSWORD 'password'
82+
----
83+
=====
84+
====
85+
4586

4687
For more information about composite databases and database aliases in composite databases, see xref:database-administration/composite-databases/concepts.adoc[], and xref:database-administration/aliases/manage-aliases-composite-databases.adoc[].
4788

0 commit comments

Comments
 (0)