0
Cypher Query Language    Chicago Graph Database Meet-Up             Max De Marzi
What is Cypher?• Graph Query Language for Neo4j• Aims to make querying simple
Design Decisions Pattern matching                       A                   B       C
Design Decisions Pattern matching
Design Decisions Pattern matching
Design Decisions Pattern matching
Design Decisions Pattern matching
Design Decisions ASCII-art patterns           () --> ()
Design Decisions Directed relationship             A           B        (A) --> (B)
Design Decisions Undirected relationship             A             B         (A) -- (B)
Design Decisions specific relationships                   LOVES             A             B          A -[:LOVES]-> B
Design Decisions Joined paths      A            B   C     A --> B --> C
Design Decisions multiple paths                       A                   B       C     A --> B --> C, A --> C      A --> ...
Design Decisions Variable length paths             A           B         A                   B  A                         ...
Design Decisions Optional relationships             A            B         A -[?]-> B
Mutating Cypher    New in Neo4j 1.8
Create NodesCREATE turtle1 = {name : Donatello},       turtle2 = {name : ‘Michelangelo},    Cypher       turtle3 = {name :...
Create RelationshipsSTART t1 = node(1), t2 = node(2),     t3 = node(3), t4 = node(4)CREATE s = {name: ‘Splinter’ },       ...
Delete NodesSTART  s = node:nodes(name = ‘Shredder’)DELETE s                                      Cypher                  ...
Update PropertiesSTART t1 = node(0), t2 = node(2)SET t1.weapon = ‘Bo Staff’, t2.hungry = ‘Yes’   Cypher                   ...
Delete PropertiesSTART t2 = node(2)DELETE t2.hungry            Cypher                     Michelangelo nom nom nom
Using RelateSTART turtles = node(1,2,3,4)RELATE turtles-[r:LOVE]->pizza        Cypher                                 The ...
Using Relate againSTART turtles = node(1,2,3,4)RELATE turtles-[r:LOVE]-(pizza        Cypher{name:’Supreme’})              ...
Questions?maxdemarzi.com
Upcoming SlideShare
Loading in...5
×

Intro to Mutating Cypher

1,930

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,930
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
38
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • There existed a number of different ways to query a graph database. This one aims to make querying easy, and to produce queries that are readable. We looked at alternatives - SPARQL, SQL, Gremlin and other...
  • Transcript of "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
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×