Upcoming SlideShare
×

# Intro to Mutating Cypher

• 1,796 views

• Comment goes here.
Are you sure you want to
Be the first to comment
Be the first to like this

Total Views
1,796
On Slideshare
0
From Embeds
0
Number of Embeds
1

Shares
34
0
Likes
0

No embeds

### Report content

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

• 1. Cypher Query Language Chicago Graph Database Meet-Up Max De Marzi
• 2. What is Cypher?• Graph Query Language for Neo4j• Aims to make querying simple
• 3. Design Decisions Pattern matching A B C
• 4. Design Decisions Pattern matching
• 5. Design Decisions Pattern matching
• 6. Design Decisions Pattern matching
• 7. Design Decisions Pattern matching
• 8. Design Decisions ASCII-art patterns () --> ()
• 9. Design Decisions Directed relationship A B (A) --> (B)
• 10. Design Decisions Undirected relationship A B (A) -- (B)
• 11. Design Decisions specific relationships LOVES A B A -[:LOVES]-> B
• 12. Design Decisions Joined paths A B C A --> B --> C
• 13. Design Decisions multiple paths A B C A --> B --> C, A --> C A --> B --> C <-- A
• 14. Design Decisions Variable length paths A B A B A B ... A -[*]-> B
• 15. Design Decisions Optional relationships A B A -[?]-> B
• 16. Mutating Cypher New in Neo4j 1.8
• 17. Create NodesCREATE turtle1 = {name : Donatello}, turtle2 = {name : ‘Michelangelo}, Cypher turtle3 = {name : ‘Raphael}, turtle4 = {name : ‘Leonardo} The Ninja Turtles
• 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. Delete NodesSTART  s = node:nodes(name = ‘Shredder’)DELETE s Cypher Shredder is defeated
• 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. Delete PropertiesSTART t2 = node(2)DELETE t2.hungry Cypher Michelangelo nom nom nom
• 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. 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. Questions?maxdemarzi.com