Title: Semantics and Complexity of SPARQL By: JORGE PE
1Semantics and Complexity of SPARQLBy JORGE
PEREZ and MARCELO ARENASPontificia Universidad
Cat olica de ChileandCLAUDIO
GUTIERREZUniversidad de ChilePresenterNiral
Zaveri
2What is SPARQL ?
- SQL-like query language for RDF.
- What is RDF.?
- Resource Description Framework is a data model
for representing information about World Wide Web
resources. - It represents the information in a Directed
labeled graph just like an ER-diagram in a
relational database. - SPARQL is essentially a graph-matching query
language. - It has a recommendation of the W3C as of January
15, 2008.
3RDF Graph
- RDF Triple ltsubject, predicate, objectgt
Teachers
name
name
Fred
Joe
knows
t1
t2
43
CS
age
faculty
4 SPARQL Query Syntax
- Graph-matching query language having form of H ?
B, - where B is the body of the query and H is the
Head of the query. - B A Complex RDF graph pattern expression.
- H An expression that indicates how to construct
the answer to the query. -
-
-
5SPARQL Query Evaluation
?teacher
Professor
Variables are matched against the input graph
?name
Teachers
title
?faculty
t1
t2
?title unbound
faculty
faculty
name
name
SELECT ?name ?faculty ?title WHERE ?teacher
rdftype Teachers. ?teacher name ?name.
?teacher faculty ?faculty. OPTIONAL
?teacher title ?title.
Joe
Fred
CS
CS
?name ?faculty ?title
Joe CS
Fred CS Professor
6Complexity of SPARQL
- In general What is the influence of each
component of the language in this complexity? - How difficult it is to verify whether a given
mapping is a solution for a pattern evaluated
over an RDF dataset.
Theorem Operators Complexity
1 AND and FILTER O(P.D)
2 AND,FILTER and UNION NP-complete
3 AND,FILTER and OPT PSPACE-complete
4 AND,UNION and OPT PSPACE-complete
7Reducing Complexity
- An important question is whether one can find
interesting classes of graph patterns,
constructed by imposing simple and natural
syntactic restrictions. - Managed to lower the complexity of the
AND-FILTER-UNION fragment by imposing a simple
normal form.
8Well-Designed Graph Patterns
- One of the most delicate issues in the definition
of a semantics for graph pattern expressions is
the semantics of the OPT operator. - The idea is to allow optional matching of
patterns. - The complexity of evaluating well-designed graph
pattern expression is lower than in the general
case.
9Optimization of Well-Designed Patterns
- The classical results of optimizing the
outer-join query are not directly applicable in
the SPRQL context. - In SPARQL, the null-rejecting predicates are
implicit in the variables that graph patterns
share and they are never null rejecting. - Some specific techniques are needed.
- Result All AND and FILTER operations are
executed prior to the execution of the OPT
operations.
10Related Work
- Semantics
- Two proposals
- Operational Semantics depth-first traversal
- Compositional Semantics bottom-up evaluation
- Cyganiak presents a relational model of SPARQL
- Harris and Shadbolt presents an implementation of
a simple fragment of SPARQL in a relational
database engine. - De Bruijn study the semantics of the conjunctive
fragment of SPARQL
11Other proposal for RDF query languages
- Gutierrez discuss the basic issues of the
semantics and complexity of a conjunctive query
language for RDF. - Haase present a comparison of functionalities of
pre-SPARQL query languages. - Furche presents another in-depth comparison of
RDF query languages, in terms of their constructs
and evaluation methods. - Several proposals of having an Algebraic query
language for RDF.
12Complexity and Optimization
- Mapping a known query language Q (algebra/SQL)
into SPARQL graph patterns. - There is no complexity study of the fragment of
relational algebra/SQL. - Notion of Join-Tree
- A possible way to optimize SPARQL queries is to
map SPARQL graph patterns into relational
algebra/SQL queries.
13Conclusion
- Semantics played a key role.
- Formalization of a semantics is beneficial.
- The unlimited use of optional parts in the graph
patterns could lead to high complexity. - Well-designed graph patterns.
- Provide several rules which may have a
considerable - impact in the cost of evaluating SPARQL queries.
14Thank You
Questions are invited.