SlideShare a Scribd company logo
1 of 36
Download to read offline
FOSDEM 2012
                                                         Graph Processing Room
                                                         5 Feb 2012




         Cypher Query Language
                              Andrés Taylor and Alistair Jones




Wednesday, February 8, 2012
What is Cypher?


                    • Graph Query Language for Neo4j
                    • Aims to make querying simple

Wednesday, February 8, 2012
Motivation
       Something new?


                    • Existing Neo4j query mechanisms were not
                          simple enough

                         • Too verbose (Java API)
                         • Too prescriptive (Gremlin)

Wednesday, February 8, 2012
Motivation
       SQL?


                    • Unable to express paths
                      • these are crucial for graph-based
                              reasoning

                    • neo4j is schema/table free

Wednesday, February 8, 2012
Motivation
       SPARQL?


                    • SPARQL designed for a different data model
                      • namespaces
                      • properties as nodes


Wednesday, February 8, 2012
Design




Wednesday, February 8, 2012
Design Decisions
             Declarative
                        Imperative         Declarative
      follow relationship              specify starting point
  breadth-first vs depth-first         specify desired outcome

              explicit algorithm       algorithm adaptable
                                         based on query




Wednesday, February 8, 2012
Design Decisions
             Pattern matching




Wednesday, February 8, 2012
Design Decisions
             Pattern matching


                                  A


                              B       C


Wednesday, February 8, 2012
Design Decisions                    A
             Pattern matching
                                B       C




Wednesday, February 8, 2012
Design Decisions                    A
             Pattern matching
                                B       C




Wednesday, February 8, 2012
Design Decisions                    A
             Pattern matching
                                B       C




Wednesday, February 8, 2012
Design Decisions                    A
             Pattern matching
                                B       C




Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns




Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns




                              () --> ()

Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns


                              A   B




Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns


                               A      B

                              (A) --> (B)

Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns

                                  LOVES
                              A           B




Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns

                                   LOVES
                               A           B

                              A -[:LOVES]-> B



Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns


                    A         B   C




Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns


                    A         B   C

                   A --> B --> C

Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns

                                  A


                              B       C




Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns

                                  A


                              B       C

                 A --> B --> C, A --> C

Wednesday, February 8, 2012
Design Decisions
             ASCII-art patterns

                                  A


                              B       C

                 A --> B --> C, A --> C
                  A --> B --> C <-- A
Wednesday, February 8, 2012
Design Decisions
             Variable length paths

                                      A         B

                                  A                 B

                              A                         B
                                          ...



Wednesday, February 8, 2012
Design Decisions
             Variable length paths

                                      A         B

                                  A                 B

                              A                         B
                                          ...

                              A -[*]-> B
Wednesday, February 8, 2012
Design Decisions
             Optional relationships


                              A       B




Wednesday, February 8, 2012
Design Decisions
             Optional relationships


                               A      B

                              A -[?]-> B

Wednesday, February 8, 2012
Design Decisions
             Closures

      start london = node(1), moscow = node(2)
      match path = london -[*]-> moscow
      where all(city in nodes(path) where city.capital = true)




Wednesday, February 8, 2012
Design Decisions
             Parsed, not an internal DSL



              Execution Semantics      Serialisation

                         Type System   Portability




Wednesday, February 8, 2012
Design Decisions
             Familiar for SQL users


                               select
                                          start
                                from
                                         match
                               where
                                         where
                              group by
                                         return
                              order by




Wednesday, February 8, 2012
Implementation




Wednesday, February 8, 2012
Implementation

             Execution Plan


  start n=node(0)
  return n

  Parameters()
  Nodes(n)
  Extract([n])
  ColumnFilter([n])




Wednesday, February 8, 2012
Implementation

             Execution Plan
  start n=node(0)
  match n-[*]-> b
  return n.name, n, count(*)
  order by n.age

  Parameters()
  Nodes(n)
  PatternMatch(n-[*]->b)
  Extract([n.name, n])
  EagerAggregation( keys: [n.name, n], aggregates: [count(*)])
  Extract([n.age])
  Sort(n.age ASC)
  ColumnFilter([n.name,n,count(*)])


Wednesday, February 8, 2012
Implementation

             Execution Plan
  start n=node(0)
  match n-[*]-> b
  return n.name, n, count(*)
  order by n.name

  Parameters()
  Nodes(n)
  PatternMatch(n-[*]->b)
  Extract([n.name, n])
  Sort(n.name ASC,n ASC)
  EagerAggregation( keys: [n.name, n], aggregates: [count(*)])
  ColumnFilter([n.name,n,count(*)])


Wednesday, February 8, 2012
Thanks for Listening!
                                Questions?
   Andrés Taylor andres.taylor@neotechnology.com @andres_taylor
       Alistair Jones alistair.jones@neotechnology.com @apcj




Wednesday, February 8, 2012

More Related Content

What's hot

Kovacs [FINAL] .pptx
Kovacs [FINAL] .pptxKovacs [FINAL] .pptx
Kovacs [FINAL] .pptx
FIWARE
 
Data Architecture for Solutions.pdf
Data Architecture for Solutions.pdfData Architecture for Solutions.pdf
Data Architecture for Solutions.pdf
Alan McSweeney
 

What's hot (20)

How Graph Algorithms Answer your Business Questions in Banking and Beyond
How Graph Algorithms Answer your Business Questions in Banking and BeyondHow Graph Algorithms Answer your Business Questions in Banking and Beyond
How Graph Algorithms Answer your Business Questions in Banking and Beyond
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
How Expedia’s Entity Graph Powers Global Travel
How Expedia’s Entity Graph Powers Global TravelHow Expedia’s Entity Graph Powers Global Travel
How Expedia’s Entity Graph Powers Global Travel
 
Workshop Tel Aviv - Graph Data Science
Workshop Tel Aviv - Graph Data ScienceWorkshop Tel Aviv - Graph Data Science
Workshop Tel Aviv - Graph Data Science
 
A Universe of Knowledge Graphs
A Universe of Knowledge GraphsA Universe of Knowledge Graphs
A Universe of Knowledge Graphs
 
Knowledge Graphs & Graph Data Science, More Context, Better Predictions - Neo...
Knowledge Graphs & Graph Data Science, More Context, Better Predictions - Neo...Knowledge Graphs & Graph Data Science, More Context, Better Predictions - Neo...
Knowledge Graphs & Graph Data Science, More Context, Better Predictions - Neo...
 
Kovacs [FINAL] .pptx
Kovacs [FINAL] .pptxKovacs [FINAL] .pptx
Kovacs [FINAL] .pptx
 
https://www.slideshare.net/neo4j/a-fusion-of-machine-learning-and-graph-analy...
https://www.slideshare.net/neo4j/a-fusion-of-machine-learning-and-graph-analy...https://www.slideshare.net/neo4j/a-fusion-of-machine-learning-and-graph-analy...
https://www.slideshare.net/neo4j/a-fusion-of-machine-learning-and-graph-analy...
 
Data Governance
Data GovernanceData Governance
Data Governance
 
Neo4j Graph Use Cases, Bruno Ungermann, Neo4j
Neo4j Graph Use Cases, Bruno Ungermann, Neo4jNeo4j Graph Use Cases, Bruno Ungermann, Neo4j
Neo4j Graph Use Cases, Bruno Ungermann, Neo4j
 
How to boost your datamanagement with Dremio ?
How to boost your datamanagement with Dremio ?How to boost your datamanagement with Dremio ?
How to boost your datamanagement with Dremio ?
 
Dataiku Data Science Studio (datasheet)
Dataiku Data Science Studio (datasheet)Dataiku Data Science Studio (datasheet)
Dataiku Data Science Studio (datasheet)
 
Apply MLOps at Scale
Apply MLOps at ScaleApply MLOps at Scale
Apply MLOps at Scale
 
Driving Datascience at scale using Postgresql, Greenplum and Dataiku - Greenp...
Driving Datascience at scale using Postgresql, Greenplum and Dataiku - Greenp...Driving Datascience at scale using Postgresql, Greenplum and Dataiku - Greenp...
Driving Datascience at scale using Postgresql, Greenplum and Dataiku - Greenp...
 
Building a modern data stack to maintain an efficient and safe electrical grid
Building a modern data stack to maintain an efficient and safe electrical gridBuilding a modern data stack to maintain an efficient and safe electrical grid
Building a modern data stack to maintain an efficient and safe electrical grid
 
Introduction to Knowledge Graphs and Semantic AI
Introduction to Knowledge Graphs and Semantic AIIntroduction to Knowledge Graphs and Semantic AI
Introduction to Knowledge Graphs and Semantic AI
 
Graph Databases - RedisGraph and RedisInsight
Graph Databases - RedisGraph and RedisInsightGraph Databases - RedisGraph and RedisInsight
Graph Databases - RedisGraph and RedisInsight
 
Data Architecture for Solutions.pdf
Data Architecture for Solutions.pdfData Architecture for Solutions.pdf
Data Architecture for Solutions.pdf
 
Understanding DataOps and Its Impact on Application Quality
Understanding DataOps and Its Impact on Application QualityUnderstanding DataOps and Its Impact on Application Quality
Understanding DataOps and Its Impact on Application Quality
 
Emerging Trends in Data Architecture – What’s the Next Big Thing?
Emerging Trends in Data Architecture – What’s the Next Big Thing?Emerging Trends in Data Architecture – What’s the Next Big Thing?
Emerging Trends in Data Architecture – What’s the Next Big Thing?
 

Similar to Cypher Query Language

Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)
Obie Fernandez
 

Similar to Cypher Query Language (9)

Como escalar aplicações PHP
Como escalar aplicações PHPComo escalar aplicações PHP
Como escalar aplicações PHP
 
Games for the Masses (QCon London 2012)
Games for the Masses (QCon London 2012)Games for the Masses (QCon London 2012)
Games for the Masses (QCon London 2012)
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Continous Delivery in Action
Continous Delivery in ActionContinous Delivery in Action
Continous Delivery in Action
 
Games for the Masses - Wie DevOps die Entwicklung von Architektur verändert (...
Games for the Masses - Wie DevOps die Entwicklung von Architektur verändert (...Games for the Masses - Wie DevOps die Entwicklung von Architektur verändert (...
Games for the Masses - Wie DevOps die Entwicklung von Architektur verändert (...
 
How design is transforming modern intranets
How design is transforming modern intranetsHow design is transforming modern intranets
How design is transforming modern intranets
 
An Analytics Toolkit Tour
An Analytics Toolkit TourAn Analytics Toolkit Tour
An Analytics Toolkit Tour
 
Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)
 
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
RoRoRoomba - Ruby on Rails on Roomba Railsconf 2012
 

More from graphdevroom

Challenges in the Design of a Graph Database Benchmark
Challenges in the Design of a Graph Database Benchmark Challenges in the Design of a Graph Database Benchmark
Challenges in the Design of a Graph Database Benchmark
graphdevroom
 
Using Cascalog and Hadoop for rapid graph processing and exploration
Using Cascalog and Hadoop for rapid graph processing and exploration Using Cascalog and Hadoop for rapid graph processing and exploration
Using Cascalog and Hadoop for rapid graph processing and exploration
graphdevroom
 

More from graphdevroom (6)

An example graph visualization with Processing.js
An example graph visualization with Processing.js An example graph visualization with Processing.js
An example graph visualization with Processing.js
 
Bio4j: A pioneer graph based database for the integration of biological Big D...
Bio4j: A pioneer graph based database for the integration of biological Big D...Bio4j: A pioneer graph based database for the integration of biological Big D...
Bio4j: A pioneer graph based database for the integration of biological Big D...
 
Challenges in the Design of a Graph Database Benchmark
Challenges in the Design of a Graph Database Benchmark Challenges in the Design of a Graph Database Benchmark
Challenges in the Design of a Graph Database Benchmark
 
Ontological Conjunctive Query Answering over large, semi-structured knowledge...
Ontological Conjunctive Query Answering over large, semi-structured knowledge...Ontological Conjunctive Query Answering over large, semi-structured knowledge...
Ontological Conjunctive Query Answering over large, semi-structured knowledge...
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB
 
Using Cascalog and Hadoop for rapid graph processing and exploration
Using Cascalog and Hadoop for rapid graph processing and exploration Using Cascalog and Hadoop for rapid graph processing and exploration
Using Cascalog and Hadoop for rapid graph processing and exploration
 

Cypher Query Language

  • 1. FOSDEM 2012 Graph Processing Room 5 Feb 2012 Cypher Query Language Andrés Taylor and Alistair Jones Wednesday, February 8, 2012
  • 2. What is Cypher? • Graph Query Language for Neo4j • Aims to make querying simple Wednesday, February 8, 2012
  • 3. Motivation Something new? • Existing Neo4j query mechanisms were not simple enough • Too verbose (Java API) • Too prescriptive (Gremlin) Wednesday, February 8, 2012
  • 4. Motivation SQL? • Unable to express paths • these are crucial for graph-based reasoning • neo4j is schema/table free Wednesday, February 8, 2012
  • 5. Motivation SPARQL? • SPARQL designed for a different data model • namespaces • properties as nodes Wednesday, February 8, 2012
  • 7. Design Decisions Declarative Imperative Declarative follow relationship specify starting point breadth-first vs depth-first specify desired outcome explicit algorithm algorithm adaptable based on query Wednesday, February 8, 2012
  • 8. Design Decisions Pattern matching Wednesday, February 8, 2012
  • 9. Design Decisions Pattern matching A B C Wednesday, February 8, 2012
  • 10. Design Decisions A Pattern matching B C Wednesday, February 8, 2012
  • 11. Design Decisions A Pattern matching B C Wednesday, February 8, 2012
  • 12. Design Decisions A Pattern matching B C Wednesday, February 8, 2012
  • 13. Design Decisions A Pattern matching B C Wednesday, February 8, 2012
  • 14. Design Decisions ASCII-art patterns Wednesday, February 8, 2012
  • 15. Design Decisions ASCII-art patterns () --> () Wednesday, February 8, 2012
  • 16. Design Decisions ASCII-art patterns A B Wednesday, February 8, 2012
  • 17. Design Decisions ASCII-art patterns A B (A) --> (B) Wednesday, February 8, 2012
  • 18. Design Decisions ASCII-art patterns LOVES A B Wednesday, February 8, 2012
  • 19. Design Decisions ASCII-art patterns LOVES A B A -[:LOVES]-> B Wednesday, February 8, 2012
  • 20. Design Decisions ASCII-art patterns A B C Wednesday, February 8, 2012
  • 21. Design Decisions ASCII-art patterns A B C A --> B --> C Wednesday, February 8, 2012
  • 22. Design Decisions ASCII-art patterns A B C Wednesday, February 8, 2012
  • 23. Design Decisions ASCII-art patterns A B C A --> B --> C, A --> C Wednesday, February 8, 2012
  • 24. Design Decisions ASCII-art patterns A B C A --> B --> C, A --> C A --> B --> C <-- A Wednesday, February 8, 2012
  • 25. Design Decisions Variable length paths A B A B A B ... Wednesday, February 8, 2012
  • 26. Design Decisions Variable length paths A B A B A B ... A -[*]-> B Wednesday, February 8, 2012
  • 27. Design Decisions Optional relationships A B Wednesday, February 8, 2012
  • 28. Design Decisions Optional relationships A B A -[?]-> B Wednesday, February 8, 2012
  • 29. Design Decisions Closures start london = node(1), moscow = node(2) match path = london -[*]-> moscow where all(city in nodes(path) where city.capital = true) Wednesday, February 8, 2012
  • 30. Design Decisions Parsed, not an internal DSL Execution Semantics Serialisation Type System Portability Wednesday, February 8, 2012
  • 31. Design Decisions Familiar for SQL users select start from match where where group by return order by Wednesday, February 8, 2012
  • 33. Implementation Execution Plan start n=node(0) return n Parameters() Nodes(n) Extract([n]) ColumnFilter([n]) Wednesday, February 8, 2012
  • 34. Implementation Execution Plan start n=node(0) match n-[*]-> b return n.name, n, count(*) order by n.age Parameters() Nodes(n) PatternMatch(n-[*]->b) Extract([n.name, n]) EagerAggregation( keys: [n.name, n], aggregates: [count(*)]) Extract([n.age]) Sort(n.age ASC) ColumnFilter([n.name,n,count(*)]) Wednesday, February 8, 2012
  • 35. Implementation Execution Plan start n=node(0) match n-[*]-> b return n.name, n, count(*) order by n.name Parameters() Nodes(n) PatternMatch(n-[*]->b) Extract([n.name, n]) Sort(n.name ASC,n ASC) EagerAggregation( keys: [n.name, n], aggregates: [count(*)]) ColumnFilter([n.name,n,count(*)]) Wednesday, February 8, 2012
  • 36. Thanks for Listening! Questions? Andrés Taylor andres.taylor@neotechnology.com @andres_taylor Alistair Jones alistair.jones@neotechnology.com @apcj Wednesday, February 8, 2012