slanted W3C logo
Cover page images (keys)

Direct Mapping of RDBs to RDF

Alexandre Bertails, <bertails@w3.org>
Eric Prud'hommeaux, <eric@w3.org>
Health Care & Life Sciences IG, <public-semweb-lifesci@w3.org>

This talk: <http://w3.org/brief/MjQx>

Web Zealots

View the world's data in the SemWeb.

This talk: <http://w3.org/brief/MjQx>

(W3C) Use Cases

eGov
Publication/access to civil data.
Life Sciences
SPARQL query of decentralized biomedical data.
Health Care
Matching coded clinical protocols.

This talk: <http://w3.org/brief/MjQx>

Database to DLG

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Database to DLG

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Database to DLG

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Database to DLG

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Database to DLG

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Direct Mapping

People
PK→ Address(ID)
IDfnameaddr
7Bob18
8SueNULL
Addresses
PK
IDcitystate
18CambridgeMA
<People/ID=7> <People#ID> 7 .
<People/ID=7> <People#fname> "Bob" .
<People/ID=7> <People#addr> <Addresses/ID=18> .

<People/ID=8> <People#ID> 8 .
<People/ID=8> <People#fname> "Sue" .

<Addresses/ID=18> <Addresses#ID> 18 .
<Addresses/ID=18> <Addresses#city> "Cambridge" .
<Addresses/ID=18> <Addresses#state> "MA" .
      

Direct Graph

<People/ID=7> <People#ID> 7 .

<People/ID=7> <People#fname> "Bob" .
<People/ID=7> <People#addr> <Addresses/ID=18> .
<People/ID=8> <People#ID> 8 .

<People/ID=8> <People#fname> "Sue" .

<Addresses/ID=18> <Addresses#ID> 18 .
<Addresses/ID=18> <Addresses#city> "Cambridge" .

<Addresses/ID=18> <Addresses#state> "MA" .
      

RDB2RDF Approaches

R2RML
D2R-like mapping declaration
Virtuoso RDF Views
DDL-like definition of an RDF graph
SquirrelRDF, Direct Mapping
   simple dump of data.
+ rules

Rules Languages

The semantics align well, but implementations focus on different use case optimizations.

CONSTRUCT Usage Patterns

   PREFIX :mydb <http://cityhospital.example/dbs>
CONSTRUCT { ?o a               study:SubjectObservation .
            ?o study:subject   ?p .
            ?o study:clinician ?d .
            ?d :foaf:name ?dName }

    WHERE { ?o mydb:patient ?p .
            ?o mydb:doctor  ?d .
            ?d mydb:name    ?dName }

5-star Data

What makes data sharable?

SPARQL1.1 strings and term constructors

Domain-appropriate Views

Query Transformation

SELECT ?o ?d
 WHERE {
   ?o study:subject <Bob> .
   <Bob> study:clinician ?d .
 }
SELECT ?o ?d
 WHERE {
   ?o mydb:onPatient <Bob> .
   ?o mydb:byDoctor ?d .
 }
SELECT observations... doctors...
  FROM observations, 
   patients ON id=observations.patient ...
   WHERE patients.name = "Bob"

SPARQL to SQL

How easy will it be to turn a query over the above graph
into an SQL query over the input tables?

SELECT ?name
 WHERE {
   ?who db:name "Bob" .
   ?who db:manager ?boss .
   ?boss db:name ?name .
 }
SELECT boss.name
FROM Employees AS who
INNER JOIN Employees AS boss ON boss.id=who.manager
WHERE who.name="Bob"

SPARQL to SPARQL

Function Inversion

Resolve as much as possible;
huge impact on performance.

{ <http://www.uniprot.org/uniprot/P04637> skos:prefLabel ?symbol }

=>

SELECT (fn:lower-case(?_uniProt_0_u_gene_symbol) AS ?symbol) 
 WHERE {
   _:_uniProt_0_gene <http://ucsc.example/uniProt/gene#acc> "P04637"  .
   _:_uniProt_0_gene <http://ucsc.example/uniProt/gene#val> ?_uniProt_0_u_gene_symbol .
}

=>

SELECT TOLOWER(uniProt.val) AS ?symbol
FROM uniProt WHERE acc = "P04637"
SELECT TOLOWER(uniProt.val) AS ?symbol
FROM uniProt WHERE CONCAT("http://www.uniprot.org/uniprot/", uniprot.acc) =
                          "http://www.uniprot.org/uniprot/P04637"

Function Inversion

Resolve as deeply as possible.

Questions/Comments