Intro to Cypher
August 2017William Lyon
@lyonwj
William Lyon
Developer Relations Engineer @neo4j
will@neo4j.com
@lyonwj
lyonwj.com
Agenda - Introduction To Cypher
• Neo4j Overview
• Cypher Overview
• Hands On Intro To Cypher
• Resources
• Q&A
neo4j.com/developer
Neo4j Graph Database
https://offshoreleaks.icij.org/pages/database
https://arxiv.org/pdf/1004.1001.pdf
What is Cypher?
Declarative
Query
Language
openCypher
Graph
Pattern
Matching
Bolt /
Drivers
Human
Readable
What is Cypher?
Declarative
Query
Language
• What data we want, not
how
What is Cypher?
Graph
Pattern
Matching
(node)-[:RELATIONSHIP]->(node)
• What data we want, not
how
• Expressiveness
What is Cypher?
Graph
Pattern
Matching
(node {key: value})-[:RELATIONSHIP]->(node)
• What data we want, not
how
• Expressiveness
What is Cypher?
Graph
Pattern
Matching
(node {key: value})-[:RELATIONSHIP*..2]->(node)
• What data we want, not
how
• Expressiveness
What is Cypher?
Human
Readable
(node)-[:RELATIONSHIP]->(node)
• Focus on domain, not
database
What is Cypher?
openCypher
• Open standard for graph
querying
http://www.opencypher.org/
What is Cypher?
Bolt /
Drivers
• Binary protocol for Neo4j
What is Cypher?
Bolt /
Drivers
• Language Drivers
What is Cypher?
Bolt /
Drivers
What is Cypher?
Bolt /
Drivers
Querying The Graph
The Data
https://www.yelp.com/dataset_challenge
Yelp Data Challenge In Neo4j
https://github.com/johnymontana/neo4j-datasets/tree/master/yelp
“Working With A Real-World Dataset In Neo4j”
https://youtu.be/oXziS-PPIUA
Graph Data Model
Labeled Property Graph Model
Labeled Property Graph Model
The Data
user.json business.json review.json
Our Data Model
http://www.apcjones.com/arrows/#
• Identify “entities”
• What properties are
relevant?
• Identify unique ids
• Find connections
• Repeat
The Graph
Querying The Graph
What Breweries Near Me That My Friends
Also Like Have The Highest Rating?
What Breweries Near Me That My Friends
Also Like Have The Highest Rating?
What Breweries Near Me That My Friends
Also Like Have The Highest Rating?
• MATCH …
• (node)-[:RELATIONSHIP]->(node)
• Predicates
• Aggregations
• Ordering
• Graph vs tabular data
PROFILE / EXPLAIN
• Query execution plan
• Declarative vs imperative
• Performance tuning
CREATE INDEX …
• Indexes are only used to find the starting point for queries.
Use index scans to look up
rows in tables and join them
with rows from other tables
Use indexes to find the starting
points for a query.
Relational
Graph
Spatial functionality
Extending Cypher - Procedures and
Functions
• Code deployed to database
• Callable from Cypher
• APOC library
• data import
• graph algorithms
• periodic iterate
• MUCH more…
• Neo4j Spatial
• Neo4j-GraphQL
Extending Cypher - Procedures and
Functions
• PageRank - friend with highest PageRank?
Resources
Cypher Refcard
https://neo4j.com/docs/cypher-refcard/current/
openCypher
opencypher.org
Neo4j Developer Page
neo4j.com/developer
Neo4j Sandbox
neo4jsandbox.com
(you)-[:HAVE]->(?)
(?)<-[:ANSWERS]-(will)

Intro to Cypher