SlideShare a Scribd company logo
Exploring the Cypher Query
Language through GraphGists
Luanne Misquitta

@luannem
Our Path
Neo4j Cypher ExamplesGraphGists
What if…
Credit: Shantaram Waingankar
Or
Credit: Luanne M.
Or
Credit: Florent Biville
Or
6
Credit: Luanne M.
All you need is…
According to The Beatles
But that’s not why you’re here
What you really need is… a Graph
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
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
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
Patterns and pictures
Neo Trinity
Loves
Neo loves Trinity
(Neo)-[:LOVES]->(Trinity)
Cypher
Agent
Smith
Knows
Cypher knows Agent Smith
(Cypher)-[:KNOWS]->(Agent Smith)
Pattern matching
14
MATCH
(me:User {name:’Luanne’})-[f:FRIEND_OF]->(friend)-[:LISTENS_TO]->(artist)!
WHERE NOT (me-[:LISTENS_TO]->(artist) AND f.similarity>0.7!
RETURN artist
Luanne
The
Beatles
F1
Aerosmith
F2
Pink
Floyd
FRIEND_OF
{similarity=0.9}
FRIEND_OF
{similarity=0.4}
LISTENS_TO
LISTENS_TO
LISTENS_TOLISTENS_TO
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
MATCH
• Allows you to specify patterns that Cypher
will search for in the graph
16
Match
17
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
Where
• Filters the results
• Adds constraints to the pattern described in
MATCH
18
Where
19
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
Return
• Returns results
20
Return
21
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
Order By, Limit
• Sort the output
• Return a subset
22
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
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
With
25
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
GraphGists
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
Okay, why?
• How do you share your graph model?
• Whiteboard?
• Document?
• How do you demonstrate queries? 
• Need a live database?
• Modelling is incremental
28
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
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
Resources
32
Neo4j
http://www.neo4j.org/
!
Explore and create your own GraphGist
http://www.neo4j.org/learn/graphgist
!
Online Training
http://www.neo4j.org/learn/online_course
Spreading Graph Love
Exploring cypher with graph gists

More Related Content

Similar to Exploring cypher with graph gists

Neo4j Data Science Presentation
Neo4j Data Science PresentationNeo4j Data Science Presentation
Neo4j Data Science Presentation
Max De Marzi
 
Bill howe 8_graphs
Bill howe 8_graphsBill howe 8_graphs
Bill howe 8_graphs
Mahammad Valiyev
 
More than Words: Advancing Prosodic Analysis
More than Words: Advancing Prosodic AnalysisMore than Words: Advancing Prosodic Analysis
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large Graphs
Nishant Gandhi
 
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeSIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
Electronic Arts / DICE
 
Hands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4jHands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4j
Serendio Inc.
 
DiscoRank: optimizing discoverability on SoundCloud
DiscoRank: optimizing discoverability on SoundCloudDiscoRank: optimizing discoverability on SoundCloud
DiscoRank: optimizing discoverability on SoundCloud
Amélie Anglade
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 
Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...
Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...
Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...
Paul Leclercq
 
The 2nd graph database in sv meetup
The 2nd graph database in sv meetupThe 2nd graph database in sv meetup
The 2nd graph database in sv meetup
Joshua Bae
 
Introduction to Graph Database
Introduction to Graph DatabaseIntroduction to Graph Database
Introduction to Graph Database
Eric Lee
 
RDA for Music: Scores
RDA for Music: ScoresRDA for Music: Scores
RDA for Music: Scores
ALATechSource
 
DrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & EffectsDrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & Effects
Shawn Villaron
 
Extend R with C!!!
Extend R with C!!!Extend R with C!!!
Extend R with C!!!mickey24
 
Selections from rda in action
Selections from rda in actionSelections from rda in action
Selections from rda in actionBeth Thornton
 
The Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier LeagueThe Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier LeagueMark Needham
 
DotDash3CaseStudy
DotDash3CaseStudyDotDash3CaseStudy
DotDash3CaseStudy
Roxanne Mustafa
 

Similar to Exploring cypher with graph gists (17)

Neo4j Data Science Presentation
Neo4j Data Science PresentationNeo4j Data Science Presentation
Neo4j Data Science Presentation
 
Bill howe 8_graphs
Bill howe 8_graphsBill howe 8_graphs
Bill howe 8_graphs
 
More than Words: Advancing Prosodic Analysis
More than Words: Advancing Prosodic AnalysisMore than Words: Advancing Prosodic Analysis
More than Words: Advancing Prosodic Analysis
 
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large Graphs
 
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's EdgeSIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
 
Hands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4jHands on Training – Graph Database with Neo4j
Hands on Training – Graph Database with Neo4j
 
DiscoRank: optimizing discoverability on SoundCloud
DiscoRank: optimizing discoverability on SoundCloudDiscoRank: optimizing discoverability on SoundCloud
DiscoRank: optimizing discoverability on SoundCloud
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...
Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...
Analyze one year of radio station songs aired with Spark SQL, Spotify, and Da...
 
The 2nd graph database in sv meetup
The 2nd graph database in sv meetupThe 2nd graph database in sv meetup
The 2nd graph database in sv meetup
 
Introduction to Graph Database
Introduction to Graph DatabaseIntroduction to Graph Database
Introduction to Graph Database
 
RDA for Music: Scores
RDA for Music: ScoresRDA for Music: Scores
RDA for Music: Scores
 
DrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & EffectsDrawingML Subject: Shape Properties & Effects
DrawingML Subject: Shape Properties & Effects
 
Extend R with C!!!
Extend R with C!!!Extend R with C!!!
Extend R with C!!!
 
Selections from rda in action
Selections from rda in actionSelections from rda in action
Selections from rda in action
 
The Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier LeagueThe Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier League
 
DotDash3CaseStudy
DotDash3CaseStudyDotDash3CaseStudy
DotDash3CaseStudy
 

Recently uploaded

Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 

Recently uploaded (20)

Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 

Exploring cypher with graph gists