cypher query language

of 36/36
Cypher Query Language Andrés Taylor and Alistair Jones FOSDEM 2012 Graph Processing Room 5 Feb 2012 Wednesday, February 8, 2012

Post on 28-Nov-2014

4.782 views

Category:

Documents

1 download

Embed Size (px)

DESCRIPTION

Cypher is a declarative query language recently added to the Neo4j graph database. In this talk we explain the motivations for creating this language, describe its current features and design, and dive a little into its implementation. Finally, we discuss the future direction of how we expect the language to evolve.

TRANSCRIPT

  • 1. FOSDEM 2012 Graph Processing Room 5 Feb 2012 Cypher Query Language Andrs Taylor and Alistair JonesWednesday, February 8, 2012
  • 2. What is Cypher? Graph Query Language for Neo4j Aims to make querying simpleWednesday, 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 freeWednesday, February 8, 2012
  • 5. Motivation SPARQL? SPARQL designed for a different data model namespaces properties as nodesWednesday, February 8, 2012
  • 6. DesignWednesday, February 8, 2012
  • 7. Design Decisions Declarative Imperative Declarative follow relationship specify starting point breadth-rst vs depth-rst specify desired outcome explicit algorithm algorithm adaptable based on queryWednesday, February 8, 2012
  • 8. Design Decisions Pattern matchingWednesday, February 8, 2012
  • 9. Design Decisions Pattern matching A B CWednesday, February 8, 2012
  • 10. Design Decisions A Pattern matching B CWednesday, February 8, 2012
  • 11. Design Decisions A Pattern matching B CWednesday, February 8, 2012
  • 12. Design Decisions A Pattern matching B CWednesday, February 8, 2012
  • 13. Design Decisions A Pattern matching B CWednesday, February 8, 2012
  • 14. Design Decisions ASCII-art patternsWednesday, February 8, 2012
  • 15. Design Decisions ASCII-art patterns () --> ()Wednesday, February 8, 2012
  • 16. Design Decisions ASCII-art patterns A BWednesday, 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 BWednesday, February 8, 2012
  • 19. Design Decisions ASCII-art patterns LOVES A B A -[:LOVES]-> BWednesday, February 8, 2012
  • 20. Design Decisions ASCII-art patterns A B CWednesday, February 8, 2012
  • 21. Design Decisions ASCII-art patterns A B C A --> B --> CWednesday, February 8, 2012
  • 22. Design Decisions ASCII-art patterns A B CWednesday, February 8, 2012
  • 23. Design Decisions ASCII-art patterns A B C A --> B --> C, A --> CWednesday, February 8, 2012
  • 24. Design Decisions ASCII-art patterns A B C A --> B --> C, A --> C A --> B --> C BWednesday, February 8, 2012
  • 27. Design Decisions Optional relationships A BWednesday, February 8, 2012
  • 28. Design Decisions Optional relationships A B A -[?]-> BWednesday, 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 PortabilityWednesday, February 8, 2012
  • 31. Design Decisions Familiar for SQL users select start from match where where group by return order byWednesday, February 8, 2012
  • 32. ImplementationWednesday, 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? Andrs Taylor [email protected] @andres_taylor Alistair Jones [email protected] @apcjWednesday, February 8, 2012