Example of SQL-based RDB2RDF Mapping: Revision 1

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
   <InstanceIdMap DBColumnName="deptURI" RDFTerm="IRI"/> 
   <PropertyMap PropertyName="dept:deptno" DBColumnName="deptno" /> 
   <PropertyMap PropertyName="dept:Name" DBColumnName="dname" /> 
   <PropertyMap PropertyName="dept:location" DBColumnName="loc" /> 

  <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

   <InstanceIdMap DBColumnName="empURI" RDFTerm="IRI"/> 

   <RDFTypeURIPropertyMap RDFTypeURIPropertyName="emp:jobtype" DBColumnName="jobTypeURI" /> 
   <RDFTypeURIPropertyMap RDFTypeURIPropertyName="emp:emptype" DBColumnName="empTypeURI" /> 

   <GraphURIPropertyMap GraphURIPropertyName="emp:destGraph" DBColumnName="graphURI" /> 

   <PropertyMap PropertyName="emp:empno" DBColumnName="empno" /> 
   <PropertyMap PropertyName="emp:Name" DBColumnName="ename" /> 
   <PropertyMap PropertyName="emp:job" DBColumnName="job" /> 
   <PropertyMap PropertyName="emp:deptNum" DBColumnName="deptno" /> 
   <PropertyMap PropertyName="emp:etype" DBColumnName="etype" /> 

     JoinCondition="{child}.deptno = {parent}.deptno" 



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

DEPT related schema triples

 xyz:dept          rdfs:subClassOf        gen:SuperClass1
 dept:deptno       rdfs:domain            gen:SuperClass1
 dept:deptno       rdfs:range             xsd:integer
 dept:Name         rdfs:domain            gen:SuperClass1
 dept:Name         rdfs:range             xsd:string
 dept:location     rdfs:domain            gen:SuperClass1
 dept:location     rdfs:range             xsd:string

EMP related schema triples

 xyz:emp           rdfs:subClassOf        gen:SuperClass2
 emp:empno         rdfs:domain            gen:SuperClass2
 emp:empno         rdfs:range             xsd:integer
 emp:Name          rdfs:domain            gen:SuperClass2
 emp:Name          rdfs:range             xsd:string
 emp:job           rdfs:domain            gen:SuperClass2
 emp:job           rdfs:range             xyz:string
 emp:deptNum       rdfs:domain            gen:SuperClass2
 emp:deptNum       rdfs:range             xsd:integer
 emp:etype         rdfs:domain            gen:SuperClass2
 emp:etype         rdfs:range             xyz:string
 emp:c_ref_deptno  rdfs:domain            gen:SuperClass2
 emp:c_ref_deptno  rdfs:range             gen:SuperClass1
 emp:jobtype       rdfs:domain            gen:SuperClass2
 emp:jobtype       rdfs:subPropertyOf     rdf:type
 emp:emptype       rdfs:domain            gen:SuperClass2
 emp:emptype       rdfs:subPropertyOf     rdf:type
Last modified on 7 September 2010, at 14:33