W3C logo
slanted W3C logo

RDF Access to Relational Databases

W3C Semantic Web in Health Care and Life Sciences.


Eric Prud'hommeaux, Sanitation Engineer.
URL: http://w3.org/brief/MTYw
Last modified: $Date: 2010/03/16 19:03:21 $
Creative Commons License This work is licensed under a Creative Commons Attribution 3.0 License, with attribution to W3C.

Valid XHTML + RDFa

What's RDF?

Directed-labeled graph of propositions.

Using Existing Data(bases)

[unrendered SVG image of HL7 data in a relational database]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Using Existing Data(bases)

[unrendered SVG image of HL7 data in RDF]

[unrendered SVG image of HL7 data in RDF]

Simple assertions

boring example here,
exciting for e.g. drug classification.

... about people, ...

... medicine, ...

... life sciences, ...

... in one universe.

Integrate Databases

Perform Queries

HCLS demo #2 query: SPARQL query over MeSH, PubMed, Entrez Gene, GO

Publish (existence of) Answers

Alzgene query results

What's in it for us?

most of the world's data
is in documents

books

Leverage Web architecture

loom

Scripting

spaghetti

Declarative

   PREFIX :study <http://cdisc.example/sdtm>
   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 }

Mashups become queries.

SERVICE <http://uu3.org:8888/7tm_receptors>
  {
    ?iuphar  iface:family      ?family .
    ?iuphar  iface:code	       ?code .
    ?iuphar  iface:iupharName  ?iupharNm .
    ?human   iface:iuphar      ?iuphar .
    ?human   iface:geneName    "GABBR1" .
    ?human   iface:entrezGene  ?humanEntrez .
  }
SERVICE <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&>

  {
     _:gene  dbp:entrezgene    ?humanEntrez ;
             rdfs:label        ?label ;
    FILTER (lang(?label) = "en")
  }
SERVICE <http://hcls.deri.org/atag/data/gabab_example.html>
  {
     ?topic  rdfs:label        ?label .
     ?post   sioc:topic        ?topic
  }

Scientific statements

Statements about scientific statements

Uniform Protocol

HTTP protocol, marshaling consistent with HTML forms.
SPARQL URL =

  1. Endpoint (e.g. http://example.org/sparql)
  2. + "named-graph-uri=" data sources (e.g. named-graph-uri=http://example.org/reviews/ebert
  3. + "query=" + form-url-encoded query (e.g. query=SELECT+%3Fpatient…)
http://example.org/sparql?named-graph-uri=http%3A%2F%2Fexample.orgm%2F
reviews%2Febert&query=SELECT+%3Freview_graph+WHERE+%7B%0D%0A++GRAPH+%3Frev
iew_graph+%7B%0D%0A+++++%3Freview+rev%3Arating+10+.%0D%0A++%7D%0D%0A%7D

Sacrifices

Thesis: triples of URIs promote sharing semantics.

At what cost?

Real hospital database

Real Hospital Database as RDF

... Sharable RDF

   PREFIX :study <http://cdisc.example/sdtm>
   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 }

Query Transformation

PREFIX db: <…>
SELECT ?o ?d
 WHERE {
   ?o db:onPatient <Bob> .
   ?o db:byDoctor ?d .
 }

PREFIX db: <…>
SELECT observations... doctors...
  FROM observations, 
   patients ON id=observations.patient ...
   WHERE patients.name = "Bob"
 }

Use existing data.

LOD cloud

Contribute some of your own.

LODD cloud

RDB2RDF Working Group

What I want from you.

uncle sam

RDF Formats

Turtle Example: Blood Pressure






<encounter7> edns:patient <patient3> .

<patient3>   r:type galen:Patient ;
             foaf:family_name "Levin" ;
             foaf:firstName "Henry" .



      

Turtle Example: Blood Pressure






<encounter7> edns:patient <patient3> ;
             edns:screeningBP <s20090714c> .
<patient3>   r:type galen:Patient ;
             foaf:family_name "Levin" ;
             foaf:firstName "Henry" .
<s20090714c> dc:date "2009-07-14T18:23"^^xsd:dateTime ;
             edns:systolic "132"^^edns:mmHg ;
             edns:diastolic "86"^^edns:mmHg .
             
      

Turtle Example: Blood Pressure

@prefix edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix galen: <http://www.co-ode.org/ontologies/galen#> .
@prefix snomed: <http://termhost.example/SNOMED/> .

<encounter7> edns:patient <patient3> ;
             edns:screeningBP <s20090714c> .
<patient3>   r:type galen:Patient ;
             foaf:family_name "Levin" ;
             foaf:firstName "Henry" .
<s20090714c> dc:date "2009-07-14T18:23"^^xsd:dateTime ;
             edns:systolic "132"^^edns:mmHg ;
             edns:diastolic "86"^^edns:mmHg .
             

Turtle Example: Blood Pressure

@prefix edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix galen: <http://www.co-ode.org/ontologies/galen#> .
@prefix snomed: <http://termhost.example/SNOMED/> .

<encounter7> edns:patient <patient3> ;
             edns:screeningBP <s20090714c> .
<patient3>   r:type galen:Patient ;
             foaf:family_name "Levin" ;
             foaf:firstName "Henry" .
<s20090714c> dc:date "2009-07-14T18:23"^^xsd:dateTime ;
             edns:systolic "132"^^edns:mmHg ;
             edns:diastolic "86"^^edns:mmHg ;
             edns:posture snomed:_163035008 . # SNOMED:sitting

RDF/XML Example: Blood Pressure

<rdf:RDF xmlns:edns="http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#"
	 xmlns:foaf: "http://xmlns.com/foaf/0.1/" .
	 xmlns:galen: "http://www.co-ode.org/ontologies/galen#" .
	 xmlns:snomed: "http://termhost.example/SNOMED/">
<rdf:Description rdf:about="encounter7">
  <edns:patient rdf:resource="patient3"/>
  <edns:screeningBP>s20090714c</edns:screeningBP>
</rdf:Description>
<galen:Patient rdf:about="patient3" foaf:family_name="Levin" foaf:firstName="Henry">
<rdf:Description rdf:about="s20090714c">
  <dc:date xsi:dt="http://www.w3.org/2001/XMLSchemadateTime">2009-07-14T18:23</dc:date>
  <edns:systolic xsi:dt="http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#mmHg">132</edns:systolic>
  <edns:diastolic xsi:dt="http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#mmHg">86</edns:systolic>
  <edns:posture rdf:resource="http://termhost.example/SNOMED/_163035008</edns:posture> <!-- SNOMED:sitting -->
</rdf:Description>

SPARQL Example: ER Blood Pressure Query

PREFIX edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX galen: <http://www.co-ode.org/ontologies/galen#>
PREFIX snomed: <http://termhost.example/SNOMED/>

SELECT ?date ?systolic ?diastolic WHERE {

?encounter edns:patient     ?patient ;
           edns:screeningBP ?screenBP .
?patient   foaf:family_name "Levin" ;
           foaf:firstName   "Henry" .
?screenBP  dc:date          ?date ;
           edns:systolic    ?systolic ;
           edns:diastolic   ?diastolic ;
} ORDER DESC BY ?date

SPARQL Example: Study Blood Pressure Query

PREFIX edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX galen: <http://www.co-ode.org/ontologies/galen#>
PREFIX snomed: <http://termhost.example/SNOMED/>

SELECT ?date ?systolic ?diastolic WHERE {

?encounter edns:patient     ?patient ;
           edns:screeningBP ?screenBP .
?patient   foaf:family_name "Levin" ;
           foaf:firstName   "Henry" .
?screenBP  dc:date          ?date ;
           edns:systolic    ?systolic ;
           edns:diastolic   ?diastolic ;
           edns:posture ?posture . # SNOMED:sitting
FILTER (?posture = snomed:_163035008 || ?posture = snomed:_163035009)
} ORDER DESC BY ?date

SPARQL Example: Study Blood Pressure Query

PREFIX edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX galen: <http://www.co-ode.org/ontologies/galen#>
PREFIX snomed: <http://termhost.example/SNOMED/>

SELECT ?date ?systolic ?diastolic ?posture WHERE {

?encounter edns:patient     ?patient ;
           edns:screeningBP ?screenBP .
?patient   foaf:family_name "Levin" ;
           foaf:firstName   "Henry" .
?screenBP  dc:date          ?date ;
           edns:systolic    ?systolic ;
           edns:diastolic   ?diastolic .
  OPTIONAL {
    ?screenBP  edns:posture ?posture .
  }
} ORDER DESC BY ?date

Query Federation

SELECT ?date ?systolic ?diastolic WHERE {
...
  GRAPH <ER_admission_screenings.rdf>  {
    ?sc1 edns:patient ?patient ; dc:date ?date ;
         edns:systolic ?systolic ; edns:diastolic ?diastolic .
  }
  SERVICE <http://countyHospital.example/SPARQL>  {
    ?sc2 edns:patient ?patient ; dc:date ?date ;
         edns:systolic ?systolic ; edns:diastolic ?diastolic .
  }
  SERVICE <http://countyHospital.example/SPARQL>  {
    ?patient foo:screening ?sc3 . ?sc3 foo:patient ; dc:date ?date ;
             foo:BPmeasurement ( ?systolic , ?diastolic )
  }
}

Result forms

3 types of queries:

SELECT and ASK results can be returned as XML or JSON. CONSTRUCT and DESCRIBE results can be returned via any RDF serialization (e.g. RDF/XML or Turtle).

SPARQL Resources

Inferring types

Collaboration

We want your help

join per <http://www.w3.org/2001/sw/hcls/#Participation>.