@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/ns#> .
@prefix emp: <http://example.com/emp#> .
@prefix dept: <http://example.com/dept#> .
@prefix likes: <http://example.com/likes#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://example.com/base/> .


<TriplesMap1>
    a rr:TriplesMap;
    rr:logicalTable [ rr:sqlQuery """
       SELECT ('Department' || "deptno") AS deptId
            , "deptno"
            , "dname"
            , "loc"
       FROM "DEPT"
       """ ];

    rr:subjectMap [ rr:column "deptId"; rr:termType rr:BlankNode;
                    rr:inverseExpression "{\"deptno\"} = substr({deptId},length('Department')+1)" ];

    rr:predicateObjectMap
    [ 
      rr:predicate		dept:deptno ; 
      rr:objectMap    [ rr:column "\"deptno\""; ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		dept:name ; 
      rr:objectMap    [ rr:column "\"dname\"" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		dept:location ; 
      rr:objectMap    [ rr:column "\"loc\"" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		dept:COMPANY ; 
      rr:object			"EXAMPLE Corporation"
    ]
.

<TriplesMap2>
    a rr:TriplesMap;
    rr:logicalTable [ rr:sqlQuery """
       SELECT ('http://example.com/emp/' || "empno") AS empURI
            , "empno"
            , "ename"
            , ('http://example.com/emp/job/'|| "job") AS jobTypeURI
            , "job"
            , "deptno"
            , ('http://example.com/emp/etype/'|| "etype") AS empTypeURI
            , "etype"
            , ('http://example.com/graph/'|| "job" || '/' || "etype") AS graphURI
       FROM "EMP"
       """ ];

    rr:subjectMap [ rr:column "empURI"; ];
     
    rr:predicateObjectMap 
    [ 
      rr:predicate		emp:jobtype ; 
      rr:objectMap    [ rr:column "jobTypeURI"; rr:termType rr:IRI; ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		rdf:type ; 
      rr:objectMap    [ rr:column "jobTypeURI"; rr:termType rr:IRI; ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		emp:emptype ; 
      rr:objectMap    [ rr:column "empTypeURI"; rr:termType rr:IRI; ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		rdf:type ; 
      rr:objectMap    [ rr:column "empTypeURI"; rr:termType rr:IRI; ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		emp:empno ; 
      rr:objectMap    [ rr:column "\"empno\"" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		emp:name ; 
      rr:objectMap    [ rr:column "\"ename\"" ]; 
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		emp:job ; 
      rr:objectMap    [ rr:column "\"job\"" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		emp:deptNum ; 
      rr:objectMap    [ rr:column "\"deptno\"" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicate		emp:etype ; 
      rr:objectMap    [ rr:column "\"etype\"" ]
    ];

    rr:predicateObjectMap [
      rr:predicate		emp:c_ref_deptno ;
      rr:objectMap    [
        a rr:RefObjectMap ;
        rr:parentTriplesMap <TriplesMap1>;
        rr:joinCondition [
          rr:child "\"deptno\"";
          rr:parent "\"deptno\"";
        ];
      ];
    ]
    .
