W3C logo
slanted W3C logo

SPARQLt-SPARQLn-SQLn

RDF-to-RDF and RDF-to-relational query transformation in SWObjects.


Eric Prud'hommeaux, Sanitation Engineer. Last modified: $Date: 2009/12/08 15:26:00 $
Creative Commons License This work is licensed under a Creative Commons Attribution 3.0 License, with attribution to W3C.

Valid XHTML + RDFa

Databases as RDF

trivial to dump RDB as RDF

test: is the graph query coherent (do generated node identifiers merge)?

ETL needs

Sociopathic RDF graph

?who mydb:fn ?name

Need interface graph

?who foaf:name ?name

RDB2RDF Mission

The charter says to map RDBs to RDF/OWL.

Standards Goal

clear algebra for:

SPARQL->SQL

abstract syntax tree
Patterns Modifiers Query Forms
RDF terms DISTINCT SELECT
triple patterns REDUCED CONSTRUCT
Basic graph patterns PROJECT DESCRIBE
Groups ORDER BY ASK
OPTIONAL LIMIT  
UNION OFFSET
GRAPH  
FILTER
SPARQL algebra terms
Graph Pattern Solution Modifiers
BGP ToList
Join OrderBy
LeftJoin Project
Filter Distinct
Union Reduced
Graph Slice
SQL algebra subset
Graph Pattern Solution Modifiers Evaluation
ProjectAlias MultiSet NULL
TableAlias OrderBy  
Join Project
LeftJoin Distinct
Constraint Reduced
Union offset/limit

Simple Mapping from RDB to RDF

test: does the StemGraph meet the same use cases as the relational data?

Virtualizing the StemGraph

test: does RelQuery(RelData) == StemQuery(StemGraph)?

BGP Algebra factored

VARconstraint(VAR, FQAttribute):
    if bindings[VAR]) equivs.insert(FQAttribute= bindings[VAR]
    bindings[VAR]= FQAttribute
URIconstraint(URI) => Value:
    (Rel, Attr, Value) = match(URI, stemURI + '/' (\w+) '/' (\w+) '.' (\w+) '#record')
    some Alias = hash(Rel + URI)
    joins.insert(Rel AS Attr)
    pk = primary_key_attribute(Rel)
    equivs.insert(Alias.pk= Value)
    Value

(Rel, Attr) = match(P, stemURI + '/' + (\w+) + '#' (\w+))
some Alias = hash(Rel + S)
join.insert(Rel AS Alias)
pk = primary_key_attribute(Rel)
    match S with
      VAR -> VARconstraint(S, Alias.pk)
      URI -> URIconstraint(S)
    match O with
      LITERAL -> equivs.insert(alias.attr= O)
      VAR -> VARconstraint(O, Alias.Attr)
      URI -> equivs.insert(Alias.Attr= URIconstraint(O))

What's in the Algebra?

Conjunction

Employees
idmanagersection
14sales
4NULLexec
Emp:id=1 emp:id 1 .             
Emp:id=1 emp:manager Emp:id=4 .	
Emp:id=1 emp:section "sales" .  
Emp:id=4 emp:id 4 .	        
                        	
Emp:id=4 emp:manager "exec" .   
	
Tasks
employeeleadname
14widgets
45widgets
_:t1 task.employee Emp:id=1 .
_:t1 task.lead Emp:id=2 .    
_:t1 task.name "widgets" .   
_:t2 task.employee Emp:id=4 .
_:t2 task.lead Emp:id=5 .    
_:t2 task.name "widgets".    
	
SELECT ?sec ?name
 WHERE { GRAPH<HQ>    { ?flunky emp:section ?sec OPTIONAL { ?flunky emp:manager ?boss } }
         GRAPH<Sales> { _:t task:employee ?flunky; task:lead ?boss; task:name ?task } }
      
SPARQL
flunkybosssectask
Emp:id=1Emp:id=4"sales""widgets"
Emp:id=4"exec""widgets"
SQL join
flunkybosssectask
14saleswidgets

OPTIONALs

NULL guards

Operators

Interface Graph

Performance

Integrity Constraints

CONSTRUCT { ?x shop:name ?name ; shop:price ?price }
    WHERE { ?x db:name ?name ; db:price ?price }
SELECT ?name
 WHERE { <...Items/id=5#record> shop:name ?name ; shop:price ?price }

Required Integrity Constraint

CONSTRUCT { ?x a shop:SaleItem ; shop:name ?name ; shop:price ?price }
    WHERE { ?x db:name ?name ; db:price ?price ; db:discount ?discount
            FILTER (?discount > 0.0) }
SELECT ?cost
 WHERE { <...Items/id=5#record> a shop:SaleItem ;
                                shop:name ?name ;
                                shop:price ?price }

Integrity Constraint Options

CONSTRUCT usefull elsewhere

Useful for:

HCLS Requirements

What requirements to we have?

requirements feedback through:

tech space

systemexpressivity
Virtuosod2r/DDL
TriplifySQL->app?
D2Rd2r
MetatomixGUI
UltrawrapDDL
OracleDDL
SWObjectsCONSTRUCT
OKKAM???