You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Testing] Make a few more examples testable (#499)
I removed a few `test-skip` here and there, and removed some useless
attributes from code blocks where I was editing already.
Also added some comments on why some examples need to be skipped.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/clauses/merge.adoc
+26-25Lines changed: 26 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
== Introduction
8
8
9
9
The `MERGE` clause either matches existing node patterns in the graph and binds them or, if not present, creates new data and binds that.
10
-
In this way, it acts as a combination of `MATCH` and `CREATE` that allows for specific actions depending on whether the specified data was matched or created.
10
+
In this way, it acts as a combination of `MATCH` and `CREATE` that allows for specific actions depending on whether the specified data was matched or created.
11
11
12
12
For example, `MERGE` can be used to specify that a graph must contain a node with a `Person` label and a specific `name` property.
13
13
If there isn't a node with the specific `name` property, a new node will be created with that `name` property.
@@ -80,7 +80,7 @@ RETURN robert, labels(robert)
80
80
A new node is created because there are no nodes labeled `Critic` in the database:
Note that in order to match or create a relationship when using `MERGE`, at least one bound node must be specified, which is done via the `MATCH` clause in the above example.
@@ -402,7 +402,7 @@ As `'Charlie Sheen'` and `'Michael Douglas'` both have a chauffeur with the same
402
402
This is in contrast to the example shown above in xref::clauses/merge.adoc#merge-merge-on-a-relationship-between-two-existing-nodes[Merge on a relationship between two existing nodes], where the first `MERGE` was used to bind the `Location` nodes and to prevent them from being recreated (and thus duplicated) on the second `MERGE`.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/introduction/cypher_overview.adoc
+23-14Lines changed: 23 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,30 @@
2
2
= Overview
3
3
:description: This section provides an overview of Cypher and its key differences compared to SQL.
4
4
5
-
This section provides an overview of Cypher and a brief discussion of how Cypher differs to SQL.
5
+
This section provides an overview of Cypher and a brief discussion of how Cypher differs to SQL.
6
+
7
+
////
8
+
[source, cypher, role=test-setup]
9
+
----
10
+
MERGE (matrix:Movie {title: 'The Matrix', rating: 10})
11
+
MERGE (keanu:Person {name: 'Keanu Reeves'})
12
+
MERGE (keanu)-[:ACTED_IN]->(matrix)
13
+
----
14
+
////
6
15
7
16
== What is Cypher?
8
17
9
-
Cypher is Neo4j’s declarative graph query language.
10
-
It was created in 2011 by Neo4j engineers as an SQL-equivalent language for graph databases.
18
+
Cypher is Neo4j’s declarative graph query language.
19
+
It was created in 2011 by Neo4j engineers as an SQL-equivalent language for graph databases.
11
20
Similar to SQL, Cypher lets users focus on _what_ to retrieve from graph, rather than _how_ to retrieve it.
12
21
As such, Cypher enables users to realize the full potential of their property graph databases by allowing for efficient and expressive queries that reveal previously unknown data connections and clusters.
13
22
14
-
Cypher provides a visual way of matching patterns and relationships.
23
+
Cypher provides a visual way of matching patterns and relationships.
15
24
It relies on the following ascii-art type of syntax: `(nodes)-[:CONNECT_TO]->(otherNodes)`.
16
-
Rounded brackets are used for circular nodes, and `-[:ARROWS]->` for relationships.
17
-
Writing a query is effectively like drawing a pattern through the data in the graph.
25
+
Rounded brackets are used for circular nodes, and `-[:ARROWS]->` for relationships.
26
+
Writing a query is effectively like drawing a pattern through the data in the graph.
18
27
In other words, entities such as nodes and their relationships are visually built into queries.
19
-
This makes Cypher a highly intuitive language to both read and write.
28
+
This makes Cypher a highly intuitive language to both read and write.
20
29
21
30
== Cypher and SQL: key differences
22
31
@@ -27,8 +36,8 @@ However, there are some important differences between the two:
27
36
*Cypher is schema-flexible*::
28
37
29
38
While it is both possible and advised to enforce partial schemas using xref:constraints/index.adoc[indexes and constraints], Cypher and Neo4j offers a greater degree of schema-flexibility than SQL and a relational database.
30
-
More specifically, nodes and relationships in a Neo4j database do not have to have a specific property set to them because other nodes or relationships in the same graph have that property (unless there is an xref:constraints/examples.adoc#constraints-examples-node-property-existence[existence constraint created on that specific property]).
31
-
This means that users are not required to use a fixed schema to represent data and that they can add new attributes and relationships as their graphs evolve.
39
+
More specifically, nodes and relationships in a Neo4j database do not have to have a specific property set to them because other nodes or relationships in the same graph have that property (unless there is an xref:constraints/examples.adoc#constraints-examples-node-property-existence[existence constraint created on that specific property]).
40
+
This means that users are not required to use a fixed schema to represent data and that they can add new attributes and relationships as their graphs evolve.
32
41
33
42
*Query order*::
34
43
@@ -41,11 +50,11 @@ FROM movie
41
50
WHERE movie.rating > 7
42
51
----
43
52
+
44
-
[source, cypher, role=test-skip]
53
+
[source, cypher]
45
54
----
46
55
MATCH (movie:Movie)
47
56
WHERE movie.rating > 7
48
-
RETURN movie.name
57
+
RETURN movie.title
49
58
----
50
59
51
60
*Cypher queries are more concise*::
@@ -62,15 +71,15 @@ FROM actors
62
71
WHERE movies.title = "The Matrix"
63
72
----
64
73
+
65
-
[source, cypher, role=test-skip]
74
+
[source, cypher]
66
75
----
67
76
MATCH (actor:Actor)-[:ACTED_IN]->(movie:Movie {title: 'The Matrix'})
68
77
RETURN actor.name
69
78
----
70
79
71
80
== Cypher and APOC
72
81
73
-
Neo4j supports the APOC (Awesome Procedures on Cypher) Core library.
82
+
Neo4j supports the APOC (Awesome Procedures on Cypher) Core library.
74
83
The APOC Core library provides access to user-defined procedures and functions which extend the use of the Cypher query language into areas such as data integration, graph algorithms, and data conversion.
75
84
76
-
For more details, visit the link:{neo4j-docs-base-uri}/apoc/{page-version}[APOC Core page].
85
+
For more details, visit the link:{neo4j-docs-base-uri}/apoc/{page-version}[APOC Core page].
0 commit comments