SlideShare a Scribd company logo
Introduction to Cypher
Graph Query Language
October 6, 2016
Graph Databases in Silicon Valley Meetup
Overview
Goal
Understand the benefits of Cypher query language
Graph Data Models and Query Languages
Basics of Cypher Query Language
Features and Execution Structure
Who am I
Ph.D Kisung Kim - Chief Technology Officer of Bitnine Global Inc.
Developed a distributed relational database engine in TmaxSoft
Lead the development of a new graph database, Agens Graph in Bitnine
Global
Graph Enthusiast !
Graph Data Model and Query Languages
● Property graph model
○ Cypher query language from Cypher
○ AQL from ArangoDB
○ OrientDB’s SQL dialect
○ Tinkerpop API, a domain specific language, from Titan
● RDF graph model
○ W3C standard recommendation for the Semantic Web
○ SPARQL query language
● Facebook’s GraphQL (?)
Property Graph Model
Terminology:
Node(vertex) - Entity
Relationships(Edge)
Property - Attribute
Label(type) - Group nodes and relationships
person company
works_for
Name: Kisung Kim
Email: kskim@bitnine.net
Name: Bitnine Global
Homepage: http://bitnine.net
title: CTO
Team: agens graph
Property
Node
Relationship
Very intuitive and easy
to model E-R diagram to property graphs
Cypher
● Declarative query language for the property graph model
○ Inspired by SQL and SPARQL
○ Designed to be human-readable query language
● Developed by Neo technology Inc. since 2011
● Cypher is now evolving
○ Current version is 3.0
● OpenCypher.org
○ Participate in developing the query language
OpenCypher.org
http://www.slideshare.net/neo4j/the-opencypher-project-an-open-graph-query-language
Cypher is Human-Readable
Finding all ancestor-descendant pairs in the graph
with recursive
as (
select
parent, child as descendant,
1 as level from source
union all
select
d.parent, s.child, d.level + 1
from descendants as d
join source s on d.descendant = s.parent
)
select * from descendants
order by parent, level, descendant ;
SQL
MATCH
p=(descendant)-[:Parent*]->(ancestor)
RETURN
(ancestor), (descendant), length(p)
ORDER BY (ancestor), (descendant), length(p)
Cypher
descendant ancestor
Cypher Query Example
Graph Pattern
Results
Graph Pattern Matching
● Graph pattern matching is at the heart of Cypher
● Find subgraphs which are matched to the specified graph pattern
○ Subgraph isomorphism
Query Pattern
Graph Data
Graph Pattern
● How can we represent graph patterns in a query?
○ Use ASCII art to represent the graph pattern easily
○ Like a diagram
● Node : ( )
● Relationship : --> or <-- (with direction),
-- (without direction)
● Node label : ( :LABEL_NAME )
● Relationship type : -[ :TYPE_NAME ]->
:Actor :Movie
ACTS_IN
(:Actor)-[:ACTS_IN]->(:Movie)
Graph Pattern
● Property
○ Node property: ( { field : value, … } )
○ Relationship property: -[ { field : value, … } ]->
● Assign nodes and relations to variables
:Actor
name=’TOM’
:Movie (:Actor {name: “TOM”})-[:ACTS_IN]->(:Movie)
ACTS_IN
(a:Actor {name: “TOM”})-[ r:ACTS_IN]->(b:Movie)
Graph Pattern
Represent more complicated patterns
:Person :Movie
RATED
:Person
RATED
FRIEND
(a:Person)-[:RATED]->(m:Movie)<-[:RATED]-( c:Person),
(a)-[:FRIEND]-(c)
Path1
Path2
Path1
Path2
MATCH Clause
● Find the specified patterns
● Return matched variables to the next clause
MATCH
(a:Person)-[:RATED]->( m:Movie)<-[:RATED]-( c:Person),(a)-[:FRIEND]-(c
)
a (node) m (node) c (node)
Results of MATCH clause
Cypher Clause
● For reading
○ MATCH / OPTIONAL MATCH
● For updating
○ CREATE
○ MERGE
○ SET
● For filtering
○ WHERE
● For handling results
○ WITH, RETURN
○ And ORDER BY, LIMIT, SKIP https://s3.amazonaws.com/artifacts.opencypher.org/M02/railroad/Cypher.html
Cypher Query Structure
Pipelined Execution
Clauses are provided results from the former clause
MATCH
MATCH
RETURN
tom movie
tom movie nicole
tom.name movie.title nicole.name
Clause Chain Result Format
Uniqueness in Pattern Matching
● Cypher defines that pattern matching does not match a relationship to be
matched to several relationships in a pattern
● If we want multiple matching, then separate into multiple MATCH clauses
b
a
c
Graph Data Query Pattern
Friend r1:Friend r2:Friend
MATCH (a)-[r1:Friend]->(b), (a)-[r2:Friend]->(c) MATCH (a)-[r1:Friend]->(b)
MATCH (a)-[r2:Friend]->(c)
Variable Length Relationship Matching
● One of the important features of the Cypher
● Finding all people links between two specified persons
Kisung Kim Joshua
MATCH
(:person {name: “Kisung Kim”})- [:friends*]->(:person {name: “Joshua”})
MATCH
(:person {name: “Kisung Kim”})- [:friends*3..5]->(:person {name:
“Joshua”})
Specify the path length 3 to 5
?
Summary
Query database using graph patterns using Cypher
Cyper features
● Graph pattern syntax
● Uniqueness restriction of relationship matching
● Pipelined execution structure
● Variable length path matching
Graph query is much easier than SQL query
Thank you
How do you feel about
Graph Database?

More Related Content

What's hot (20)

PDF
GraphFrames: Graph Queries in Spark SQL by Ankur Dave
Spark Summit
 
PDF
Writing a Cypher Engine in Clojure
Gábor Szárnyas
 
PDF
What Makes Graph Queries Difficult?
Gábor Szárnyas
 
PPTX
Apache Spark GraphX & GraphFrame Synthetic ID Fraud Use Case
Mo Patel
 
PDF
Signals from outer space
GraphAware
 
PDF
GraphX: Graph analytics for insights about developer communities
Paco Nathan
 
PDF
Machine Learning and GraphX
Andy Petrella
 
PDF
MLSD18. Basic Transformations - QCRI
BigML, Inc
 
DOCX
Data_Size_statistics
Sudhanshu Sharma
 
PDF
BUILDING WHILE FLYING
Kamal Shannak
 
PPTX
Gephi, Graphx, and Giraph
Doug Needham
 
PDF
GraphGen: Conducting Graph Analytics over Relational Databases
Konstantinos Xirogiannopoulos
 
PPT
Benchmarking graph databases on the problem of community detection
Symeon Papadopoulos
 
PDF
Graphalytics: A big data benchmark for graph-processing platforms
Graph-TA
 
PPTX
MicroStation DGN: How to Integrate CAD and GIS
Safe Software
 
PDF
Graph Databases - RedisGraph and RedisInsight
Md. Farhan Memon
 
PPTX
Graph database & neo4j
Sandip Jadhav
 
PPTX
How to Exchange Data between CAD and GIS
Safe Software
 
PDF
MLSD18. Summary of Morning Sessions
BigML, Inc
 
PDF
Improve ML Predictions using Connected Feature Extraction
Databricks
 
GraphFrames: Graph Queries in Spark SQL by Ankur Dave
Spark Summit
 
Writing a Cypher Engine in Clojure
Gábor Szárnyas
 
What Makes Graph Queries Difficult?
Gábor Szárnyas
 
Apache Spark GraphX & GraphFrame Synthetic ID Fraud Use Case
Mo Patel
 
Signals from outer space
GraphAware
 
GraphX: Graph analytics for insights about developer communities
Paco Nathan
 
Machine Learning and GraphX
Andy Petrella
 
MLSD18. Basic Transformations - QCRI
BigML, Inc
 
Data_Size_statistics
Sudhanshu Sharma
 
BUILDING WHILE FLYING
Kamal Shannak
 
Gephi, Graphx, and Giraph
Doug Needham
 
GraphGen: Conducting Graph Analytics over Relational Databases
Konstantinos Xirogiannopoulos
 
Benchmarking graph databases on the problem of community detection
Symeon Papadopoulos
 
Graphalytics: A big data benchmark for graph-processing platforms
Graph-TA
 
MicroStation DGN: How to Integrate CAD and GIS
Safe Software
 
Graph Databases - RedisGraph and RedisInsight
Md. Farhan Memon
 
Graph database & neo4j
Sandip Jadhav
 
How to Exchange Data between CAD and GIS
Safe Software
 
MLSD18. Summary of Morning Sessions
BigML, Inc
 
Improve ML Predictions using Connected Feature Extraction
Databricks
 

Similar to The 2nd graph database in sv meetup (20)

PPTX
The openCypher Project - An Open Graph Query Language
Neo4j
 
PDF
AgensGraph Presentation at PGConf.us 2017
Kisung Kim
 
PDF
Intro to Cypher
Neo4j
 
PDF
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
openCypher
 
PDF
Morpheus - Cypher for Apache Spark
Knoldus Inc.
 
PDF
Path Pattern Queries: Introducing Regular Path Queries in openCypher
openCypher
 
PDF
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
David Fombella Pombal
 
PPTX
GraphDatabase.pptx
JeyaVarthini1
 
PPTX
Mapping Graph Queries to PostgreSQL
Gábor Szárnyas
 
PDF
Graph Database Using Neo4J
Harmeet Singh(Taara)
 
PDF
Getting started with Graph Databases & Neo4j
Suroor Wijdan
 
PDF
Understanding Graph Databases with Neo4j and Cypher
Ruhaim Izmeth
 
PDF
Neo4J
nklmish
 
PPTX
Neo4j graph database
Prashant Bhargava
 
PPTX
Neo4j Davide Francesconi
Davide Francesconi
 
PDF
The Property Graph Query Language Landscape: openCypher and Property Graph Ex...
openCypher
 
PDF
03 introduction to graph databases
Neo4j
 
PDF
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
Athens Big Data
 
PPTX
Intro to Cypher
Brian Underwood
 
PDF
Flink Forward Berlin 2017: Max Kiessling, Martin Junghanns - Cypher-based Gra...
Flink Forward
 
The openCypher Project - An Open Graph Query Language
Neo4j
 
AgensGraph Presentation at PGConf.us 2017
Kisung Kim
 
Intro to Cypher
Neo4j
 
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
openCypher
 
Morpheus - Cypher for Apache Spark
Knoldus Inc.
 
Path Pattern Queries: Introducing Regular Path Queries in openCypher
openCypher
 
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
David Fombella Pombal
 
GraphDatabase.pptx
JeyaVarthini1
 
Mapping Graph Queries to PostgreSQL
Gábor Szárnyas
 
Graph Database Using Neo4J
Harmeet Singh(Taara)
 
Getting started with Graph Databases & Neo4j
Suroor Wijdan
 
Understanding Graph Databases with Neo4j and Cypher
Ruhaim Izmeth
 
Neo4J
nklmish
 
Neo4j graph database
Prashant Bhargava
 
Neo4j Davide Francesconi
Davide Francesconi
 
The Property Graph Query Language Landscape: openCypher and Property Graph Ex...
openCypher
 
03 introduction to graph databases
Neo4j
 
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
Athens Big Data
 
Intro to Cypher
Brian Underwood
 
Flink Forward Berlin 2017: Max Kiessling, Martin Junghanns - Cypher-based Gra...
Flink Forward
 
Ad

Recently uploaded (20)

PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
PDF
2025年 Linux 核心專題: 探討 sched_ext 及機器學習.pdf
Eric Chou
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PPTX
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
PPTX
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PPTX
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
PPTX
PowerISO Crack 2025 – Free Download Full Version with Serial Key [Latest](1)....
HyperPc soft
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PDF
Transform Retail with Smart Technology: Power Your Growth with Ginesys
Ginesys
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
Human Resources Information System (HRIS)
Amity University, Patna
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
2025年 Linux 核心專題: 探討 sched_ext 及機器學習.pdf
Eric Chou
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
PowerISO Crack 2025 – Free Download Full Version with Serial Key [Latest](1)....
HyperPc soft
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Transform Retail with Smart Technology: Power Your Growth with Ginesys
Ginesys
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
Ad

The 2nd graph database in sv meetup

  • 1. Introduction to Cypher Graph Query Language October 6, 2016 Graph Databases in Silicon Valley Meetup
  • 2. Overview Goal Understand the benefits of Cypher query language Graph Data Models and Query Languages Basics of Cypher Query Language Features and Execution Structure
  • 3. Who am I Ph.D Kisung Kim - Chief Technology Officer of Bitnine Global Inc. Developed a distributed relational database engine in TmaxSoft Lead the development of a new graph database, Agens Graph in Bitnine Global Graph Enthusiast !
  • 4. Graph Data Model and Query Languages ● Property graph model ○ Cypher query language from Cypher ○ AQL from ArangoDB ○ OrientDB’s SQL dialect ○ Tinkerpop API, a domain specific language, from Titan ● RDF graph model ○ W3C standard recommendation for the Semantic Web ○ SPARQL query language ● Facebook’s GraphQL (?)
  • 5. Property Graph Model Terminology: Node(vertex) - Entity Relationships(Edge) Property - Attribute Label(type) - Group nodes and relationships person company works_for Name: Kisung Kim Email: [email protected] Name: Bitnine Global Homepage: http://bitnine.net title: CTO Team: agens graph Property Node Relationship Very intuitive and easy to model E-R diagram to property graphs
  • 6. Cypher ● Declarative query language for the property graph model ○ Inspired by SQL and SPARQL ○ Designed to be human-readable query language ● Developed by Neo technology Inc. since 2011 ● Cypher is now evolving ○ Current version is 3.0 ● OpenCypher.org ○ Participate in developing the query language
  • 8. Cypher is Human-Readable Finding all ancestor-descendant pairs in the graph with recursive as ( select parent, child as descendant, 1 as level from source union all select d.parent, s.child, d.level + 1 from descendants as d join source s on d.descendant = s.parent ) select * from descendants order by parent, level, descendant ; SQL MATCH p=(descendant)-[:Parent*]->(ancestor) RETURN (ancestor), (descendant), length(p) ORDER BY (ancestor), (descendant), length(p) Cypher descendant ancestor
  • 9. Cypher Query Example Graph Pattern Results
  • 10. Graph Pattern Matching ● Graph pattern matching is at the heart of Cypher ● Find subgraphs which are matched to the specified graph pattern ○ Subgraph isomorphism Query Pattern Graph Data
  • 11. Graph Pattern ● How can we represent graph patterns in a query? ○ Use ASCII art to represent the graph pattern easily ○ Like a diagram ● Node : ( ) ● Relationship : --> or <-- (with direction), -- (without direction) ● Node label : ( :LABEL_NAME ) ● Relationship type : -[ :TYPE_NAME ]-> :Actor :Movie ACTS_IN (:Actor)-[:ACTS_IN]->(:Movie)
  • 12. Graph Pattern ● Property ○ Node property: ( { field : value, … } ) ○ Relationship property: -[ { field : value, … } ]-> ● Assign nodes and relations to variables :Actor name=’TOM’ :Movie (:Actor {name: “TOM”})-[:ACTS_IN]->(:Movie) ACTS_IN (a:Actor {name: “TOM”})-[ r:ACTS_IN]->(b:Movie)
  • 13. Graph Pattern Represent more complicated patterns :Person :Movie RATED :Person RATED FRIEND (a:Person)-[:RATED]->(m:Movie)<-[:RATED]-( c:Person), (a)-[:FRIEND]-(c) Path1 Path2 Path1 Path2
  • 14. MATCH Clause ● Find the specified patterns ● Return matched variables to the next clause MATCH (a:Person)-[:RATED]->( m:Movie)<-[:RATED]-( c:Person),(a)-[:FRIEND]-(c ) a (node) m (node) c (node) Results of MATCH clause
  • 15. Cypher Clause ● For reading ○ MATCH / OPTIONAL MATCH ● For updating ○ CREATE ○ MERGE ○ SET ● For filtering ○ WHERE ● For handling results ○ WITH, RETURN ○ And ORDER BY, LIMIT, SKIP https://s3.amazonaws.com/artifacts.opencypher.org/M02/railroad/Cypher.html
  • 16. Cypher Query Structure Pipelined Execution Clauses are provided results from the former clause MATCH MATCH RETURN tom movie tom movie nicole tom.name movie.title nicole.name Clause Chain Result Format
  • 17. Uniqueness in Pattern Matching ● Cypher defines that pattern matching does not match a relationship to be matched to several relationships in a pattern ● If we want multiple matching, then separate into multiple MATCH clauses b a c Graph Data Query Pattern Friend r1:Friend r2:Friend MATCH (a)-[r1:Friend]->(b), (a)-[r2:Friend]->(c) MATCH (a)-[r1:Friend]->(b) MATCH (a)-[r2:Friend]->(c)
  • 18. Variable Length Relationship Matching ● One of the important features of the Cypher ● Finding all people links between two specified persons Kisung Kim Joshua MATCH (:person {name: “Kisung Kim”})- [:friends*]->(:person {name: “Joshua”}) MATCH (:person {name: “Kisung Kim”})- [:friends*3..5]->(:person {name: “Joshua”}) Specify the path length 3 to 5 ?
  • 19. Summary Query database using graph patterns using Cypher Cyper features ● Graph pattern syntax ● Uniqueness restriction of relationship matching ● Pipelined execution structure ● Variable length path matching Graph query is much easier than SQL query
  • 20. Thank you How do you feel about Graph Database?