***** Queries in Cypher ***** ===== Creates a Dinosaur node with properties CREATE (:Dinosaur { id: "MNHN 1912.20", size: "9" }) ===== Create a Species node with properties CREATE (:Species { id: "Triceratops horridus" }) ===== Create a Place node with properties CREATE (:Place {id: "Lance Creek" }) ===== Finds (matches) the previous Dinosaur and Place nodes and connect them ===== through a Found edge MATCH (dn) WHERE dn.id = "MNHN 1912.20" MATCH (pl) WHERE pl.id = "Lance Creek" CREATE (dn)-[:Found]->(pl) ===== Creates a node three nodes (a Dinosaur, a Species and a PLace) and connect them CREATE (mn:Dinosaur { id: "MNHN 1912.20", size: "9" }), (th:Species { id: "Triceratops horridus" }), (pl:Place {id: "Lance Creek" }), (mn)-[:Is_a {recognized:1889}]->(th), (mn)-[:Found]->(pl) ===== Looks for any two nodes connected through a Found edge and delete the nodes and the edge MATCH (dn)-[edg:Found]->(pl) DELETE edg DELETE dn DELETE pl ===== Finds a node whose id is "Triceratops horridus" and deletes it MATCH (sp) WHERE sp.id = "Triceratops horridus" DELETE sp ===== Returns the id of Species found in Lance Creek MATCH (y)-[:Is_a]->(x) MATCH (y)-[:Found]->(p) WHERE p.id="Lance Creek" RETURN x.id ===== Returns the id of Species of Dinosaurs found in Lance Creek MATCH (y:Dinosaur)-[:Is_a]->(x:Species) MATCH (y)-[:Found]->(p:Place) WHERE p.id="Lance Creek" RETURN x.id ===== Creates a Dinosaur nodes CREATE (d:Dinosaur {id: "JGF111"}) ===== Connects the Dinosaur node to a Species node MATCH (d) WHERE d.id="JGF111" MATCH (s) WHERE s.id="Triceratops horridus" CREATE (d)-[:Is_a]->(s) ===== Returns all nodes which is a Triceratops Horridus MATCH (d)-[:Is_a]->(s) MATCH (s) WHERE s.id="Triceratops horridus" RETURN d.id ===== Creates a chain of Place nodes, each one is part of the next MATCH (pl1:Place) WHERE pl1.id = "Lance Creek" CREATE (pl2:Place {id: "Converse conty"}), (pl3:Place {id: "Wyoming"}), (pl4:Place {id: "USA"}), (pl1)-[:Part_of]->(pl2), (pl2)-[:Part_of]->(pl3), (pl3)-[:Part_of]->(pl4) ===== Lists all Places connected by any number of edges to a Place node USA MATCH (pl:Place)-[*]->(pl2:Place) WHERE pl2.id="USA" RETURN pl.id ===== List all Dinosaurs Found in a Place which is part of USA ===== (connected by any number of edges) MATCH (dn:Dinosaur)-[:Found]->(pl:Place) MATCH (pl)-[:Part_of*]->(pl2:Place) WHERE pl2.id="USA" RETURN dn.id ===== List all Dinosaurs Found in a Place which is part of USA ===== (connected by 0 to 5 edges) MATCH (dn:Dinosaur)-[:Found]->(pl:Place) MATCH (pl)-[:Part_of*0..5]->(pl2:Place) WHERE pl2.id="USA" RETURN dn.id ===== List all Dinosaurs Found in a Place which is part of USA ===== (connected by 0 to any number of edges) MATCH (dn:Dinosaur)-[:Found]->(pl:Place) MATCH (pl)-[:Part_of*0..]->(pl2:Place) WHERE pl2.id="USA" RETURN dn.id