SlideShare a Scribd company logo
1 of 30
Download to read offline
opencypher.orgopencypher.org | opencypher@googlegroups.com
Schema and Constraints
Mats Rydberg
mats@neotechnology.com
opencypher.orgopencypher.org | opencypher@googlegroups.com
● Cypher is schema-optional
● Fits well with heterogenous data
● Makes typing and query planning harder
● Does not fit well with many existing table-based engines
● Constraints are the only tools to enforce structure in the data
Schema in Cypher is a point where we expect there to be major
developments as more actors get involved.
Schema in Cypher
2
opencypher.orgopencypher.org | opencypher@googlegroups.com
● Consistent syntax for all types of constraints (CIP)
● Re-use as much as possible from the rest of the language
● Allow for a large set of future constraints, some of which are
vendor-specific
● This allows vendors to use more strict schema when necessary
CREATE CONSTRAINT <name>
FOR <simple pattern>
REQUIRE <constraint expression>
New constraint syntax
3
opencypher.orgopencypher.org | opencypher@googlegroups.com
● Property uniqueness constraint
➢ CREATE CONSTRAINT unique_person_names
FOR (p:Person)
REQUIRE UNIQUE p.firstName, p.lastName
● Property existence constraint
➢ CREATE CONSTRAINT person_must_have_firstName
FOR (p:Person)
REQUIRE exists(p.firstName)
Constraints, examples
4
opencypher.orgopencypher.org | opencypher@googlegroups.com
● Property value constraint
➢ CREATE CONSTRAINT roads_must_have_positive_finite_length
FOR ()-[r:ROAD]-()
REQUIRE 0 < r.distance < infinity
● Property type constraint
➢ CREATE CONSTRAINT people_schema
FOR (p:Person)
REQUIRE p.email IS STRING
REQUIRE p.name IS STRING?
REQUIRE p.age IS INTEGER?
Constraints, examples
5
opencypher.orgopencypher.org | opencypher@googlegroups.com
● Cardinality constraints
➢ CREATE CONSTRAINT spread_the_love
FOR (p:Person)
REQUIRE size((p)-[:LOVES]->()) > 3
● Endpoint constraints
➢ CREATE CONSTRAINT can_only_own_things
FOR ()-[:OWNS]->(t)
REQUIRE (t:Vehicle) OR (t:Building) OR (t:Object)
● Label coexistence constraints
➢ CREATE CONSTRAINT programmers_are_people_too
FOR (p:Programmer)
REQUIRE p:Person
Constraints, examples
6
opencypher.orgopencypher.org | opencypher@googlegroups.com
That's it!
Questions ?
opencypher.orgopencypher.org | opencypher@googlegroups.com
Subqueries
Petra Selmer
petra.selmer@neotechnology.com
opencypher.orgopencypher.org | opencypher@googlegroups.com
MATCH (actor:Actor)
WHERE EXISTS {
(actor)-[:ACTED_IN]->(movie),
(other:Actor)-[:ACTED_IN]->(movie)
WHERE other.name = actor.name
AND actor <> other
}
RETURN actor
Existential subqueries
CIP
9
opencypher.orgopencypher.org | opencypher@googlegroups.com
MATCH (f:Farm {id: $farmId})-[:IS_IN]->(country:Country)
MATCH {
MATCH (u:User {id: $userId})-[:LIKES]->(b:Brand)
RETURN b AS item, b.designedDate AS dateOfInterest
UNION
MATCH (u:User {id: $userId})-[:BOUGHT]->(v:Vehicle)
WHERE v.leftHandDrive = country.leftHandDrive
RETURN v AS item, v.manufacturedDate AS dateOfInterest
}
RETURN DISTINCT v.code
ORDER BY dateOfInterest
Nested correlated subqueries
CIP
10
opencypher.orgopencypher.org | opencypher@googlegroups.com
MATCH (r:Root)
DO {
UNWIND range(1, 10) AS x
MERGE (c:Child {id: x})
MERGE (r)-[:PARENT]->(c)
}
● UNWIND manages the looping
● DO suppresses the increased cardinality from the inner query
● DO hides all new variable bindings (e.g. c)
Nested read/write subqueries
CIP
11
opencypher.orgopencypher.org | opencypher@googlegroups.com
MATCH (actor:Actor)
WHERE actor.age > {
MATCH (director:Director)-[:DIRECTED]->(:Movie)
RETURN max(director.age)
}
RETURN actor.name, actor.details
Scalar subqueries
12
CIR
opencypher.orgopencypher.org | opencypher@googlegroups.com
That's it!
Questions ?
opencypher.orgopencypher.org | opencypher@googlegroups.com
Homomorphic and Isomorphic
Pattern Matching
Stefan Plantikow
stefan.plantikow@neotechnology.com
opencypher.orgopencypher.org | opencypher@googlegroups.com
• MATCH(a)-[r]->(b)
≡ { (a, r, b) V E V | r (a,b) }
• MATCH (a)-[r1]->(b)-[r2]->(c)
≡ { (a, r1
, b, r2
, c) V E V E V | r 1
(a,b) r 2
(b,c) r1
≠ r2
}
• MATCH (a)-[rs*]->(b)
≡ { (a, rs, b) V E*
V | rs *
(a,b) rs=[...,r1
...,r2
,...] r1
≠ r2
}
Basic Pattern Matching Semantics
15
opencypher.orgopencypher.org | opencypher@googlegroups.com
• Why?
• No uniqueness Potentially infinitely many matching paths
• Node uniqueness Can't match self-loops
• When?
• All pattern variables in a MATCH
• And similar constructs (comprehensions etc.)
• Optional?
• Not for variable length
Default Uniqueness = Relationship Uniqueness
16
opencypher.orgopencypher.org | opencypher@googlegroups.com
• CIR 2017-174
• Defines uniqueness scope precisely
• Add configurable uniqueness
• No uniqueness => Graph homomorphism
• Relationship uniqueness => Graph (relationship) isomorphism
• Node uniqueness => Graph (node) isomorphism
• Default uniqueness
• Cardinality & path matching semantics
Let's fix this: Requirements
17
opencypher.orgopencypher.org | opencypher@googlegroups.com
• CIP 2017-01-18
• Uniqueness mode specifiers
• MATCH ALL (a)-[r*]->(b)
• MATCH UNIQUE RELATIONSHIPS
• MATCH UNIQUE NODES
• Subquery uniqueness mode specifiers
• MATCH [MODE] { ... }
• DO [MODE] { ... }
Let's fix this: Proposal
18
opencypher.orgopencypher.org | opencypher@googlegroups.com
• CIP 2017-01-18: Path predicates
• MATCH ALL p=()-[:T1*]->()<-[r:T2]->() WHERE ...
• node-isomorphic nodeUnique(p)
• relationship-isomorphic relUnique(p)
• has cycles | has no cycles open(p)|closed(p)
• no immediately repeated rels trek(p)
• no repeated cycles NOT redundant(p)
• ...
Let's fix this: Proposal
19
opencypher.orgopencypher.org | opencypher@googlegroups.com
That's it!
Questions ?
opencypher.orgopencypher.org | opencypher@googlegroups.com
(Conjunctive) Regular Path Queries
“Regular expressions over Graphs”
Tobias Lindaaker
tobias@neotechnology.com
opencypher.orgopencypher.org | opencypher@googlegroups.com
We’ve been wanting to do this for long
Been trying to find well balanced syntax
22
opencypher.orgopencypher.org | opencypher@googlegroups.com
Regular Path Patterns
• Disjunctions (unions) between patterns:
(a)-/alt1 | alt2 | alt3/-(b)
• Sequence of patterns:
(a)-/first second third/->(b)
• Repetition of pattern:
(a)<-/(many times)*/-(b)
• Definition of complex pattern predicates:
MATCH (a)-/complex/->(b)
PATH (x)-/complex/->(y) IS
(x)-[:LOVES]->(y), (y)-[:HATES]->(x)
• Shorthand for simple predicates:
(a)-/:REGULAR_RELATIONSHIP_TYPE/->(b)
• Combinations of the above
23
(CIP2017-02-06)
opencypher.orgopencypher.org | opencypher@googlegroups.com
Origins of the syntax in CIP2017-02-06
“Canterbury Style”
(from a meeting in Canterbury, summer 2015)
● In-line pattern expression
MATCH p=(a:Person{a})[
(x)-[:AUTHORED]->(:Book)<-[:AUTHORED]-(y)
WHERE x <> y
]*(b:Person{b})
RETURN p ORDER BY length(p) ASC LIMIT 1
Pros
● Pattern visible where used
Cons
● Large patterns, hard to overview
24
“PGQL Style”
(inspired by the path patterns in PGQL)
● Composition of simple pattern declarations
PATH CO_AUTHORED :=
(x)-[:AUTHORED]->(:Book)<-[:AUTHORED]-(y)
WHERE x <> y
MATCH p=(a:Person{a})-/CO_AUTHORED*/-(b:Person{b})
RETURN p ORDER BY length(p) ASC LIMIT 1
Pros
● No nested syntax, each pattern is clear
● Allows reuse of complex sub-pattern
● Pattern definitions align with “path-views”
Cons
● Definition removed from use
● Everything needs to be declared to be used
● Unclear which nodes are input, and which are
internal to a PATH pattern
opencypher.orgopencypher.org | opencypher@googlegroups.com
Syntax tradeoffs
Desirable
• Pattern visible where used
• No unnecessary ceremony
• Transparent complexity
• Familiar regular language
• Allow reuse of complex
sub-patterns
Undesirable
• Lots of details in patterns
- hard to view structure
• Definition of pattern
removed from use
• Very many ways to express
the same thing
25
opencypher.orgopencypher.org | opencypher@googlegroups.com
Evolving from Cypher today
• Limited support today:
• Disjunction on edge label: ()-[:A|B|C]->()
• Repetition of single edge: ()-[:X*]->()
• unhelpful when binding: ()-[x:X*]->() - binds as list!
• (these two forms can be combined)
• Regular Path Patterns
replace existing repetition syntax
• For CRPQs (Conjunctive Regular Path Queries)
Cypher need only add Regular Path Patterns,
it already has conjunctions
26
opencypher.orgopencypher.org | opencypher@googlegroups.com
Expressive powerComparing to GXPath (path expressions)
• ⟦ε⟧G
- {(v,v) | v ∈ V} - yes: PATH (a)-/nop/-(a) IS (a)
• ⟦_⟧G
- {(v,w)| (v,a,w) ∈ E for some a}
- yes: PATH (a)-/any/->(b) IS (a)-->(b)
• ⟦a⟧G
- {(v,w)| (v,a,w) ∈ E} - yes: (v)-/:a/->(w)
• ⟦a-
⟧G
= {(v,w) | (w,a,v) ∈ E} - yes: (v)-/<:a/->(w)
• ⟦ɑ*⟧G
= reflexive transitive closure of ɑ
- yes: ()-/ɑ*/->()
• ⟦ɑ · β⟧G
= ⟦ɑ⟧G
⟦β⟧G
- yes: ()-/ɑ β/->()
• ⟦ɑ ∪ β⟧G
= ⟦ɑ⟧G
∪ ⟦β⟧G
- yes: ()-/ɑ|β/->()
• ⟦¬ɑ⟧G
= V V - ⟦ɑ⟧G
- maybe:
PATH (v)-/not_alpha/->(w) IS (v), (w)
WHERE NOT EXISTS { (v)-/ɑ/->(w) }
Warning: the above is intractable, we might want to restrict to connected patterns
• ⟦[φ]⟧G
= {(v,v) | v ∈ ⟦φ⟧G
}
- yes: PATH (v)-/phi/-(v) IS (v) WHERE φ
• ⟦ɑn,m
⟧G
= ⋃k=n
m
(⟦ɑ⟧G
)k - yes: ()-/ɑ*n..m/->()
• ⟦ɑ=
⟧G
= {(v,w) ∈ ⟦ɑ=
⟧G
| ρ(v)=ρ(w)}
- yes: PATH (v)-/alpha_eq/->(w) IS (v)-/ɑ/->(w) WHERE v.ρ = w.ρ
• ⟦ɑ≠
⟧G
= {(v,w) ∈ ⟦ɑ=
⟧G
| ρ(v)≠ρ(w)}
- yes: PATH (v)-/alpha_not_eq/->(w) IS (v)-/ɑ/->(w) WHERE v.ρ <> w.ρ
• Conjunctions (for CRPQs): ⟦ɑ ∩ β⟧G
= ⟦ɑ⟧G
∪ ⟦β⟧G
- yes: PATH (v)-/alpha_and_beta/->(w) IS (v)-/ɑ/->(w), (v)-/β/->(w)
2
7
27Querying Graphs with Data - L.Libkin, W.Martens, D.Vrgoč
opencypher.orgopencypher.org | opencypher@googlegroups.com
Expressive power
Comparing to GXPath (node tests)
• ⟦⟨ɑ⟩⟧G
= {v | ∃w (v,w) ∈ ⟦ɑ⟧G
}
- yes: PATH (v)-/has_alpha/-(v) IS (v)-/ɑ/->()
• ⟦¬φ⟧G
= V - ⟦φ⟧G
- yes: PATH (v)-/not_phi/-(v) IS (v) WHERE NOT φ
• ⟦φ ∧ ψ⟧G
= ⟦φ⟧G
∩ ⟦ψ⟧G
- yes: PATH (v)-/phi_and_psi/-(v) IS (v) WHERE φ AND ψ
• ⟦φ ∨ ψ⟧G
= ⟦φ⟧G
∪ ⟦ψ⟧G
- yes: PATH (v)-/phi_or_psi/-(v) IS (v) WHERE φ OR ψ
• ⟦c=
⟧G
= {v ∈ V | ρ(v) = c}
- yes: PATH (v)-/rho_is_c/-(v) IS (v) WHERE v.ρ = c
• ⟦c≠
⟧G
= {v ∈ V | ρ(v) ≠ c}
- yes: PATH (v)-/rho_is_c/-(v) IS (v) WHERE v.ρ <> c
• ⟦⟨ɑ = β⟩⟧G
= {v ∈ V | ∃w,y (v,w)∈⟦ɑ⟧G
, (v,y)∈⟦β⟧G
, ρ(w)=ρ(y)}
- yes: PATH (v)-/alpha_eq_beta/-(v) IS
(v)-/ɑ/->(w), (v)-/β/->(y) WHERE w.ρ = y.ρ
• ⟦⟨ɑ ≠ β⟩⟧G
= {v ∈ V | ∃w,y (v,w)∈⟦ɑ⟧G
, (v,y)∈⟦β⟧G
, ρ(w)≠ρ(y)}
- yes: PATH (v)-/alpha_not_eq_beta/-(v) IS
(v)-/ɑ/->(w), (v)-/β/->(y) WHERE w.ρ <> y.ρ
2
8
28Querying Graphs with Data - L.Libkin, W.Martens, D.Vrgoč
opencypher.orgopencypher.org | opencypher@googlegroups.com
Can we do even better?
• Shorthand syntax for node labels
• Shorthand syntax for matching any edge
• Shorthand syntax for property predicates
• What is the scope of PATH declarations?
• ...and where in the query should they go?
• Beginning of query?
• Sub-clause of MATCH?
• Anywhere in the query?
• Can we parameterize PATH declarations?
• ...and use parameters for both input and output...
2
9
29
opencypher.orgopencypher.org | opencypher@googlegroups.com
<Your suggestion here>
What other features would
you like to see in Cypher?

More Related Content

What's hot

Cypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsCypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsopenCypher
 
Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...
Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...
Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...Goran S. Milovanovic
 
R Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In RR Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In RRsquared Academy
 
Introduction to R for Data Science :: Session 6 [Linear Regression in R]
Introduction to R for Data Science :: Session 6 [Linear Regression in R] Introduction to R for Data Science :: Session 6 [Linear Regression in R]
Introduction to R for Data Science :: Session 6 [Linear Regression in R] Goran S. Milovanovic
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesGábor Szárnyas
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programmingizahn
 
R Programming: Export/Output Data In R
R Programming: Export/Output Data In RR Programming: Export/Output Data In R
R Programming: Export/Output Data In RRsquared Academy
 
Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...
Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...
Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...Goran S. Milovanovic
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programaciónSoftware Guru
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with RShareThis
 
Beyond tf idf why, what & how
Beyond tf idf why, what & howBeyond tf idf why, what & how
Beyond tf idf why, what & howlucenerevolution
 
2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factorskrishna singh
 
R Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In RR Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In RRsquared Academy
 
OPTEX Mathematical Modeling and Management System
OPTEX Mathematical Modeling and Management SystemOPTEX Mathematical Modeling and Management System
OPTEX Mathematical Modeling and Management SystemJesus Velasquez
 
Hash presentation
Hash presentationHash presentation
Hash presentationomercode
 
Grouping & Summarizing Data in R
Grouping & Summarizing Data in RGrouping & Summarizing Data in R
Grouping & Summarizing Data in RJeffrey Breen
 
SQL window functions for MySQL
SQL window functions for MySQLSQL window functions for MySQL
SQL window functions for MySQLDag H. Wanvik
 

What's hot (20)

R language
R languageR language
R language
 
Cypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsCypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semantics
 
Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...
Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...
Introduction to R for Data Science :: Session 8 [Intro to Text Mining in R, M...
 
R Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In RR Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In R
 
Introduction to R for Data Science :: Session 6 [Linear Regression in R]
Introduction to R for Data Science :: Session 6 [Linear Regression in R] Introduction to R for Data Science :: Session 6 [Linear Regression in R]
Introduction to R for Data Science :: Session 6 [Linear Regression in R]
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
R Programming: Export/Output Data In R
R Programming: Export/Output Data In RR Programming: Export/Output Data In R
R Programming: Export/Output Data In R
 
Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...
Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...
Introduction to R for Data Science :: Session 7 [Multiple Linear Regression i...
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
 
Rtutorial
RtutorialRtutorial
Rtutorial
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with R
 
Beyond tf idf why, what & how
Beyond tf idf why, what & howBeyond tf idf why, what & how
Beyond tf idf why, what & how
 
2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors2. R-basics, Vectors, Arrays, Matrices, Factors
2. R-basics, Vectors, Arrays, Matrices, Factors
 
Grokking regex
Grokking regexGrokking regex
Grokking regex
 
R Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In RR Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In R
 
OPTEX Mathematical Modeling and Management System
OPTEX Mathematical Modeling and Management SystemOPTEX Mathematical Modeling and Management System
OPTEX Mathematical Modeling and Management System
 
Hash presentation
Hash presentationHash presentation
Hash presentation
 
Grouping & Summarizing Data in R
Grouping & Summarizing Data in RGrouping & Summarizing Data in R
Grouping & Summarizing Data in R
 
SQL window functions for MySQL
SQL window functions for MySQLSQL window functions for MySQL
SQL window functions for MySQL
 

Similar to Future features for openCypher: Schema, Constraints, Subqueries, Configurable Pattern Matching, Conjunctive regular Path Queries

Path Pattern Queries: Introducing Regular Path Queries in openCypher
Path Pattern Queries: Introducing Regular Path Queries in openCypherPath Pattern Queries: Introducing Regular Path Queries in openCypher
Path Pattern Queries: Introducing Regular Path Queries in openCypheropenCypher
 
MLconf NYC Shan Shan Huang
MLconf NYC Shan Shan HuangMLconf NYC Shan Shan Huang
MLconf NYC Shan Shan HuangMLconf
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for GraphsJean Ihm
 
Cypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in PrologCypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in PrologopenCypher
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Ruslan Shevchenko
 
Scoped dynamic rewrite rules
Scoped dynamic rewrite rulesScoped dynamic rewrite rules
Scoped dynamic rewrite rulesEelco Visser
 
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...Kazuki Yoshida
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Peng Cheng
 
Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Joachim Baumann
 
Extending lifespan with Hadoop and R
Extending lifespan with Hadoop and RExtending lifespan with Hadoop and R
Extending lifespan with Hadoop and RRadek Maciaszek
 
Neal Gafter Java Evolution
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolutiondeimos
 
Introductionto fp with groovy
Introductionto fp with groovyIntroductionto fp with groovy
Introductionto fp with groovyIsuru Samaraweera
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Data Con LA
 
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the CloudsGreg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the CloudsFlink Forward
 
Introduction to R
Introduction to RIntroduction to R
Introduction to Ragnonchik
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentationManav Prasad
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesopenCypher
 
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...openCypher
 

Similar to Future features for openCypher: Schema, Constraints, Subqueries, Configurable Pattern Matching, Conjunctive regular Path Queries (20)

Path Pattern Queries: Introducing Regular Path Queries in openCypher
Path Pattern Queries: Introducing Regular Path Queries in openCypherPath Pattern Queries: Introducing Regular Path Queries in openCypher
Path Pattern Queries: Introducing Regular Path Queries in openCypher
 
MLconf NYC Shan Shan Huang
MLconf NYC Shan Shan HuangMLconf NYC Shan Shan Huang
MLconf NYC Shan Shan Huang
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for Graphs
 
Cypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in PrologCypher.PL: Executable Specification of Cypher written in Prolog
Cypher.PL: Executable Specification of Cypher written in Prolog
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version]
 
Regular expression for everyone
Regular expression for everyoneRegular expression for everyone
Regular expression for everyone
 
Scoped dynamic rewrite rules
Scoped dynamic rewrite rulesScoped dynamic rewrite rules
Scoped dynamic rewrite rules
 
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...
Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag,...
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
 
Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)
 
Extending lifespan with Hadoop and R
Extending lifespan with Hadoop and RExtending lifespan with Hadoop and R
Extending lifespan with Hadoop and R
 
Neal Gafter Java Evolution
Neal Gafter Java EvolutionNeal Gafter Java Evolution
Neal Gafter Java Evolution
 
Introductionto fp with groovy
Introductionto fp with groovyIntroductionto fp with groovy
Introductionto fp with groovy
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
 
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the CloudsGreg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
Greg Hogan – To Petascale and Beyond- Apache Flink in the Clouds
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
An Intoduction to R
An Intoduction to RAn Intoduction to R
An Intoduction to R
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentation
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...
 

More from openCypher

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with CypheropenCypher
 
Formal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesFormal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesopenCypher
 
Multiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsMultiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsopenCypher
 
Micro-Servicing Linked Data
Micro-Servicing Linked DataMicro-Servicing Linked Data
Micro-Servicing Linked DataopenCypher
 
Graph abstraction
Graph abstractionGraph abstraction
Graph abstractionopenCypher
 
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...openCypher
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for GremlinopenCypher
 
Comparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypherComparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypheropenCypher
 
Multiple graphs in openCypher
Multiple graphs in openCypherMultiple graphs in openCypher
Multiple graphs in openCypheropenCypher
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateopenCypher
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for GremlinopenCypher
 
Supporting dates and times in Cypher
Supporting dates and times in CypherSupporting dates and times in Cypher
Supporting dates and times in CypheropenCypher
 
Seventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateSeventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateopenCypher
 
Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...openCypher
 
Property Graphs with Time
Property Graphs with TimeProperty Graphs with Time
Property Graphs with TimeopenCypher
 
Use case: processing multiple graphs
Use case: processing multiple graphsUse case: processing multiple graphs
Use case: processing multiple graphsopenCypher
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher
 
Cypher Editor in the Web
Cypher Editor in the WebCypher Editor in the Web
Cypher Editor in the WebopenCypher
 
The inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesThe inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesopenCypher
 
Formal Specification of Cypher
Formal Specification of CypherFormal Specification of Cypher
Formal Specification of CypheropenCypher
 

More from openCypher (20)

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with Cypher
 
Formal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesFormal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updates
 
Multiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsMultiple Graphs: Updatable Views
Multiple Graphs: Updatable Views
 
Micro-Servicing Linked Data
Micro-Servicing Linked DataMicro-Servicing Linked Data
Micro-Servicing Linked Data
 
Graph abstraction
Graph abstractionGraph abstraction
Graph abstraction
 
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for Gremlin
 
Comparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypherComparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and Cypher
 
Multiple graphs in openCypher
Multiple graphs in openCypherMultiple graphs in openCypher
Multiple graphs in openCypher
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status Update
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for Gremlin
 
Supporting dates and times in Cypher
Supporting dates and times in CypherSupporting dates and times in Cypher
Supporting dates and times in Cypher
 
Seventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateSeventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status Update
 
Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...
 
Property Graphs with Time
Property Graphs with TimeProperty Graphs with Time
Property Graphs with Time
 
Use case: processing multiple graphs
Use case: processing multiple graphsUse case: processing multiple graphs
Use case: processing multiple graphs
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)
 
Cypher Editor in the Web
Cypher Editor in the WebCypher Editor in the Web
Cypher Editor in the Web
 
The inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesThe inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queries
 
Formal Specification of Cypher
Formal Specification of CypherFormal Specification of Cypher
Formal Specification of Cypher
 

Recently uploaded

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 

Future features for openCypher: Schema, Constraints, Subqueries, Configurable Pattern Matching, Conjunctive regular Path Queries

  • 1. opencypher.orgopencypher.org | opencypher@googlegroups.com Schema and Constraints Mats Rydberg mats@neotechnology.com
  • 2. opencypher.orgopencypher.org | opencypher@googlegroups.com ● Cypher is schema-optional ● Fits well with heterogenous data ● Makes typing and query planning harder ● Does not fit well with many existing table-based engines ● Constraints are the only tools to enforce structure in the data Schema in Cypher is a point where we expect there to be major developments as more actors get involved. Schema in Cypher 2
  • 3. opencypher.orgopencypher.org | opencypher@googlegroups.com ● Consistent syntax for all types of constraints (CIP) ● Re-use as much as possible from the rest of the language ● Allow for a large set of future constraints, some of which are vendor-specific ● This allows vendors to use more strict schema when necessary CREATE CONSTRAINT <name> FOR <simple pattern> REQUIRE <constraint expression> New constraint syntax 3
  • 4. opencypher.orgopencypher.org | opencypher@googlegroups.com ● Property uniqueness constraint ➢ CREATE CONSTRAINT unique_person_names FOR (p:Person) REQUIRE UNIQUE p.firstName, p.lastName ● Property existence constraint ➢ CREATE CONSTRAINT person_must_have_firstName FOR (p:Person) REQUIRE exists(p.firstName) Constraints, examples 4
  • 5. opencypher.orgopencypher.org | opencypher@googlegroups.com ● Property value constraint ➢ CREATE CONSTRAINT roads_must_have_positive_finite_length FOR ()-[r:ROAD]-() REQUIRE 0 < r.distance < infinity ● Property type constraint ➢ CREATE CONSTRAINT people_schema FOR (p:Person) REQUIRE p.email IS STRING REQUIRE p.name IS STRING? REQUIRE p.age IS INTEGER? Constraints, examples 5
  • 6. opencypher.orgopencypher.org | opencypher@googlegroups.com ● Cardinality constraints ➢ CREATE CONSTRAINT spread_the_love FOR (p:Person) REQUIRE size((p)-[:LOVES]->()) > 3 ● Endpoint constraints ➢ CREATE CONSTRAINT can_only_own_things FOR ()-[:OWNS]->(t) REQUIRE (t:Vehicle) OR (t:Building) OR (t:Object) ● Label coexistence constraints ➢ CREATE CONSTRAINT programmers_are_people_too FOR (p:Programmer) REQUIRE p:Person Constraints, examples 6
  • 9. opencypher.orgopencypher.org | opencypher@googlegroups.com MATCH (actor:Actor) WHERE EXISTS { (actor)-[:ACTED_IN]->(movie), (other:Actor)-[:ACTED_IN]->(movie) WHERE other.name = actor.name AND actor <> other } RETURN actor Existential subqueries CIP 9
  • 10. opencypher.orgopencypher.org | opencypher@googlegroups.com MATCH (f:Farm {id: $farmId})-[:IS_IN]->(country:Country) MATCH { MATCH (u:User {id: $userId})-[:LIKES]->(b:Brand) RETURN b AS item, b.designedDate AS dateOfInterest UNION MATCH (u:User {id: $userId})-[:BOUGHT]->(v:Vehicle) WHERE v.leftHandDrive = country.leftHandDrive RETURN v AS item, v.manufacturedDate AS dateOfInterest } RETURN DISTINCT v.code ORDER BY dateOfInterest Nested correlated subqueries CIP 10
  • 11. opencypher.orgopencypher.org | opencypher@googlegroups.com MATCH (r:Root) DO { UNWIND range(1, 10) AS x MERGE (c:Child {id: x}) MERGE (r)-[:PARENT]->(c) } ● UNWIND manages the looping ● DO suppresses the increased cardinality from the inner query ● DO hides all new variable bindings (e.g. c) Nested read/write subqueries CIP 11
  • 12. opencypher.orgopencypher.org | opencypher@googlegroups.com MATCH (actor:Actor) WHERE actor.age > { MATCH (director:Director)-[:DIRECTED]->(:Movie) RETURN max(director.age) } RETURN actor.name, actor.details Scalar subqueries 12 CIR
  • 14. opencypher.orgopencypher.org | opencypher@googlegroups.com Homomorphic and Isomorphic Pattern Matching Stefan Plantikow stefan.plantikow@neotechnology.com
  • 15. opencypher.orgopencypher.org | opencypher@googlegroups.com • MATCH(a)-[r]->(b) ≡ { (a, r, b) V E V | r (a,b) } • MATCH (a)-[r1]->(b)-[r2]->(c) ≡ { (a, r1 , b, r2 , c) V E V E V | r 1 (a,b) r 2 (b,c) r1 ≠ r2 } • MATCH (a)-[rs*]->(b) ≡ { (a, rs, b) V E* V | rs * (a,b) rs=[...,r1 ...,r2 ,...] r1 ≠ r2 } Basic Pattern Matching Semantics 15
  • 16. opencypher.orgopencypher.org | opencypher@googlegroups.com • Why? • No uniqueness Potentially infinitely many matching paths • Node uniqueness Can't match self-loops • When? • All pattern variables in a MATCH • And similar constructs (comprehensions etc.) • Optional? • Not for variable length Default Uniqueness = Relationship Uniqueness 16
  • 17. opencypher.orgopencypher.org | opencypher@googlegroups.com • CIR 2017-174 • Defines uniqueness scope precisely • Add configurable uniqueness • No uniqueness => Graph homomorphism • Relationship uniqueness => Graph (relationship) isomorphism • Node uniqueness => Graph (node) isomorphism • Default uniqueness • Cardinality & path matching semantics Let's fix this: Requirements 17
  • 18. opencypher.orgopencypher.org | opencypher@googlegroups.com • CIP 2017-01-18 • Uniqueness mode specifiers • MATCH ALL (a)-[r*]->(b) • MATCH UNIQUE RELATIONSHIPS • MATCH UNIQUE NODES • Subquery uniqueness mode specifiers • MATCH [MODE] { ... } • DO [MODE] { ... } Let's fix this: Proposal 18
  • 19. opencypher.orgopencypher.org | opencypher@googlegroups.com • CIP 2017-01-18: Path predicates • MATCH ALL p=()-[:T1*]->()<-[r:T2]->() WHERE ... • node-isomorphic nodeUnique(p) • relationship-isomorphic relUnique(p) • has cycles | has no cycles open(p)|closed(p) • no immediately repeated rels trek(p) • no repeated cycles NOT redundant(p) • ... Let's fix this: Proposal 19
  • 21. opencypher.orgopencypher.org | opencypher@googlegroups.com (Conjunctive) Regular Path Queries “Regular expressions over Graphs” Tobias Lindaaker tobias@neotechnology.com
  • 22. opencypher.orgopencypher.org | opencypher@googlegroups.com We’ve been wanting to do this for long Been trying to find well balanced syntax 22
  • 23. opencypher.orgopencypher.org | opencypher@googlegroups.com Regular Path Patterns • Disjunctions (unions) between patterns: (a)-/alt1 | alt2 | alt3/-(b) • Sequence of patterns: (a)-/first second third/->(b) • Repetition of pattern: (a)<-/(many times)*/-(b) • Definition of complex pattern predicates: MATCH (a)-/complex/->(b) PATH (x)-/complex/->(y) IS (x)-[:LOVES]->(y), (y)-[:HATES]->(x) • Shorthand for simple predicates: (a)-/:REGULAR_RELATIONSHIP_TYPE/->(b) • Combinations of the above 23 (CIP2017-02-06)
  • 24. opencypher.orgopencypher.org | opencypher@googlegroups.com Origins of the syntax in CIP2017-02-06 “Canterbury Style” (from a meeting in Canterbury, summer 2015) ● In-line pattern expression MATCH p=(a:Person{a})[ (x)-[:AUTHORED]->(:Book)<-[:AUTHORED]-(y) WHERE x <> y ]*(b:Person{b}) RETURN p ORDER BY length(p) ASC LIMIT 1 Pros ● Pattern visible where used Cons ● Large patterns, hard to overview 24 “PGQL Style” (inspired by the path patterns in PGQL) ● Composition of simple pattern declarations PATH CO_AUTHORED := (x)-[:AUTHORED]->(:Book)<-[:AUTHORED]-(y) WHERE x <> y MATCH p=(a:Person{a})-/CO_AUTHORED*/-(b:Person{b}) RETURN p ORDER BY length(p) ASC LIMIT 1 Pros ● No nested syntax, each pattern is clear ● Allows reuse of complex sub-pattern ● Pattern definitions align with “path-views” Cons ● Definition removed from use ● Everything needs to be declared to be used ● Unclear which nodes are input, and which are internal to a PATH pattern
  • 25. opencypher.orgopencypher.org | opencypher@googlegroups.com Syntax tradeoffs Desirable • Pattern visible where used • No unnecessary ceremony • Transparent complexity • Familiar regular language • Allow reuse of complex sub-patterns Undesirable • Lots of details in patterns - hard to view structure • Definition of pattern removed from use • Very many ways to express the same thing 25
  • 26. opencypher.orgopencypher.org | opencypher@googlegroups.com Evolving from Cypher today • Limited support today: • Disjunction on edge label: ()-[:A|B|C]->() • Repetition of single edge: ()-[:X*]->() • unhelpful when binding: ()-[x:X*]->() - binds as list! • (these two forms can be combined) • Regular Path Patterns replace existing repetition syntax • For CRPQs (Conjunctive Regular Path Queries) Cypher need only add Regular Path Patterns, it already has conjunctions 26
  • 27. opencypher.orgopencypher.org | opencypher@googlegroups.com Expressive powerComparing to GXPath (path expressions) • ⟦ε⟧G - {(v,v) | v ∈ V} - yes: PATH (a)-/nop/-(a) IS (a) • ⟦_⟧G - {(v,w)| (v,a,w) ∈ E for some a} - yes: PATH (a)-/any/->(b) IS (a)-->(b) • ⟦a⟧G - {(v,w)| (v,a,w) ∈ E} - yes: (v)-/:a/->(w) • ⟦a- ⟧G = {(v,w) | (w,a,v) ∈ E} - yes: (v)-/<:a/->(w) • ⟦ɑ*⟧G = reflexive transitive closure of ɑ - yes: ()-/ɑ*/->() • ⟦ɑ · β⟧G = ⟦ɑ⟧G ⟦β⟧G - yes: ()-/ɑ β/->() • ⟦ɑ ∪ β⟧G = ⟦ɑ⟧G ∪ ⟦β⟧G - yes: ()-/ɑ|β/->() • ⟦¬ɑ⟧G = V V - ⟦ɑ⟧G - maybe: PATH (v)-/not_alpha/->(w) IS (v), (w) WHERE NOT EXISTS { (v)-/ɑ/->(w) } Warning: the above is intractable, we might want to restrict to connected patterns • ⟦[φ]⟧G = {(v,v) | v ∈ ⟦φ⟧G } - yes: PATH (v)-/phi/-(v) IS (v) WHERE φ • ⟦ɑn,m ⟧G = ⋃k=n m (⟦ɑ⟧G )k - yes: ()-/ɑ*n..m/->() • ⟦ɑ= ⟧G = {(v,w) ∈ ⟦ɑ= ⟧G | ρ(v)=ρ(w)} - yes: PATH (v)-/alpha_eq/->(w) IS (v)-/ɑ/->(w) WHERE v.ρ = w.ρ • ⟦ɑ≠ ⟧G = {(v,w) ∈ ⟦ɑ= ⟧G | ρ(v)≠ρ(w)} - yes: PATH (v)-/alpha_not_eq/->(w) IS (v)-/ɑ/->(w) WHERE v.ρ <> w.ρ • Conjunctions (for CRPQs): ⟦ɑ ∩ β⟧G = ⟦ɑ⟧G ∪ ⟦β⟧G - yes: PATH (v)-/alpha_and_beta/->(w) IS (v)-/ɑ/->(w), (v)-/β/->(w) 2 7 27Querying Graphs with Data - L.Libkin, W.Martens, D.Vrgoč
  • 28. opencypher.orgopencypher.org | opencypher@googlegroups.com Expressive power Comparing to GXPath (node tests) • ⟦⟨ɑ⟩⟧G = {v | ∃w (v,w) ∈ ⟦ɑ⟧G } - yes: PATH (v)-/has_alpha/-(v) IS (v)-/ɑ/->() • ⟦¬φ⟧G = V - ⟦φ⟧G - yes: PATH (v)-/not_phi/-(v) IS (v) WHERE NOT φ • ⟦φ ∧ ψ⟧G = ⟦φ⟧G ∩ ⟦ψ⟧G - yes: PATH (v)-/phi_and_psi/-(v) IS (v) WHERE φ AND ψ • ⟦φ ∨ ψ⟧G = ⟦φ⟧G ∪ ⟦ψ⟧G - yes: PATH (v)-/phi_or_psi/-(v) IS (v) WHERE φ OR ψ • ⟦c= ⟧G = {v ∈ V | ρ(v) = c} - yes: PATH (v)-/rho_is_c/-(v) IS (v) WHERE v.ρ = c • ⟦c≠ ⟧G = {v ∈ V | ρ(v) ≠ c} - yes: PATH (v)-/rho_is_c/-(v) IS (v) WHERE v.ρ <> c • ⟦⟨ɑ = β⟩⟧G = {v ∈ V | ∃w,y (v,w)∈⟦ɑ⟧G , (v,y)∈⟦β⟧G , ρ(w)=ρ(y)} - yes: PATH (v)-/alpha_eq_beta/-(v) IS (v)-/ɑ/->(w), (v)-/β/->(y) WHERE w.ρ = y.ρ • ⟦⟨ɑ ≠ β⟩⟧G = {v ∈ V | ∃w,y (v,w)∈⟦ɑ⟧G , (v,y)∈⟦β⟧G , ρ(w)≠ρ(y)} - yes: PATH (v)-/alpha_not_eq_beta/-(v) IS (v)-/ɑ/->(w), (v)-/β/->(y) WHERE w.ρ <> y.ρ 2 8 28Querying Graphs with Data - L.Libkin, W.Martens, D.Vrgoč
  • 29. opencypher.orgopencypher.org | opencypher@googlegroups.com Can we do even better? • Shorthand syntax for node labels • Shorthand syntax for matching any edge • Shorthand syntax for property predicates • What is the scope of PATH declarations? • ...and where in the query should they go? • Beginning of query? • Sub-clause of MATCH? • Anywhere in the query? • Can we parameterize PATH declarations? • ...and use parameters for both input and output... 2 9 29
  • 30. opencypher.orgopencypher.org | opencypher@googlegroups.com <Your suggestion here> What other features would you like to see in Cypher?