Efficient SPARQL to SQL
translation with user
defined mapping
Miloš Chaloupka and Martin Nečaský
XML and Web Engineering Research Group
Faculty of Mathematics and Physics
Charles University
Motivation
 RDF is great for publishing data
 Relational DBMS is the standard way how to store data
Efficient SPARQL to SQL translation
with user defined mapping
Rank DBMS Model Score
1 Oracle Relational 1425.56
2 MySQL Relational 1354.03
3 Microsoft SQL Server Relational 1211.55
33 MarkLogic Multi (incl. RDF) 10.15
73 Virtuoso Multi (incl. RDF) 2.50
83 Jena RDF store 2.11
http://db-engines.com/en/ranking
Motivation
 How to publish data stored in RDBMS in RDF format?
 Duplicate data
 Periodically create dump and import it to RDF store
 Virtual endpoint
 Provides access to data using a SPARQL endpoint
 Translates every query from SPARQL to SQL
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL SQL
Evolution of virtual endpoints
 D2R (initial version from 2004)
 http://d2rq.org/
 „state of the art“
 Multiple SQL queries for a single SPARQL query
Efficient SPARQL to SQL translation
with user defined mapping
Evolution of virtual endpoints
 Ultrawrap
 http://capsenta.com/
 Completely relying on the
RDBMS optimization engine
 Outperforms D2R
Efficient SPARQL to SQL translation
with user defined mapping
WITH t(s,s_r,p,o,o_r) AS (
SELECT "http://example.org/student/" + id AS s,
id AS s_r, "rdf:type" AS p, "ex:students" AS o,
NULL AS o_r
FROM students
UNION ALL
SELECT "http://example.org/student/" + id AS s,
id AS s_r, "ex:name" AS p, name AS o, NULL AS o_r
FROM students
)
SELECT t1.s AS iri, t2.o AS name
FROM t AS t1, t AS t2
WHERE
t1.p = "rdf:type" AND
t1.s_r = t2.s_r AND
t2.p = "ex:name"
Evolution of virtual endpoints
 Ontop
 http://ontop.inf.unibz.it/
 Single query without „view“
 Outperforms Ultrawrap
 Translates SPARQL query into SQL query and then optimizes it
 Candidate selection
 Self-join elimination
Efficient SPARQL to SQL translation
with user defined mapping
Processing query
Parse SPARQL query
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
SPARQL
SELECT ?iri ?name
WHERE {
?iri a ex:students;
ex:name ?name.
}
Algebra
AND
BGP1 BGP2
?iri rdf:type ex:students ?iri ex:name ?name
Processing query
Add mapping information
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
AND
∪ ∪
?iri rdf:type ex:students ?iri ex:name ?name
BGPr1
1 BGPrn
1
... BGPr1
1 BGPrn
2
...
Processing query
Candidate selection
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
AND
BGPr4
1 ∪
BGPr3
2 BGPr7
2
?iri rdf:type ex:students ?iri ex:name ?name
Processing query
Join of unions
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
∪
AND AND
BGPr4
1 BGPr3
2
BGPr4
1 BGPr7
2
?iri rdf:type ex:students ?iri rdf:type ex:students?iri ex:name ?name ?iri ex:name ?name
Processing query
Candidate selection (again)
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
AND
BGPr4
1 BGPr3
2
?iri rdf:type ex:students ?iri ex:name ?name
Processing query
Transform to SQL
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
𝑖𝑑 𝑖𝑑, 𝑛𝑎𝑚𝑒 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠,
𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑 }
𝑖𝑑, 𝑛𝑎𝑚𝑒 𝑖𝑑, 𝑛𝑎𝑚𝑒 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠,
𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙(𝑛𝑎𝑚𝑒)}
AND
Processing query
Transform to SQL (cont.)
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
{ 𝑖𝑑1, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2
∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑1 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑2 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑛𝑎𝑚𝑒2 ,
𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑1 ∨ 𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑2 ∨ (𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑1
= 𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑2 )}
Processing query
Simplify conditions
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
{ 𝑖𝑑1, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2
∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑1 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑2 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑛𝑎𝑚𝑒2 , 𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑1
∨ 𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑2 ∨ (𝑖𝑑1 = 𝑖𝑑2)}
Processing query
Simplify conditions (cont.)
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
{ 𝑖𝑑1, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑1 = 𝑖𝑑2}
Processing query
Self-join optimization
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
{ 𝑖𝑑1, 𝑛𝑎𝑚𝑒1| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠}
Processing query
SQL query
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
SELECT id, name FROM students
?iri 𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑
?name 𝑛𝑎𝑚𝑒
Processing query
SQL query
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
 SQL query is executed and the
query results are being retriever
 The returned columns does not
contain the SPARQL values directly
Processing query
SQL query
Efficient SPARQL to SQL translation
with user defined mapping
SPARQL
SPARQL with mapping
SQL with value bindingsSQL results
SPARQL results
RDBMS
R2RML
?iri 𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑
?name 𝑛𝑎𝑚𝑒
EVI - Evaluation
Efficient SPARQL to SQL translation
with user defined mapping
#1 #2 #3 #4 #5
Evi 38 69 53 128 1291
Ontop 135 118 121 185 1658
1
10
100
1000
10000
Executiontime[ms]
Query
Thank you for your attention
Miloš Chaloupka Martin Nečaský
chaloupka@ksi.mff.cuni.cz necasky@ksi.mff.cuni.cz
@ChaloupkaMilos
XML and Web Engineering Research Group
Faculty of Mathematics and Physics
Charles University
Efficient SPARQL to SQL translation
with user defined mapping

Efficient SPARQL to SQL translation with user defined mapping

  • 1.
    Efficient SPARQL toSQL translation with user defined mapping Miloš Chaloupka and Martin Nečaský XML and Web Engineering Research Group Faculty of Mathematics and Physics Charles University
  • 2.
    Motivation  RDF isgreat for publishing data  Relational DBMS is the standard way how to store data Efficient SPARQL to SQL translation with user defined mapping Rank DBMS Model Score 1 Oracle Relational 1425.56 2 MySQL Relational 1354.03 3 Microsoft SQL Server Relational 1211.55 33 MarkLogic Multi (incl. RDF) 10.15 73 Virtuoso Multi (incl. RDF) 2.50 83 Jena RDF store 2.11 http://db-engines.com/en/ranking
  • 3.
    Motivation  How topublish data stored in RDBMS in RDF format?  Duplicate data  Periodically create dump and import it to RDF store  Virtual endpoint  Provides access to data using a SPARQL endpoint  Translates every query from SPARQL to SQL Efficient SPARQL to SQL translation with user defined mapping SPARQL SQL
  • 4.
    Evolution of virtualendpoints  D2R (initial version from 2004)  http://d2rq.org/  „state of the art“  Multiple SQL queries for a single SPARQL query Efficient SPARQL to SQL translation with user defined mapping
  • 5.
    Evolution of virtualendpoints  Ultrawrap  http://capsenta.com/  Completely relying on the RDBMS optimization engine  Outperforms D2R Efficient SPARQL to SQL translation with user defined mapping WITH t(s,s_r,p,o,o_r) AS ( SELECT "http://example.org/student/" + id AS s, id AS s_r, "rdf:type" AS p, "ex:students" AS o, NULL AS o_r FROM students UNION ALL SELECT "http://example.org/student/" + id AS s, id AS s_r, "ex:name" AS p, name AS o, NULL AS o_r FROM students ) SELECT t1.s AS iri, t2.o AS name FROM t AS t1, t AS t2 WHERE t1.p = "rdf:type" AND t1.s_r = t2.s_r AND t2.p = "ex:name"
  • 6.
    Evolution of virtualendpoints  Ontop  http://ontop.inf.unibz.it/  Single query without „view“  Outperforms Ultrawrap  Translates SPARQL query into SQL query and then optimizes it  Candidate selection  Self-join elimination Efficient SPARQL to SQL translation with user defined mapping
  • 7.
    Processing query Parse SPARQLquery Efficient SPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML SPARQL SELECT ?iri ?name WHERE { ?iri a ex:students; ex:name ?name. } Algebra AND BGP1 BGP2 ?iri rdf:type ex:students ?iri ex:name ?name
  • 8.
    Processing query Add mappinginformation Efficient SPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML AND ∪ ∪ ?iri rdf:type ex:students ?iri ex:name ?name BGPr1 1 BGPrn 1 ... BGPr1 1 BGPrn 2 ...
  • 9.
    Processing query Candidate selection EfficientSPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML AND BGPr4 1 ∪ BGPr3 2 BGPr7 2 ?iri rdf:type ex:students ?iri ex:name ?name
  • 10.
    Processing query Join ofunions Efficient SPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML ∪ AND AND BGPr4 1 BGPr3 2 BGPr4 1 BGPr7 2 ?iri rdf:type ex:students ?iri rdf:type ex:students?iri ex:name ?name ?iri ex:name ?name
  • 11.
    Processing query Candidate selection(again) Efficient SPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML AND BGPr4 1 BGPr3 2 ?iri rdf:type ex:students ?iri ex:name ?name
  • 12.
    Processing query Transform toSQL Efficient SPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML 𝑖𝑑 𝑖𝑑, 𝑛𝑎𝑚𝑒 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑 } 𝑖𝑑, 𝑛𝑎𝑚𝑒 𝑖𝑑, 𝑛𝑎𝑚𝑒 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙(𝑛𝑎𝑚𝑒)} AND
  • 13.
    Processing query Transform toSQL (cont.) Efficient SPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML { 𝑖𝑑1, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑1 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑2 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑛𝑎𝑚𝑒2 , 𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑1 ∨ 𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑2 ∨ (𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑1 = 𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑2 )}
  • 14.
    Processing query Simplify conditions EfficientSPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML { 𝑖𝑑1, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑1 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑖𝑑2 , 𝑛𝑜𝑡𝑛𝑢𝑙𝑙 𝑛𝑎𝑚𝑒2 , 𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑1 ∨ 𝑖𝑠𝑛𝑢𝑙𝑙 𝑖𝑑2 ∨ (𝑖𝑑1 = 𝑖𝑑2)}
  • 15.
    Processing query Simplify conditions(cont.) Efficient SPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML { 𝑖𝑑1, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑2, 𝑛𝑎𝑚𝑒2 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠, 𝑖𝑑1 = 𝑖𝑑2}
  • 16.
    Processing query Self-join optimization EfficientSPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML { 𝑖𝑑1, 𝑛𝑎𝑚𝑒1| 𝑖𝑑1, 𝑛𝑎𝑚𝑒1 ∈ 𝑠𝑡𝑢𝑑𝑒𝑛𝑡𝑠}
  • 17.
    Processing query SQL query EfficientSPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML SELECT id, name FROM students ?iri 𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑 ?name 𝑛𝑎𝑚𝑒
  • 18.
    Processing query SQL query EfficientSPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML  SQL query is executed and the query results are being retriever  The returned columns does not contain the SPARQL values directly
  • 19.
    Processing query SQL query EfficientSPARQL to SQL translation with user defined mapping SPARQL SPARQL with mapping SQL with value bindingsSQL results SPARQL results RDBMS R2RML ?iri 𝑐𝑜𝑛𝑐𝑎𝑡 ′http://example.org/student/′, 𝑖𝑑 ?name 𝑛𝑎𝑚𝑒
  • 20.
    EVI - Evaluation EfficientSPARQL to SQL translation with user defined mapping #1 #2 #3 #4 #5 Evi 38 69 53 128 1291 Ontop 135 118 121 185 1658 1 10 100 1000 10000 Executiontime[ms] Query
  • 21.
    Thank you foryour attention Miloš Chaloupka Martin Nečaský chaloupka@ksi.mff.cuni.cz necasky@ksi.mff.cuni.cz @ChaloupkaMilos XML and Web Engineering Research Group Faculty of Mathematics and Physics Charles University Efficient SPARQL to SQL translation with user defined mapping