Successfully reported this slideshow.

Intro to Mutating Cypher

2,665 views

Published on

  • Be the first to comment

Intro to Mutating Cypher

  1. 1. Cypher Query Language Chicago Graph Database Meet-Up Max De Marzi
  2. 2. What is Cypher?• Graph Query Language for Neo4j• Aims to make querying simple
  3. 3. Design Decisions Pattern matching A B C
  4. 4. Design Decisions Pattern matching
  5. 5. Design Decisions Pattern matching
  6. 6. Design Decisions Pattern matching
  7. 7. Design Decisions Pattern matching
  8. 8. Design Decisions ASCII-art patterns () --> ()
  9. 9. Design Decisions Directed relationship A B (A) --> (B)
  10. 10. Design Decisions Undirected relationship A B (A) -- (B)
  11. 11. Design Decisions specific relationships LOVES A B A -[:LOVES]-> B
  12. 12. Design Decisions Joined paths A B C A --> B --> C
  13. 13. Design Decisions multiple paths A B C A --> B --> C, A --> C A --> B --> C <-- A
  14. 14. Design Decisions Variable length paths A B A B A B ... A -[*]-> B
  15. 15. Design Decisions Optional relationships A B A -[?]-> B
  16. 16. Mutating Cypher New in Neo4j 1.8
  17. 17. Create NodesCREATE turtle1 = {name : Donatello}, turtle2 = {name : ‘Michelangelo}, Cypher turtle3 = {name : ‘Raphael}, turtle4 = {name : ‘Leonardo} The Ninja Turtles
  18. 18. Create RelationshipsSTART t1 = node(1), t2 = node(2), t3 = node(3), t4 = node(4)CREATE s = {name: ‘Splinter’ }, t1-[r:DISCIPLE]->s, Cypher t2-[r:DISCIPLE]->s, t3-[r:DISCIPLE]->s, t4-[r:DISCIPLE]->s The Ninja Turtles are disciples of Splinter
  19. 19. Delete NodesSTART  s = node:nodes(name = ‘Shredder’)DELETE s Cypher Shredder is defeated
  20. 20. Update PropertiesSTART t1 = node(0), t2 = node(2)SET t1.weapon = ‘Bo Staff’, t2.hungry = ‘Yes’ Cypher Donatello uses the Bo Staff Michelangelo is always hungry
  21. 21. Delete PropertiesSTART t2 = node(2)DELETE t2.hungry Cypher Michelangelo nom nom nom
  22. 22. Using RelateSTART turtles = node(1,2,3,4)RELATE turtles-[r:LOVE]->pizza Cypher The Ninja Turtles love pizza A pizza node and 4 relationships are created
  23. 23. Using Relate againSTART turtles = node(1,2,3,4)RELATE turtles-[r:LOVE]-(pizza Cypher{name:’Supreme’}) The Ninja Turtles love pizza A pizza node with name “Supreme” and 4 relationships are created
  24. 24. Questions?maxdemarzi.com

×