Example of SQL-Query based Approach (Part 1: Schema): RDB Schema, RDB2RDF Mapping, and generated RDF Schema

Jump to: navigation, search

A sample relational schema:

DEPT table

 deptno  NUMBER       UNIQUE
 dname   VARCHAR2(30)
 loc     VARCHAR2(100)

EMP table

 empno  NUMBER        PRIMARY KEY
 ename  VARCHAR2(100)
 job    VARCHAR2(30)
 deptno NUMBER        REFERENCES DEPT(deptno)
 etype  VARCHAR2(30)

A mapping specification (for mapping the above relational schema to RDF):

This example includes

 o rdf:type columns 
 o destination graphs (either at class-level or at instance-level)
 o inverse functions

Note: Expansion for prefixes "dept:" and "emp:" have not been shown.

Mapping specification (expressed using an XML-based syntax)

<?xml version="1.0" ?> 
<rdb2rdf_sample xmlns:xyz="http://xyz.com" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 <ClassMap ClassName="xyz:dept" GraphName="xyz:DeptGraph">
   Select '<xyz.com/dept/' || deptno || '>' AS deptURI
        , deptno
        , dname
        , loc 
     from dept
  <PropertyMap PropertyName="instURI" ColPosInSQLdefString="1" /> 
  <PropertyMap PropertyName="dept:deptno" ColPosInSQLdefString="2" /> 
  <PropertyMap PropertyName="dept:Name" ColPosInSQLdefString="3" /> 
  <PropertyMap PropertyName="dept:location" ColPosInSQLdefString="4" /> 
  <KeyPropertyMap KeyPropertyName="dept:c_unq_deptno" KeyType="Unique">
    <PropertyName name="dept:deptno" posInKey="1" /> 
 <ClassMap ClassName="xyz:emp">
   Select '<xyz.com/emp/' || empno || '>' AS empURI
        , empno
        , ename
        , '<xyz.com/emp/job/'|| job || '>' AS jobTypeURI
        , job
        , deptno
        , '<xyz.com/emp/etype/'|| etype || '>' AS empTypeURI
        , etype
        , '<xyz.com/graph/'|| job || '/' || etype || '>' AS graphURI 
   from emp
  <PropertyMap PropertyName="instURI" ColPosInSQLdefString="1" /> 
  <PropertyMap PropertyName="emp:empno" ColPosInSQLdefString="2" /> 
  <PropertyMap PropertyName="emp:Name" ColPosInSQLdefString="3" /> 
  <PropertyMap PropertyName="emp:jobtype" ColPosInSQLdefString="4" colType="rdf:type" /> 
  <PropertyMap PropertyName="emp:job" ColPosInSQLdefString="5" /> 
  <PropertyMap PropertyName="emp:deptNum" ColPosInSQLdefString="6" /> 
  <PropertyMap PropertyName="emp:emptype" ColPosInSQLdefString="7" colType="rdf:type" InverseExpr="xyz:etypeInvFunc" /> 
  <PropertyMap PropertyName="emp:etype" ColPosInSQLdefString="8" /> 
  <PropertyMap PropertyName="instGraph" ColPosInSQLdefString="9" InverseExpr="xyz:graphInvFunc" /> 
  <KeyPropertyMap KeyPropertyName="emp:c_prm_empno" KeyType="Primary">
    <PropertyName name="emp:empno" posInKey="1" /> 
  <KeyPropertyMap KeyPropertyName="emp:c_ref_deptno" KeyType="Reference" RefKeyPropertyName="dept:c_unq_deptno">
    <PropertyName name="emp:deptNum" posInKey="1" /> 

RDF Schema generated from the above mapping specification (for use by SPARQL query writers):

DEPT related schema triples

 xyz:dept          rdf:type               rdfs:Class
 dept:deptno       rdfs:domain            xyz:dept
 dept:deptno       rdfs:range             xsd:integer
 dept:Name         rdfs:domain            xyz:dept
 dept:Name         rdfs:range             xsd:string
 dept:location     rdfs:domain            xyz:dept
 dept:location     rdfs:range             xsd:string

EMP related schema triples

 xyz:emp           rdf:type               rdfs:Class
 emp:empno         rdfs:domain            xyz:emp
 emp:empno         rdfs:range             xsd:integer
 emp:Name          rdfs:domain            xyz:emp
 emp:Name          rdfs:range             xsd:string
 emp:jobtype       rdfs:domain            xyz:emp
 emp:jobtype       rdfs:subPropertyOf     rdf:type
 emp:job           rdfs:domain            xyz:emp
 emp:job           rdfs:range             xyz:string
 emp:deptNum       rdfs:domain            xyz:emp
 emp:deptNum       rdfs:range             xsd:integer
 emp:emptype       rdfs:domain            xyz:emp
 emp:emptype       rdfs:subPropertyOf     rdf:type
 emp:etype         rdfs:domain            xyz:emp
 emp:etype         rdfs:range             xyz:string
 emp:c_ref_deptno  rdfs:domain            xyz:emp
 emp:c_ref_deptno  rdfs:range             xyz:dept