10. What is Neo4j?
• A Graph Database
• A labelled property graph
• Nodes with properties and labels (both optional)
• Directed and named relationships with properties
(optional)
• ACID
• Schema free
• Scalable: Billions of nodes and relationships
• Fast: More than 2 million traversals per second
• Suited for highly connected and complex data
11. What is Neo4j
name:Neo
name: Agent
Smith
name:
Cypher
name:
Morpheus
name:TrinityLoves
Knows
Knows
{since: 1999}
Knows
Knows
Crew
Crew
Crew
Crew
MatrixMatrix
12. Cypher
• Declarative graph query language
• Based on English prose and neat
iconography
• Focuses on
• What to retrieve from the graph and not how to
retrieve it
• Pattern matching
• Your domain instead of database access
• Humane query language, suitable for
developers and operations professionals
13. Patterns and pictures
Neo Trinity
Loves
Neo loves Trinity
(Neo)-[:LOVES]->(Trinity)
Cypher
Agent
Smith
Knows
Cypher knows Agent Smith
(Cypher)-[:KNOWS]->(Agent Smith)
15. Example Query Structure
15
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
16. MATCH
• Allows you to specify patterns that Cypher
will search for in the graph
16
23. Order By, Limit
23
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
24. WITH
• Manipulate the result sequence before it is
passed on to the following query parts.
• The manipulations can be of the shape and/
or number of entries in the result set.
• Combines queries
24
27. What’s a Gist?
27
• A simple way to share snippets of code or
data
• Automatically versioned, forkable, usable
from Git
• Nicely rendered and presented
28. Okay, why?
• How do you share your graph model?
• Whiteboard?
• Document?
• How do you demonstrate queries?
• Need a live database?
• Modelling is incremental
28
29. What’s a GraphGist?
29
• An AsciiDoc file with:
• A graph domain model
• Descriptive text and pictures
• Example queries against the model
• Interactive and executable Cypher queries
• A Neo4j console for further exploration
• Nicely rendered and presented
30. GraphGist demos
• Trek and mountaineering routing
http://gist.neo4j.org/?09520d20fbe707951e1b
@shantaramw
• Organization learning
http://gist.neo4j.org/?8021754
@luannem
• Doctor Finder
http://gist.neo4j.org/?8748719
@fbiville
• Bombay Railway Routes
http://gist.neo4j.org/?8159102
@luannem 30