welcome!...
TRANSCRIPT
![Page 1: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/1.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Welcome!
Grab a USB key, and plug it in.
Find a seat. Say hi!11
22
Run the “Install Neo4j” application (Mac or Windows).
When you see the README and the command prompt, you’re ready.33
44Grab a coffee and get ready to begin!
![Page 2: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/2.jpg)
(you)-[:know]->(Neo4j)
© All Rights Reserved 2013 | Neo Technology, Inc.
TutorialNeo4j
with Stefan Armbruster@darthvader42
![Page 3: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/3.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Why did you come?
![Page 4: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/4.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Answer five questions
• What is Neo4j?
• Why would I use it?
• How do I model data?
• How do I enter data?
• How do I query data?
and...
![Page 5: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/5.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
provide the confidence to start building a graph enabled application
![Page 6: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/6.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Schedule• 8.30am - Registration, installation and breakfast
• 9.00am - Session 1: Graphs and Modeling
•10.30am - Morning coffee break
•10.45am - Session 2: Neo4j and Cypher
•12.00pm - Lunch
• 1.00pm - Session 3: Advanced queries using Cypher
• 2.30pm - Afternoon coffee break
• 2.45pm - Session 4: Next steps and Q&A
• 4.00pm - End of training
![Page 7: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/7.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Introduction to Graphs)
![Page 8: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/8.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
But first...an important message...
![Page 9: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/9.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Eating Brains
Dancing WithMichael Jackson
![Page 10: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/10.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Eating Brains
Dancing WithMichael Jackson
These are Charts!
NOT Graphs!
![Page 11: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/11.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Leonhard Euler 1707-1783
![Page 12: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/12.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Königsberg (Prussia) - 1736
AAAA
BBBB
DDDD
CCCC
![Page 13: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/13.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
AAAA
BBBB
DDDD
CCCC
![Page 14: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/14.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
AAAA
BBBB
DDDD
CCCC
1
2
3
4
7
6
5
![Page 15: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/15.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Apr 15th 2013:
Google DoodleL. Euler's birthday
![Page 16: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/16.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
So what about data?
![Page 17: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/17.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
AliceAliceAliceAlice
BobBobBobBob
Graph Databases BookGraph Databases BookGraph Databases BookGraph Databases Book
Friend Of
Friend Of
Has R
ead
Has Read
![Page 18: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/18.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
name: Alicename: Alice age: 38age: 38 name: Alicename: Alice age: 38age: 38
name: Bobname: Bob age: 34age: 34 name: Bobname: Bob age: 34age: 34
title: Graph Databasestitle: Graph Databasesauthors: Ian Robinson,authors: Ian Robinson, Jim WebberJim Webber
title: Graph Databasestitle: Graph Databasesauthors: Ian Robinson,authors: Ian Robinson, Jim WebberJim Webber
FRIEND_OFsince: 07/09/2011
HAS_READon: 10/03/2013rating: 5
HAS_READon: 03/02/2013rating: 4
FRIEND_OFsince: 07/09/2011
![Page 19: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/19.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Segue: Graphs in a Relational World
![Page 20: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/20.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Customers AccountsCustomer_Accounts
143 Alice326
$100
725$632
981$212
143 981
143 725
143 326
![Page 21: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/21.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Alice
$100
$632
$212
143326
725
981
143 981
143 725
143 326
![Page 22: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/22.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
name: Alice
bal: $100
bal: $632
bal: $212
Nodes
Relationships
owns
owns
owns
![Page 23: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/23.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Modeling with Graphs)
![Page 24: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/24.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Start with a whiteboard
![Page 25: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/25.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 26: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/26.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Adam
LOL Cat
FRIEND_OFSHARED
COMMENTED
SarahFUNNY
ON
LIKES
![Page 27: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/27.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Adam
LOL Cat
FRIEND_OFSHARED
COMMENTED
SarahFUNNY
ON
LIKES
![Page 28: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/28.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 29: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/29.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Tom Hanks Hugo Weaving
Cloud AtlasThe Matrix
LanaWachowski
ACTED_IN
ACTED_INACTED_IN
DIRECTED
DIRECTED
![Page 30: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/30.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Model Incrementally
![Page 31: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/31.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Tom Hanks Hugo Weaving
Cloud AtlasThe Matrix
LanaWachowski
ACTED_IN
ACTED_INACTED_IN
DIRECTED
DIRECTED
![Page 32: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/32.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
name: Tom Hanksnationality: USAwon: Oscar, Emmy
name: Hugo Weavingnationality: Australiawon: MTV Movie Award
title: Cloud Atlasgenre: drama, sci-fi
title: The Matrixgenre: sci-fi
name: Lana Wachowskinationality: USA
won: Razzie, Hugo
ACTED_INrole: Zachry
ACTED_INrole: Bill Smoke
DIRECTED
DIRECTED
ACTED_INrole: Agent Smith
![Page 33: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/33.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Coffee?
![Page 34: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/34.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Brief tour of Neo4j)
![Page 35: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/35.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
bin/neo4j neo4j itself
bin/neo4j-shell a command-line shell
conf/ configuration files
data/ graph data, logs
![Page 36: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/36.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
11./bin/neo4j start
22./bin/neo4j-shell < sample/movies.cyp
33start http://localhost:7474/
11bin\neo4j start
22java -jar gumdrop.jar --file sample\movies.cyp
Mac OS X
Windows
33open http://localhost:7474/
![Page 37: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/37.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
http://localhost:7474/
Neo4j Dashboard - for monitoring of key stats
![Page 38: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/38.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
http://localhost:7474/
Neo4j Data browser - to inspect or visualize data
![Page 39: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/39.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
http://localhost:7474/
Neo4j Console - for running commands and queries
![Page 40: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/40.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Introduction to Cypher)
![Page 41: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/41.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Cypher is Neo4j's graph query language
![Page 42: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/42.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
•Declarative Pattern-Matching language
•SQL-like syntax
•Designed for graphs
![Page 43: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/43.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
It’s all about Patterns
AA
BB CC
![Page 44: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/44.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 45: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/45.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 46: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/46.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
How?
![Page 47: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/47.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(a) --> (b)
aa bb
Two nodes, one relationship
![Page 48: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/48.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Two nodes, one relationship
START a=node(*)
MATCH (a)-->(b)
RETURN a, b;
aa bb
![Page 49: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/49.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
bb
aa
bb
aa
bb
aa
START a=node(*)
MATCH (a)-->(b)
RETURN a, b;
![Page 50: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/50.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(a) --> ()
aa
Two nodes, one relationship
![Page 51: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/51.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Two nodes, one relationship
START a=node(*)
MATCH (a)-->()
RETURN a;
aa
![Page 52: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/52.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Two nodes, one relationship
START a=node(*)
MATCH (a)-->()
RETURN a.name;
aa
![Page 53: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/53.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(a) -[r]-> ()
aa
Two nodes, one relationship
r
![Page 54: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/54.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Two nodes, one relationship
START a=node(*)
MATCH (a)-[r]->()
RETURN a.name, type(r);
aar
![Page 55: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/55.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(a) -[:ACTED_IN]-> (b)
aa bb
Two nodes, one relationship
ACTED IN
![Page 56: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/56.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Two nodes, one relationship
START a=node(*)
MATCH (a)-[:ACTED_IN]->(b)
RETURN a.name, b.title;
aa bbACTED IN
![Page 57: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/57.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Two nodes, one relationship
START a=node(*)
MATCH (a)-[r:ACTED_IN]->(b)
RETURN a.name, r.roles, b.title;
aa bbACTED IN
![Page 58: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/58.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
(a)-->(b)-->(c)
aa bb cc
![Page 59: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/59.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.bb
cc
aa
bb
cc
aa
bb
aa
(a)-->(b)-->(c)
![Page 60: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/60.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
(a)-->(b)-->(c)
aa bb cc
![Page 61: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/61.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
(a)-->(b)<--(c)
aa bb cc
![Page 62: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/62.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.cc
bb
aa
cc
bb
cc
bb
aa
aa(a)-->(b)<--(c)
![Page 63: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/63.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name, m.title, d.name;
aa
mmACTED IN
dd
DIRECTED
![Page 64: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/64.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name, m.title, d.name;
dd
mm
aa
dd
mm
dd
mm
aa
aa
![Page 65: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/65.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name, m.title, d.name;
a.name m.title d.name
“Keanu Reeves” “The Matrix” “Andy Wachowski”
“Keanu Reeves” “The Matrix Reloaded” “Andy Wachowski”
“Noah Wyle” “A Few Good Men” “Rob Reiner”
“Tom Hanks” “Cloud Atlas” “Andy Wachowski”
... ... ...
![Page 66: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/66.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name AS actor, m.title AS movie,
d.name AS director;
actor movie director
“Keanu Reeves” “The Matrix” “Andy Wachowski”
“Keanu Reeves” “The Matrix Reloaded” “Andy Wachowski”
“Noah Wyle” “A Few Good Men” “Rob Reiner”
“Tom Hanks” “Cloud Atlas” “Andy Wachowski”
... ... ...
![Page 67: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/67.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m), (m)<-[:DIRECTED]-(d)
RETURN a.name, m.title, d.name;
aa mmACTED IN
ddDIRECTED
mm
![Page 68: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/68.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m), (d)-[:DIRECTED]->(m)
RETURN a.name, m.title, d.name;
aa mmACTED IN
mmDIRECTED
dd
![Page 69: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/69.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH p=(a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN p;
aa
mmACTED IN
dd
DIRECTED
![Page 70: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/70.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH p=(a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN nodes(p);
aa
mmACTED IN
dd
DIRECTED
![Page 71: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/71.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Paths
START a=node(*)
MATCH p1=(a)-[:ACTED_IN]->(m), p2=(d)-[:DIRECTED]->(m)
RETURN p1, p2;
aa mmACTED IN
mmDIRECTED
dd
![Page 72: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/72.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Aggregation
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name, m.title, d.name;
a.name m.title d.name
“Keanu Reeves” “The Matrix” “Andy Wachowski”
“Keanu Reeves” “The Matrix Reloaded” “Andy Wachowski”
“Noah Wyle” “A Few Good Men” “Rob Reiner”
“Tom Hanks” “Cloud Atlas” “Andy Wachowski”
... ... ...
![Page 73: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/73.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Aggregation
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name, d.name, count(*);
a.name d.name count(*)
“Aaron Sorkin" “Rob Reiner” 2
“Keanu Reeves” “Andy Wachowski” 3
“Hugo Weaving” “Tom Tykwer” 1
... ... ...
![Page 74: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/74.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Aggregation
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name, d.name, count(m);
a.name d.name count(m)
“Aaron Sorkin" “Rob Reiner” 2
“Keanu Reeves” “Andy Wachowski” 3
“Hugo Weaving” “Tom Tykwer” 1
... ... ...
![Page 75: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/75.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
Which directors also acted in their movie?
START d=node(*)
MATCH (d)-[:DIRECTED]->(m)<-[:ACTED_IN]-(d)
RETURN d.name, m.title;
![Page 76: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/76.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Unique relationships in paths
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:ACTED_IN]-(a)
RETURN a.name, m.title;
![Page 77: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/77.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
START a=node(*)MATCH (a)-[:ACTED_IN]->(m)<-
[:DIRECTED]-(d)RETURN a.name, d.name, count(*)
AS count
ORDER BY(count) DESC
LIMIT 5;
Sort & Limit
![Page 78: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/78.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Aggregation
count(x) - add up the number of occurrencesmin(x) - get the lowest valuemax(x) - get the highest valueavg(x) - get the average of a numeric value
collect(x) - collected all the occurrences into an array
![Page 79: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/79.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Aggregation
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN a.name, d.name, collect(m.title);
aa
mmACTED IN
bb
ACTED IN
![Page 80: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/80.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Starting somewhere
![Page 81: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/81.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
All-nodes Query
START n=node(*) RETURN n;
START - clause for looking up starting points
node(*) - all nodes in the graph
RETURN n - clause to specify data to return
![Page 82: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/82.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Find a specific node (all-node query)
START n=node(*)
WHERE has(n.name) AND n.name = "Keanu Reeves"
RETURN n;
WHERE - filter the results
has(n.name) - the name property must exist
n.name = "Keanu Reeves" - and have that value
![Page 83: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/83.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
START n=node(*)
WHERE has(n.name) AND n.name = "Keanu Reeves"
RETURN n;
kk
![Page 84: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/84.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Find a specific node (auto-index query)
START keanu=node:node_auto_index(name="Keanu Reeves")
RETURN keanu;
![Page 85: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/85.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
START keanu=node:node_auto_index(name="Keanu Reeves")RETURN keanu;
kk
![Page 86: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/86.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Start with specific node (auto-indexed)
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->(movie)
RETURN movie.title;
(Movies featuring Keanu)
![Page 87: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/87.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
mm
mm
mm
kk
mm
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->(movie)
RETURN movie.title;
![Page 88: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/88.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Start with specific node (auto-indexed)
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->()<-[:DIRECTED]-(director)
RETURN director.name;
(Directors who worked with Keanu)
![Page 89: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/89.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
mm
mm
mm
kk
mm
dd
dd
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->()<-[:DIRECTED]-(director)
RETURN director.name;
![Page 90: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/90.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Start with specific node (auto-indexed)
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->()<-[:DIRECTED]-(director)
RETURN DISTINCT director.name;
(Directors who worked with Keanu)
![Page 91: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/91.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Start with multiple nodes (auto-indexed)
START keanu=node:node_auto_index(name="Keanu Reeves"),
al=node:node_auto_index(name="Al Pacino")
MATCH (keanu)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(al)
RETURN DISTINCT movie.title;
(Movies featuring both Keanu and Al Pacino)
![Page 92: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/92.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
START keanu=node:node_auto_index(name="Keanu Reeves"),
al=node:node_auto_index(name="Al Pacino")
MATCH (keanu)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(al)
RETURN DISTINCT movie.title;
mm
alal
kk
![Page 93: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/93.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Conditions
![Page 94: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/94.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Constraints on properties
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->(movie)
WHERE movie.released < 1980
RETURN DISTINCT movie.title;
(Movies in which Keanu acted, that were released before 1980)
![Page 95: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/95.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
mm
mm
mm
kk
mm
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->(movie)
WHERE movie.released < 1980
RETURN DISTINCT movie.title;
1995
1975
2003
1999
![Page 96: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/96.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Constraints on properties
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[r:ACTED_IN]->(movie)
WHERE "Neo" IN r.roles
RETURN DISTINCT movie.title;
(Movies in which Keanu played Neo)
![Page 97: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/97.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Constraints based on comparisons
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(n)
WHERE n.born < keanu.born
RETURN DISTINCT n.name;
(Actors who worked with Keanu and are older than he was)
![Page 98: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/98.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Constraints based on comparisons
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(n)
WHERE n.born < keanu.born
RETURN DISTINCT n.name, (keanu.born - n.born) AS diff;
(Actors who worked with Keanu and are older than he was)
![Page 99: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/99.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Constraints based on patterns
START gene=node:node_auto_index(name="Gene Hackman")
MATCH (gene)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(n)
RETURN DISTINCT n.name;
(Actors who worked with Gene Hackman)
![Page 100: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/100.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Actors who worked with Gene and were directors of their own films)
Constraints based on patterns
START gene=node:node_auto_index(name="Gene Hackman")
MATCH (gene)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(n)
WHERE (n)-[:DIRECTED]->()
RETURN DISTINCT n.name;
![Page 101: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/101.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Actors who worked with Keanu, but never worked with Hugo)
Constraints based on patterns
START keanu=node:node_auto_index(name="Keanu Reeves"),
hugo=node:node_auto_index(name="Hugo Weaving")
MATCH (keanu)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(n)
WHERE NOT((hugo)-[:ACTED_IN]->(movie))
RETURN DISTINCT n.name;
![Page 102: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/102.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
Who are the five busiest actors?
START a=node(*)
MATCH (a)-[:ACTED_IN]->(m)
RETURN a.name, count(m)
ORDER BY count(m) DESC
LIMIT 5;
![Page 103: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/103.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
ADVANCED LAB
Recommend 3 actors that Keanu Reeves should work with (but hasn’t).
START keanu=node:node_auto_index(name="Keanu
Reeves")MATCH (keanu)-[:ACTED_IN]->()<-[:ACTED_IN]-(c),
(c)-[:ACTED_IN]->()<-[:ACTED_IN]-(coc)WHERE
NOT((keanu)-[:ACTED_IN]->()<-[:ACTED_IN]-(coc))AND coc
<> keanuRETURN coc.name, count(coc)ORDER BY count(coc)
DESCLIMIT 3;
![Page 104: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/104.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Coffee? Lunch?
![Page 105: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/105.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
START kevin=node:node_auto_index(name="Kevin Bacon")
MATCH (kevin)-[:ACTED_IN]->(movie)
RETURN DISTINCT movie.title;
(Movies featuring Kevin Bacon)
![Page 106: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/106.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Updating Graphs with Cypher)
![Page 107: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/107.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Creating nodes
CREATE ({title:"Mystic River", released:1993});
START movie=node:node_auto_index(title="Mystic River")
RETURN movie;
![Page 108: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/108.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Adding properties
START movie=node:node_auto_index(title="Mystic River")
SET movie.tagline = "We bury our sins here, Dave. We wash them clean."
RETURN movie;
![Page 109: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/109.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Changing properties
START movie=node:node_auto_index(title="Mystic River")
SET movie.released = 2003
RETURN movie;
![Page 110: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/110.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Creating Relationships
START movie=node:node_auto_index(title="Mystic River"),
kevin=node:node_auto_index(name="Kevin Bacon")
CREATE UNIQUE (kevin)-[:ACTED_IN {roles:["Sean"]}]->(movie);
START kevin=node:node_auto_index(name="Kevin Bacon")
MATCH (kevin)-[:ACTED_IN]->(movie)
RETURN DISTINCT movie.title;
![Page 111: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/111.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
START movie=node:node_auto_index(title="Mystic River"),
kevin=node:node_auto_index(name="Kevin Bacon")
MATCH (kevin)-[r:ACTED_IN]->(movie)
SET r.roles = ["Sean Devine"]
RETURN r.roles;
Change Kevin Bacon’s role in Mystic Riverfrom “Sean” to “Sean Devine”
![Page 112: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/112.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
START movie=node:node_auto_index(title="Mystic River"),
kevin=node:node_auto_index(name="Kevin Bacon")
MATCH (kevin)-[r:ACTED_IN]->(movie)
SET r.roles = filter(n in r.roles : n <> "Sean") + "Sean Devine"
RETURN r.roles;
Change Kevin Bacon’s role in Mystic Riverfrom “Sean” to “Sean Devine”
![Page 113: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/113.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
Add Clint Eastwood as the director of Mystic River
START movie=node:node_auto_index(title="Mystic River"),
clint=node:node_auto_index(name="Clint Eastwood")
CREATE UNIQUE (clint)-[:DIRECTED]->(movie);
![Page 114: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/114.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
List all the characters in the movie “The Matrix”
START matrix=node:node_auto_index(title="The Matrix")
MATCH (matrix)<-[r:ACTED_IN]-()
RETURN r.roles;
![Page 115: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/115.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
START matrix=node:node_auto_index(title="The Matrix")
MATCH (matrix)<-[r:ACTED_IN]-(a)
WHERE "Emil" IN r.roles
RETURN a;
![Page 116: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/116.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Deleting nodes
START emil=node:node_auto_index(name="Emil Eifrem")
DELETE emil;
![Page 117: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/117.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Deleting relationships
START emil=node:node_auto_index(name="Emil Eifrem")
MATCH (emil)-[r]->()
DELETE r;
![Page 118: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/118.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Deleting nodes and relationships
START emil=node:node_auto_index(name="Emil Eifrem")
MATCH (emil)-[r]->()
DELETE r, emil;
![Page 119: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/119.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Deleting nodes and relationships
START emil=node:node_auto_index(name="Emil Eifrem")
MATCH (emil)-[r?]->()
DELETE r, emil;
![Page 120: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/120.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
Add KNOWS relationships between all actors who were in the same movie
START a=node(*)
MATCH (a)-[:ACTED_IN]->()<-[:ACTED_IN]-(b)
CREATE UNIQUE (a)-[:KNOWS]->(b);
![Page 121: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/121.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Coffee?
![Page 122: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/122.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(More Cypher)
![Page 123: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/123.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Matching multiple relationships
START a=node(*)
MATCH (a)-[:ACTED_IN|DIRECTED]->()<-[:ACTED_IN|DIRECTED]-(b)
CREATE UNIQUE (a)-[:KNOWS]->(b);
(Create KNOWS relationships between anyone, Actors or Directors, who worked together)
![Page 124: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/124.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Variable length paths
(a)-[*1..3]->(b)
aa bb
aa bb
aa bb
![Page 125: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/125.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Friends-of-Friends
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:KNOWS*2]->(fof)
RETURN DISTINCT fof.name;
![Page 126: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/126.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
Return Friends-of-Friends who are not immediate friends
START keanu=node:node_auto_index(name="Keanu Reeves")
MATCH (keanu)-[:KNOWS*2]->(fof)
WHERE NOT((keanu)-[:KNOWS]-(fof))
RETURN DISTINCT fof.name;
![Page 127: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/127.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Bacon Number!
START charlize=node:node_auto_index(name="Charlize Theron"),
bacon=node:node_auto_index(name="Kevin Bacon")
MATCH p=shortestPath((charlize)-[:KNOWS*]->(bacon))
RETURN length(rels(p));
![Page 128: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/128.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
LAB
Return the names of the people joining Charlize to Kevin.
START charlize=node:node_auto_index(name="Charlize Theron"),
bacon=node:node_auto_index(name="Kevin Bacon")
MATCH p=shortestPath((charlize)-[:KNOWS*]->(bacon))
RETURN extract(n in nodes(p) : n.name);
![Page 129: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/129.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Graphs are Everywhere)
Neo4j Case Studies
![Page 130: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/130.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 131: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/131.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 132: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/132.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 133: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/133.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 134: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/134.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 135: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/135.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 136: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/136.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 137: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/137.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 138: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/138.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 139: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/139.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 140: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/140.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 141: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/141.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 142: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/142.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 143: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/143.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 144: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/144.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
![Page 145: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/145.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(More about Neo4j)
![Page 146: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/146.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Neo4j offers three APIs:
1.Cypher for most work
2.REST for management
3.Plugin API for special cases
More about Neo4j Neo4j APIs
![Page 147: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/147.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
http://www.neo4j.org/develop/drivers
![Page 148: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/148.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Traverses 1,000,000+ relationships / second on commodity hardware
![Page 149: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/149.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Scale: 34 Bn nodes/relationships
![Page 150: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/150.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Licensing options
![Page 151: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/151.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Next steps)
![Page 152: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/152.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
The rise of the graph
![Page 153: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/153.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
It's not just social
![Page 154: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/154.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Find the graphs in your domain,and model them
![Page 155: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/155.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Get involved in the community
![Page 156: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/156.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
http://stackoverflow.com/questions/tagged/neo4j
![Page 157: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/157.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
http://groups.google.com/group/neo4j
![Page 158: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/158.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
https://github.com/neo4j/neo4j/issues
![Page 160: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/160.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
http://www.neo4j.org/participate/contributors#map
![Page 161: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/161.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
Contact us:[dirk.moeller|stefan.armbruster]@neotechnology.com
@Neo4j, @Neo4jDE
+49 800 723 6231
![Page 162: Welcome! [nosqlroadshow.com]nosqlroadshow.com/.../Presentations/neo4j_Stefan_Armbruster_Tutorial.pdf · Welcome! Grab a USB key, and plug it in. Find a seat. Say hi! 1 2 Run the “Install](https://reader036.vdocuments.net/reader036/viewer/2022070713/5ed2debfe4da3f772200d21d/html5/thumbnails/162.jpg)
© All Rights Reserved 2013 | Neo Technology, Inc.
(Thank You)•http://www.neo4j.org
•http://groups.google.com/group/neo4j
•http://www.neo4j.org/develop