Example of SQL-Query based Approach (Part 3: Query): SPARQL Query and its SQL translation

From RDB2RDF
Revision as of 01:16, 24 March 2010 by Rcygania2 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

SPARQL graph-pattern

 { 
   ?x emp:Name    ?ename . 
   ?x emp:deptNum ?dno . 
   ?d dept:deptno ?dno . 
   ?d dept:Name   ?dname
 }

Generated SQL query

Note: We have not shown transformation of column values to RDF terms.

 WITH
 DEPT_VW AS (
 Select 
    '<xyz.com/dept/' || deptno || '>' AS deptURI
  , deptno
  , dname
  , loc 
  from dept
 ),
 EMP_VW AS (
 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
 )
 SELECT   T1.DNAME as DNAME,T0.ENAME as ENAME
 FROM EMP_VW T0, DEPT_VW T1 
 WHERE T0.DEPTNO = T1.DEPTNO
 ;