Skip to content

Instantly share code, notes, and snippets.

@cleishm
Forked from quagly/OneRelationship
Last active December 27, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleishm/7313355 to your computer and use it in GitHub Desktop.
Save cleishm/7313355 to your computer and use it in GitHub Desktop.
= graphGist generated from spock test Neo4jCypherOneRelationship.groovy
graphGist asciiDoc file for use at http://gist.neo4j.org/ [GitHub Gist]
Generated on Mon Jul 29 07:11:04 PDT 2013
//console
query to create plato with philosopher label
[source,cypher]
----
CREATE (n:Philosopher { name : 'Plato' , url : 'http://dbpedia.org/resource/Plato' })
----
//table
query to create Aristotle with philosopher label
[source,cypher]
----
CREATE (n:Philosopher { name : 'Aristotle' , url : 'http://dbpedia.org/resource/Aristotle' })
----
//table
query to get Aristotle and Plato and create influenced relationship
[source,cypher]
----
MATCH (p:Philosopher), (a:Philosopher)
WHERE p.name = 'Plato' AND a.name = 'Aristotle'
CREATE p-[r:INFLUENCED]->a
RETURN r
----
//table
query to delete INFLUENCED relationship between Aristotle and Plato
[source,cypher]
----
MATCH (p:Philosopher)-[r:INFLUENCED]->(a:Philosopher)
WHERE p.name = 'Plato' AND a.name = 'Aristotle'
DELETE r
----
//table
query to delete all philosopher Nodes
[source,cypher]
----
MATCH (p:Philosopher)
DELETE p
----
//table
query to create Plato influenced Aristotle in one statement
[source,cypher]
----
CREATE path = (p:Philosopher {name:'Plato', url : 'http://dbpedia.org/resource/Plato' })
-[:INFLUENCES]->
( a:Philosopher { name : 'Aristotle' , url : 'http://dbpedia.org/resource/Aristotle' })
----
//table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment