Warning:
This wiki has been archived and is now read-only.

Revised Example of SQL-Query based Approach

From RDB2RDF
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">
  <SQLdefString>
   Select '<xyz.com/dept/' || deptno || '>' AS deptURI
        , deptno
        , dname
        , loc 
     from dept
  </SQLdefString> 
  <InstURIPropertyMap DBColumnName="deptURI" /> 
  <PropertyMap PropertyName="dept:deptno" DBColumnName="deptno" /> 
  <PropertyMap PropertyName="dept:Name" DBColumnName="dname" /> 
  <PropertyMap PropertyName="dept:location" DBColumnName="loc" /> 
  <KeyMap KeyName="dept:c_unq_deptno" KeyType="Unique">
   <KeyDef>
    <PropertyName name="dept:deptno" /> 
   </KeyDef>
  </KeyMap>
 </ClassMap>
 <ClassMap ClassName="xyz:emp">
  <SQLDefString>
   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
  </SQLDefString> 
  <InstURIPropertyMap DBColumnName="empURI" /> 
  <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" /> 
  <KeyMap KeyName="emp:c_prm_empno" KeyType="Primary">
   <KeyDef>
    <PropertyName name="emp:empno" /> 
   </KeyDef>
  </KeyMap>
  <KeyMap KeyName="emp:c_ref_deptno" KeyType="Reference" RefKeyName="dept:c_unq_deptno">
   <KeyDef>
    <PropertyName name="emp:deptNum" /> 
   </KeyDef>
  </KeyMap>
 </ClassMap>
</rdb2rdf_sample>

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