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

Introduction of MariaDB 2017 09
Introduction of MariaDB 2017 09Introduction of MariaDB 2017 09
Introduction of MariaDB 2017 09GOTO Satoru
 
Spark's Role in the Big Data Ecosystem (Spark Summit 2014)
Spark's Role in the Big Data Ecosystem (Spark Summit 2014)Spark's Role in the Big Data Ecosystem (Spark Summit 2014)
Spark's Role in the Big Data Ecosystem (Spark Summit 2014)Databricks
 
Apache AGE and the synergy effect in the combination of Postgres and NoSQL
 Apache AGE and the synergy effect in the combination of Postgres and NoSQL Apache AGE and the synergy effect in the combination of Postgres and NoSQL
Apache AGE and the synergy effect in the combination of Postgres and NoSQLEDB
 
Data profiling with Apache Calcite
Data profiling with Apache CalciteData profiling with Apache Calcite
Data profiling with Apache CalciteJulian Hyde
 
MySQL partitions tutorial
MySQL partitions tutorialMySQL partitions tutorial
MySQL partitions tutorialGiuseppe Maxia
 
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek StavisiMasters
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architectureBishal Khanal
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMike Dirolf
 
Understanding the architecture of MariaDB ColumnStore
Understanding the architecture of MariaDB ColumnStoreUnderstanding the architecture of MariaDB ColumnStore
Understanding the architecture of MariaDB ColumnStoreMariaDB plc
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBRavi Teja
 
Mysql server query path
Mysql server query pathMysql server query path
Mysql server query pathWenjie Wu
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMariaDB plc
 

What's hot (20)

Introduction of MariaDB 2017 09
Introduction of MariaDB 2017 09Introduction of MariaDB 2017 09
Introduction of MariaDB 2017 09
 
Spark's Role in the Big Data Ecosystem (Spark Summit 2014)
Spark's Role in the Big Data Ecosystem (Spark Summit 2014)Spark's Role in the Big Data Ecosystem (Spark Summit 2014)
Spark's Role in the Big Data Ecosystem (Spark Summit 2014)
 
Apache AGE and the synergy effect in the combination of Postgres and NoSQL
 Apache AGE and the synergy effect in the combination of Postgres and NoSQL Apache AGE and the synergy effect in the combination of Postgres and NoSQL
Apache AGE and the synergy effect in the combination of Postgres and NoSQL
 
Data profiling with Apache Calcite
Data profiling with Apache CalciteData profiling with Apache Calcite
Data profiling with Apache Calcite
 
NoSQL Basics - a quick tour
NoSQL Basics - a quick tourNoSQL Basics - a quick tour
NoSQL Basics - a quick tour
 
Sequelize
SequelizeSequelize
Sequelize
 
MySQL partitions tutorial
MySQL partitions tutorialMySQL partitions tutorial
MySQL partitions tutorial
 
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
 
Ruby
RubyRuby
Ruby
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
MongoDB
MongoDBMongoDB
MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Understanding the architecture of MariaDB ColumnStore
Understanding the architecture of MariaDB ColumnStoreUnderstanding the architecture of MariaDB ColumnStore
Understanding the architecture of MariaDB ColumnStore
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
HDFS Design Principles
HDFS Design PrinciplesHDFS Design Principles
HDFS Design Principles
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mysql server query path
Mysql server query pathMysql server query path
Mysql server query path
 
Logging with log4j v1.2
Logging with log4j v1.2Logging with log4j v1.2
Logging with log4j v1.2
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimization
 

Similar to Cypher Query Language

Como escalar aplicações PHP
Como escalar aplicações PHPComo escalar aplicações PHP
Como escalar aplicações PHPAugusto Pascutti
 
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)Wooga
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignAOE
 
Continous Delivery in Action
Continous Delivery in ActionContinous Delivery in Action
Continous Delivery in Actionandyhu1007
 
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 (...Wooga
 
How design is transforming modern intranets
How design is transforming modern intranetsHow design is transforming modern intranets
How design is transforming modern intranetsJames Robertson
 
An Analytics Toolkit Tour
An Analytics Toolkit TourAn Analytics Toolkit Tour
An Analytics Toolkit TourRory Winston
 
Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)Obie Fernandez
 
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 2012cwabbott
 

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

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 graphdevroom
 
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...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
 
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...graphdevroom
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB 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