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
Copy file name to clipboardExpand all lines: modules/ROOT/pages/cypher/updating.adoc
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ image::update-graph.svg[All nodes added to the graph,width=500]
62
62
63
63
== Add a property to a node
64
64
65
-
If you want to add a birthday for the person named Jennifer, you can use this query:
65
+
If you want to add a birthday for the person named Jennifer, you can add this information as a _property_ with this query:
66
66
67
67
[source, cypher]
68
68
--
@@ -71,7 +71,7 @@ SET p.birthdate = date('1980-01-01')
71
71
RETURN p
72
72
--
73
73
74
-
What this query does is:
74
+
This query does the following:
75
75
76
76
. Find Jennifer's node with the `MATCH` clause.
77
77
. Use `SET` to create the new property `birthday` (with syntax `variable.property`) and set its value.
@@ -90,7 +90,7 @@ This is the tabular result:
90
90
91
91
== Update a property
92
92
93
-
To change Jennifer's birthdate, you can use the same query from the previous example to find Jennifer's node again, and then add a different date with the `SET` clause:
93
+
To change Jennifer's birthdate, you can use the same query from the previous example to find Jennifer's node again, and change the property value by adding a different date with the `SET` clause:
94
94
95
95
[source, cypher]
96
96
--
@@ -157,10 +157,10 @@ This is the result:
157
157
158
158
== Delete a relationship
159
159
160
-
You can use the `DELETE` clause for deleting both relationships and nodes.
160
+
You can use the `DELETE` clause to delete both relationships and nodes.
161
161
However, because Neo4j is ACID-compliant, you cannot delete a node if it still has relationships.
162
162
163
-
Therefore, if you want to xref:cypher/updating.adoc#_delete_a_node[delete a node], for example, Jennifer's node, you need to first delete the relationships appended to it:
163
+
Therefore, if you want to xref:cypher/updating.adoc#_delete_a_node[delete a node], for example Jennifer's node, you need to first delete the relationships appended to it:
164
164
165
165
[source,cypher]
166
166
--
@@ -199,7 +199,7 @@ The result is the following message: "Deleted 1 node, deleted 2 relationships".
199
199
== Add new data
200
200
201
201
If you want to add new data to your graph, it's important to avoid duplication.
202
-
For example, if you want to create a node that already exists in the graph using `CREATE`:
202
+
For example, if you try to create a node that already exists in the graph using `CREATE`:
203
203
204
204
[source, cypher]
205
205
--
@@ -291,8 +291,7 @@ RETURN j, r, m
291
291
----
292
292
293
293
`MATCH` finds both Mark and Jennifer's node before `MERGE` (finds or) creates the relationship between them.
294
-
This time, it's better not to use `CREATE` optionally because, if you run the statement again, it will duplicate the `IS_FRIENDS_WITH` relationship, but not the nodes.
295
-
Therefore, it is recommended to use `MERGE` to avoid such scenarios.
294
+
You can use `CREATE` for the relationship, but you would then risk creating a duplicate relationship (if it already exists).
296
295
297
296
Since this relationship didn't exist after xref:cypher/updating.adoc#_delete_a_node_and_its_relationships[Mark's node and appended relationships] were deleted, the result is a newly created relationship:
0 commit comments