W3C

R2RML and Direct Mapping Test Cases

W3C Editor's Draft 10 October 2011

This version:
http://www.w3.org/2001/sw/rdb2rdf/test-cases/
Latest version:
http://www.w3.org/2001/sw/rdb2rdf/test-cases/
Editors:
Boris Villazón-Terrazas, Universidad Politécnica de Madrid
Michael Hausenblas, DERI, NUI Galway

Abstract

This document defines the R2RML and Direct Mapping Test Cases deliverable for the RDB2RDF Working Group as defined in the Working Group's Charter.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This is an Editor's Draft for review by W3C members and other interested parties.

Comments on this document should be sent to public-rdb2rdf-comments@w3.org, a mailing list with a public archive.

Publication as a Editor's Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

The W3C RDB2RDF Working Group is the W3C working group responsible for this document.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

Last Modified: $Date: 2011/10/10 15:50:40 $

Table of Contents

1 Introduction
2 Organization
3 Terminology
4 Test Cases


1 Introduction

This document defines the R2RML and Direct mapping test cases, consisting of a collection of test case documents (input and expected output) and the test case manifest document (describing each test case).

The purpose of the Test Cases is to verify and validate the specification of the R2RML language and Direct mapping. Moreover, these test cases can be useful to create a test harness or automated test framework for testing the interoperable implementors, i.e. R2RML engines.

2 Organization

Test cases are organized by database. We use a descriptive naming convention for the databases. For each database we have:

The associated files (sql, nt, and nq) are available at the W3C repository.

The following picture illustrates the organization.

2 Terminology

R2RML engine
A software that takes a relational database (RDB) and a R2RML mapping document as input and produces an RDF graph according to the mapping document.
Test case manifest document
An RDF document that describe the test cases, relating input with expected output as well as containing additional metadata (such as description) about each test case. Typically used in a harness to automatically test an implementation regarding its conformance.

3 Test Cases

Each test case is described using the Test Metadata vocabulary in RDFa. The table owner for the all the databases is boricles.

D000-1table0rows

Title:Empty table

Graphical representation:

Student
Name
VARCHAR(50)

SQL:

CREATE TABLE "Student" (
       "Name" varchar(50)
);

								

File:D000-1table0rows

Direct Graph TC0000

Title:Empty table

Purpose: Tests if an empty table produces an empty RDF graph

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D000-1table0rows

Expected result: Direct Graph TC0000

RDF:

SubjectPredicateObject

R2RMLTC000

Title:Empty table

Purpose: Tests if an empty table produces an empty RDF graph

Specification reference: #physical-tables

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D000-1table0rows

Expected result: mapped.nq

RDF:

SubjectPredicateObjectGraph

R2RML mapping: R2RMLTC000

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
        
	rr:logicalTable [ rr:tableName "Student"; ] ;
	
    rr:subjectMap [ rr:template "http://example.com/{Name}" ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

D001-1table1row

Title:One table, one row

Graphical representation:

STUDENT
NAME
VARCHAR(50)
Venus

SQL:

CREATE TABLE Student (
Name varchar(50)
);
INSERT INTO Student (Name) VALUES ('Venus');

								

File:D001-1table1row

Direct Graph TC0001

Title:One table, one row

Purpose: Tests: (1) one column mapping, no primary key; (2) generation of a "BlankNode" subject; (3) one column to one property

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D001-1table1row

Expected result: Direct Graph TC0001

RDF:

SubjectPredicateObject
_:a<Student#Name>"Venus"

R2RMLTC0001a

Title:One column mapping

Purpose: Tests: (1) one column mapping, no primary key; (2) subject URI generation by using one single column; (3) one column to one property

Specification reference: #dfn-template-valued-term-map

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D001-1table1row

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Venus><http://xmlns.com/foaf/0.1/name>"Venus" 

R2RML mapping: R2RMLTC0001a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
    
    rr:logicalTable [ rr:tableName "boricles.Student" ];

    rr:subjectMap [ rr:template "http://example.com/{Name}" ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC0001b

Title:One column mapping

Purpose: Tests: (1) one column mapping, no primary key; (2) generation of a "BlankNode" subject; (3) one column to one property

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D001-1table1row

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7fff<http://xmlns.com/foaf/0.1/name>"Venus" 

R2RML mapping: R2RMLTC0001b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
    
    rr:logicalTable [ rr:tableName "boricles.Student" ];

    rr:subjectMap [ rr:column "Name"; rr:termType rr:BlankNode ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

D002-1table2columns1row

Title:One table, two columns, one row

Graphical representation:

Student
Name
VARCHAR(50)
ID
INTEGER
Venus10

SQL:

CREATE TABLE "Student" (
"ID" integer,
"Name" varchar(50)
);
INSERT INTO "Student" ("ID", "Name") VALUES(10,'Venus');

								

File:D002-1table2columns1row

Direct Graph TC0002

Title:Two columns mapping

Purpose: Tests: (1) two columns mapping, no primary key; (2) generation of a "BlankNode" subject; (3) one column to one property

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D002-1table2columns1row

Expected result: Direct Graph TC0002

RDF:

SubjectPredicateObject
_:a<Student#id>"10"^^<http://www.w3.org/2001/XMLSchema#integer>
_:a<Student#name>"Venus"

R2RMLTC0002a

Title:Two columns mapping

Purpose: Tests: (1) two column mapping, no primary key; (2) subject URI generated by concatenation of two column values; (3) one column to one property; (4) presence of unqualified name for a rr:tableName

Specification reference: #from-template

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D002-1table2columns1row

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/10Venus><http://xmlns.com/foaf/0.1/name>"Venus" 
<http://example.com/10Venus><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 

R2RML mapping: R2RMLTC0002a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
    
    rr:logicalTable [ rr:tableName "Student" ];

    rr:subjectMap [ rr:template "http://example.com/{ID}{Name}";
                    rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
	]
    .

										

R2RMLTC0002b

Title:Two columns mapping

Purpose: Tests: (1) two column mapping, no primary key; (2) generation of a "BlankNode" subject; (3) one column to one property

Specification reference: #dfn-r2rml-view

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D002-1table2columns1row

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ffd<http://xmlns.com/foaf/0.1/name>"Venus" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ffd<http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ffd<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 

R2RML mapping: R2RMLTC0002b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;
    
    rr:logicalTable [ 
                     rr:sqlQuery """
                       Select ('Student' || ID ) AS StudentId
                            , ID
                            , Name
                         from boricles.Student
                       """
                       ];

    rr:subjectMap [ rr:column "StudentId"; rr:termType rr:BlankNode; rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC0002c

Title:Two columns mapping

Purpose: Tests the presence of an invalid SQL identifier

Specification reference: #dfn-sql-identifier

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D002-1table2columns1row

R2RML mapping: R2RMLTC0002c

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
    
    rr:logicalTable [ rr:tableName "Student" ];

    rr:subjectMap [ rr:template "http://example.com/{ID}{Name}";
                    rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "IDs"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
	]
    .

										

R2RMLTC0002d

Title:Two columns mapping

Purpose: Tests the presence delimited identifiers

Specification reference: #dfn-sql-identifier

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D002-1table2columns1row

Expected result: mappedd.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/10Venus><http://xmlns.com/foaf/0.1/name>"Venus" 
<http://example.com/10Venus><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 

R2RML mapping: R2RMLTC0002d

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;
    
    rr:logicalTable [ 
                     rr:sqlQuery """
                       Select ('Student' || ID ) AS StudentId
                            , "ID"
                            , "Name"
                         from "boricles.Student"
                       """
                       ];

    rr:subjectMap [ rr:column "StudentId"; rr:termType rr:BlankNode; rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC0002e

Title:Two columns mapping

Purpose: Tests the presence of an invalid rr:tableName

Specification reference: #dfn-sql-identifier

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D002-1table2columns1row

R2RML mapping: R2RMLTC0002e

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
    
    rr:logicalTable [ rr:tableName "Students" ];

    rr:subjectMap [ rr:template "http://example.com/{ID}{Name}";
                    rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
	]
    .

										

R2RMLTC0002f

Title:Two columns mapping

Purpose: Tests the presence of schema-qualified name for a rr:tableName

Specification reference: #from-template

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D002-1table2columns1row

Expected result: mappedf.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/10Venus><http://xmlns.com/foaf/0.1/name>"Venus" 
<http://example.com/10Venus><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 

R2RML mapping: R2RMLTC0002f

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
    
    rr:logicalTable [ rr:tableName "boricles.Student" ];

    rr:subjectMap [ rr:template "http://example.com/{ID}{Name}";
                    rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
	]
    .

										

R2RMLTC0002g

Title:Two columns mapping

Purpose: Tests the presence of an invalid SQL query

Specification reference: #dfn-sql-identifier

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D002-1table2columns1row

R2RML mapping: R2RMLTC0002g

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;
    
    rr:logicalTable [ 
                     rr:sqlQuery """
                       Select ('Student' || ID ) AS StudentId
                            , "ID"
                            , "Name"
                         "boricles.Student"
                       """
                       ];

    rr:subjectMap [ rr:column "StudentId"; rr:termType rr:BlankNode; rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC0002h

Title:Two columns mapping

Purpose: Tests the presence of duplicate column names in the SELECT list of the SQL query

Specification reference: #dfn-sql-identifier

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D002-1table2columns1row

R2RML mapping: R2RMLTC0002h

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;
    
    rr:logicalTable [ 
                     rr:sqlQuery """
                       Select ('Student' || ID ) AS StudentId
                            , "ID"
                            , "Name"
			, "ID"
                       from "boricles.Student"
                       """
                       ];

    rr:subjectMap [ rr:column "StudentId"; rr:termType rr:BlankNode; rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC0002i

Title:Two columns mapping

Purpose: Tests the presence of a SQL Version identifier

Specification reference: #dfn-r2rml-view

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D002-1table2columns1row

Expected result: mappedi.nq

RDF:

SubjectPredicateObjectGraph
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ffd<http://xmlns.com/foaf/0.1/name>"Venus" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ffd<http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ffd<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 

R2RML mapping: R2RMLTC0002i

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;
    
    rr:logicalTable [ 
                     rr:sqlQuery """
                       Select ('Student' || ID ) AS StudentId
                            , ID
                            , Name
                         from boricles.Student
                       """;
					   
			rr:sqlVersion rr:SQL2008 .					   
					   
                       ];
	
	

    rr:subjectMap [ rr:column "StudentId"; rr:termType rr:BlankNode; rr:class foaf:Person ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

D003-1table3columns1row

Title:One table, two columns, one row

Graphical representation:

Student
ID
INTEGER
FirstName
VARCHAR(50)
LastName
VARCHAR(50)
10VenusWilliams

SQL:

CREATE TABLE "Student" (
"ID" integer,
"FirstName" varchar(50),
"LastName" varchar(50)
);
INSERT INTO "Student" ("ID", "FirstName", "LastName") VALUES (10,'Venus', 'Williams');

								

File:D003-1table3columns1row

Direct Graph TC0003

Title:Two columns mapping

Purpose: Tests: (1) two columns mapping, no primary key; (2) generation of a "BlankNode" subject; (3) one column to one property

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D003-1table3columns1row

Expected result: Direct Graph TC0003

RDF:

SubjectPredicateObject
_:a<Student#ID>"10"
_:a<Student#FirstName>"Venus"
_:a<Student#LastName>"Williams"

R2RMLTC0003a

Title:Two columns mapping

Purpose: Tests: (1) two column mapping, no primary key; (2) subject URI generated by concatenation of two column values; (3) one column to one property

Specification reference: #from-column

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D003-1table3columns1row

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Student10VenusWilliams><http://xmlns.com/foaf/0.1/lastName>"Williams" 
<http://example.com/Student10VenusWilliams><http://xmlns.com/foaf/0.1/firstName>"Venus" 
<http://example.com/Student10VenusWilliams><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/Student10VenusWilliams><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 

R2RML mapping: R2RMLTC0003a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;

     rr:logicalTable [ rr:tableName "boricles.Student" ];

    rr:subjectMap [ rr:template "http://example.com/Student{ID}{FirstName}{LastName}";
                    rr:class foaf:Person  ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:firstName ]; 
      rr:objectMap    [ rr:column "FirstName" ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:lastName ]; 
      rr:objectMap    [ rr:column "LastName" ]
    ]
    .

										

R2RMLTC0003b

Title:Two columns mapping

Purpose: Tests: (1) two column mapping, no primary key; (2) generation of a "BlankNode" subject; (3) one column to one property

Specification reference: #from-template

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D003-1table3columns1row

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Student10VenusWilliams><http://xmlns.com/foaf/0.1/name>"Venus Williams" 
<http://example.com/Student10VenusWilliams><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/Student10VenusWilliams><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 

R2RML mapping: R2RMLTC0003b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;

     rr:logicalTable [ 
                     rr:sqlQuery """
                     SELECT ID,
                            (FirstName || ' ' || LastName) AS Name,
                            FirstName,
                            LastName
                     FROM Student
                     """
                     ];

    rr:subjectMap [ rr:template "http://example.com/Student{ID}{FirstName}{LastName}"; 
                    rr:class foaf:Person ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC0003c

Title:Two columns mapping

Purpose: Tests rr:termType rr:BlankNode and rr:Literal

Specification reference: #from-template

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D003-1table3columns1row

Expected result: mappedc.nq

RDF:

SubjectPredicateObjectGraph
_:10VenusWilliams<http://xmlns.com/foaf/0.1/lastName>"Williams" 
_:10VenusWilliams<http://xmlns.com/foaf/0.1/firstName>"Venus" 
_:10VenusWilliams<http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 

R2RML mapping: R2RMLTC0003c

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;

     rr:logicalTable [ 
                      rr:sqlQuery """
                     SELECT ('Student' || "ID" || "FirstName" || "LastName") as StudentID,
                            "ID",
                            "FirstName",
                            "LastName"
                     FROM "Student"
                     """
                     ];

    rr:subjectMap [ rr:column "StudentID"; rr:termType rr:BlankNode;  ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:firstName ]; 
      rr:objectMap    [ rr:column "FirstName";
						rr:termType rr:Literal ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:lastName ]; 
      rr:objectMap    [ rr:column "LastName";
						rr:termType rr:Literal ]
    ]
    .

										

R2RMLTC0003d

Title:Two columns mapping

Purpose: Tests rr:termType rr:IRI

Specification reference: #from-template

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D003-1table3columns1row

Expected result: mappedd.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/10VenusWilliams><http://xmlns.com/foaf/0.1/firstName><http://example.com/data/Venus> 
<http://example.com/10VenusWilliams><http://example.com//lastName><http://example.com/data/Williams> 
<http://example.com/10VenusWilliams><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 

R2RML mapping: R2RMLTC0003d

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
     a rr:TriplesMap;

     rr:logicalTable [ 
                      rr:sqlQuery """
                     SELECT ('Student' || "ID" || "FirstName" || "LastName") as StudentID,
                            "ID",
                            "FirstName",
                            "LastName"
                     FROM "Student"
                     """
                     ];

    rr:subjectMap [ rr:template "http://example.com/{StudentID}"; rr:termType rr:IRI;  ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:firstName ]; 
      rr:objectMap    [ rr:template "http://example.com/data/{FirstName}";
						rr:termType rr:IRI ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:lastName ]; 
      rr:objectMap    [ rr:template "http://example.com/data/{LastName}";
						rr:termType rr:IRI ]
    ]
    .

										

D004-1table2columnsprojection

Title:One table, two columns, projection

Graphical representation:

Student_Sport
Student
VARCHAR(50)
Sport
VARCHAR(50)
VenusTennis

SQL:

CREATE TABLE "Student_Sport"(
      "Student" varchar(50),
      "Sport" varchar(50)
);
INSERT INTO "Student_Sport" ("Student","Sport") VALUES ('Venus', 'Tennis');

								

File:D004-1table2columnsprojection

Direct Graph TC0004

Title:Three column mapping

Purpose: Tests: (1) two column mapping, no primary key, (2) generation of a "BlankNode" subject; (3) one row table to two different resources

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D004-1table2columnsprojection

Expected result: Direct Graph TC0004

RDF:

SubjectPredicateObject
_:a<Student_Sport#Student>"Venus"
_:a<Student_Sport#Sport>"Tennis"

R2RMLTC0004a

Title:Projection

Purpose: Tests: (1) two column mapping, no primary key, (2) subject URI generated by a column value; (3) one row table to two different resources

Specification reference: #typing

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D004-1table2columnsprojection

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Venus><http://xmlns.com/foaf/0.1/name>"Venus" 
<http://example.com/Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Student> 
<http://example.com/Tennis><http://xmlns.com/foaf/0.1/name>"Tennis" 
<http://example.com/Tennis><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Sport> 

R2RML mapping: R2RMLTC0004a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;

	rr:logicalTable [ rr:tableName  "Student_Sport" ];
	
    rr:subjectMap [ rr:template "http://example.com/{Student}";
                    rr:class ex:Student ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Student" ]
    ]
    .

<TriplesMap2>
    a rr:TriplesMap;

	rr:logicalTable [ rr:tableName  "Student_Sport" ];
	
    rr:subjectMap [ rr:template "http://example.com/{Sport}";
                    rr:class ex:Sport  ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Sport" ]
    ]
	.

										

R2RMLTC0004b

Title:Projection

Purpose: Tests: (1) two column mapping, no primary key, (2) generation of a "BlankNode" subject; (3) one row table to two different resources

Specification reference: #r2rml-views

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D004-1table2columnsprojection

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff6<http://xmlns.com/foaf/0.1/name>"Tennis" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff6<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Sport> 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff7<http://xmlns.com/foaf/0.1/name>"Venus" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff7<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Student> 

R2RML mapping: R2RMLTC0004b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;

      rr:logicalTable [ rr:SQLQuery """
       Select ('Student' || Student) AS StudentId
         from Student_Sport
       """;
	   ] ;

    rr:subjectMap [ rr:column "StudentId"; rr:termType rr:BlankNode;
                    rr:class ex:Student ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Student" ]
    ]
    .

<TriplesMap2>
    a rr:TriplesMap;

      rr:SQLQuery """
       Select ('Sport' || Sport) AS SportId
         from Student_Sport
       """;

    rr:subjectMap [ rr:column "SportId"; rr:termType rr:BlankNode;
                    rr:class ex:Sport  ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ rr:column "Sport" ]
    ]
	.

										

D005-2duplicates0nulls

Title:Duplicate tuples, no primary key

Graphical representation:

IOUs
amount
DOUBLE
lname
CHARACTER(20)
fname
CHARACTER(20)
30.0E0Smith Bob
20.0E0Jones Sue
30.0E0Smith Bob

SQL:

CREATE TABLE "IOUs" (
      "fname" CHAR(20),
      "lname"  CHAR(20),
      "amount" FLOAT);
INSERT INTO "IOUs" ("fname", "lname", "amount") VALUES ('Bob', 'Smith', 30);
INSERT INTO "IOUs" ("fname", "lname", "amount") VALUES ('Sue', 'Jones', 20);
INSERT INTO "IOUs" ("fname", "lname", "amount") VALUES ('Bob', 'Smith', 30);

								

File:D005-2duplicates0nulls

Direct Graph TC0005

Title:Duplicate tuples, no primary key

Purpose: Tests the generation of Blank Nodes for duplicate tuples

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D005-2duplicates0nulls

Expected result: Direct Graph TC0005

RDF:

SubjectPredicateObject
_:a<IOUs#fname>"Bob"
_:a<IOUs#lname>"Smith"
_:a<IOUs#amount>"30.0"^^<http://www.w3.org/2001/XMLSchema#float>
_:b<IOUs#fname>"Sue"
_:b<IOUs#lname>"Jones"
_:b<IOUs#amount>"20.0"^^<http://www.w3.org/2001/XMLSchema#float>
_:c<IOUs#fname>"Bob"
_:c<IOUs#lname>"Smith"
_:c<IOUs#amount>"30.0"^^<http://www.w3.org/2001/XMLSchema#float>

D006-1table1primarykey1column1row

Title:One table, one column, one primary key

Graphical representation:

Student
Name (PK)
VARCHAR(50)
Venus

SQL:

CREATE TABLE "Student" (
"Name" varchar(50) PRIMARY KEY
);
INSERT INTO "Student" ("Name") VALUES ('Venus');

								

File:D006-1table1primarykey1column1row

Direct Graph TC0006

Title:One table, one column, one primary key

Purpose: Tests a table with a column that is a primary key

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D006-1table1primarykey1column1row

Expected result: Direct Graph TC0006

RDF:

SubjectPredicateObject
<Student/Name.Venus#_><Student#Name>"Venus"
<Student/Name.Venus#_><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><Student>

D007-1table1primarykey2columns1row

Title:One table, one column, one primary key

Graphical representation:

Student
ID (PK)
INTEGER
Name
VARCHAR(50)
10Venus

SQL:

CREATE TABLE "Student" (
"ID" integer,
"Name" varchar(50),
PRIMARY KEY ("ID")
);
INSERT INTO "Student" ("ID", "Name") VALUES(10,'Venus');

								

File:D007-1table1primarykey2columns1row

Direct Graph TC0007

Title:A table with a primary key and 2 columns

Purpose: Tests a table with a primary key and 2 columns

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D007-1table1primarykey2columns1row

Expected result: Direct Graph TC0007

RDF:

SubjectPredicateObject
<Student/ID.10#_><Student#ID>"10"^^<http://www.w3.org/2001/XMLSchema#integer>
<Student/ID.10#_><Student#Name>"Venus"
<Student/ID.10#_><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><Student>

R2RMLTC0007a

Title:One column mapping

Purpose: Tests constant-value term map by using rr:constant property

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D007-1table1primarykey2columns1row

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Student10Venus><http://xmlns.com/foaf/0.1/firstName>"Venus"<http://example.com/PersonGraph>
<http://example.com/Student10Venus><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer><http://example.com/PersonGraph>
<http://example.com/Student10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person><http://example.com/PersonGraph>

R2RML mapping: R2RMLTC0007a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .


<TriplesMap1>
     a rr:TriplesMap;

	rr:logicalTable [ rr:tableName "Student" ];

    rr:subjectMap [ rr:template "http://example.com/Student{ID}{Name}"; 
					rr:graphMap [ rr:constant ex:PersonGraph; ]
	];
	
    rr:predicateObjectMap
    [ 
		rr:predicateMap [ rr:constant rdf:type; ];
		rr:objectMap [ rr:constant foaf:Person; ]
	];
	
    rr:predicateObjectMap
    [ 
		rr:predicateMap [ rr:constant ex:id; ];
		rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:constant foaf:firstName; ];
      rr:objectMap    [ rr:column "Name" ]
    ]

    .

										

R2RMLTC0007b

Title:One column mapping

Purpose: Tests constant-value term map by using constant shortcut properties rr:predicate, rr:object and rr:graph. Also directly using rr:tableName

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D007-1table1primarykey2columns1row

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Student10Venus><http://xmlns.com/foaf/0.1/firstName>"Venus"<http://example.com/PersonGraph>
<http://example.com/Student10Venus><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer><http://example.com/PersonGraph>
<http://example.com/Student10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person><http://example.com/PersonGraph>

R2RML mapping: R2RMLTC0007b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .


<TriplesMap1>
     a rr:TriplesMap;

	rr:tableName "Student";

    rr:subjectMap [ rr:template "http://example.com/Student{ID}{Name}"; 
				    rr:graph ex:PersonGraph;
	];
	
    rr:predicateObjectMap
    [ 
		rr:predicate rdf:type;
		rr:object foaf:Person;
	];
	
    rr:predicateObjectMap
    [ 
		rr:predicate  ex:id;
		rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicate foaf:firstName;
      rr:objectMap    [ rr:column "Name" ]
    ]

    .

										

R2RMLTC0007c

Title:One column mapping

Purpose: Tests subjectmap with more than one class IRIs, rr:class

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D007-1table1primarykey2columns1row

Expected result: mappedc.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Student10Venus><http://xmlns.com/foaf/0.1/firstName>"Venus" 
<http://example.com/Student10Venus><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/Student10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 
<http://example.com/Student10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Student> 

R2RML mapping: R2RMLTC0007c

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .


<TriplesMap1>
     a rr:TriplesMap;

	rr:logicalTable [ rr:tableName "Student" ];

    rr:subjectMap [ 
		rr:template "http://example.com/Student{ID}{Name}"; 
		rr:class foaf:Person,ex:Student; 
	];
	
    rr:predicateObjectMap
    [ 
		rr:predicateMap [ rr:constant ex:id; ];
		rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:constant foaf:firstName; ];
      rr:objectMap    [ rr:column "Name" ]
    ]

    .

										

R2RMLTC0007d

Title:One column mapping

Purpose: Tests subjectmap with an alternative of having rr:class, i.e., by specifying an rr:predicateObjectMap with predicate rdf:type

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D007-1table1primarykey2columns1row

Expected result: mappedd.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/Student10Venus><http://xmlns.com/foaf/0.1/firstName>"Venus" 
<http://example.com/Student10Venus><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/Student10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person> 
<http://example.com/Student10Venus><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Student> 

R2RML mapping: R2RMLTC0007d

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .


<TriplesMap1>
     a rr:TriplesMap;

	rr:logicalTable [ rr:tableName "Student" ];

    rr:subjectMap [ 
		rr:template "http://example.com/Student{ID}{Name}"; 
	];
	
    rr:predicateObjectMap
    [ 
		rr:predicate rdf:type;
		rr:object foaf:Person;
	];

    rr:predicateObjectMap
    [ 
		rr:predicate rdf:type;
		rr:object ex:Student;
	];
	
    rr:predicateObjectMap
    [ 
		rr:predicateMap [ rr:constant ex:id; ];
		rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:constant foaf:firstName; ];
      rr:objectMap    [ rr:column "Name" ]
    ]

    .

										

D008-1table1compositeprimarykey3columns1row

Title:Composite primary key

Graphical representation:

Student
Name (PK)
VARCHAR(50)
ID (PK)
INTEGER
Sport
VARCHAR(50)
Venus Williams10Tennis

SQL:

CREATE TABLE "Student" (
"ID" integer,
"Name" varchar(50),
"Sport" varchar (50),
PRIMARY KEY ("ID","Name")
);
INSERT INTO "Student" ("ID", "Name","Sport") VALUES(10,'Venus Williams','Tennis');

								

File:D008-1table1compositeprimarykey3columns1row

Direct Graph TC0008

Title:Composite primary key

Purpose: Tests a table with a composite primary key

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D008-1table1compositeprimarykey3columns1row

Expected result: Direct Graph TC0008

RDF:

SubjectPredicateObject
<Student/ID.10_Name.Venus+Williams#_><Student#ID>"10"^^<http://www.w3.org/2001/XMLSchema#integer>
<Student/ID.10_Name.Venus+Williams#_><Student#Name>"Venus Williams"
<Student/ID.10_Name.Venus+Williams#_><Student#Sport>"Tennis"
<Student/ID.10_Name.Venus+Williams#_><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><Student>

D009-2tables1primarykey1foreingkey

Title:Two tables 1 primary key 1 foreing key

Graphical representation:

Student
ID (PK)
INTEGER
Sport (FK)
INTEGER
Name
VARCHAR(50)
10100Venus Williams
20NULLDemi Moore
Sport
ID (PK)
INTEGER
Name
VARCHAR(50)
100Tennis

SQL:

CREATE TABLE "Sport" (
"ID" integer,
"Name" varchar (50),
PRIMARY KEY ("ID")
);

CREATE TABLE "Student" (
"ID" integer,
"Name" varchar(50),
"Sport" integer,
PRIMARY KEY ("ID"),
FOREIGN KEY("Sport") REFERENCES "Sport"("ID")
);

INSERT INTO "Sport" ("ID", "Name") VALUES (100,'Tennis');
INSERT INTO "Student" ("ID", "Name", "Sport") VALUES (10,'Venus Williams', 100);
INSERT INTO "Student" ("ID", "Name", "Sport") VALUES (20,'Demi Moore', NULL);


								

File:D009-2tables1primarykey1foreingkey

Direct Graph TC0009

Title:Two tables 1 primary key 1 foreing key

Purpose: Tests two tables with a primary key and a foreing key

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D009-2tables1primarykey1foreingkey

Expected result: Direct Graph TC0009

RDF:

SubjectPredicateObject
<Student/ID.20#_><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><Student>
<Student/ID.20#_><Student#ID>"20"^^<http://www.w3.org/2001/XMLSchema#integer>
<Student/ID.20#_><Student#Name>"Demi Moore"
<Student/ID.10#_><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><Student>
<Student/ID.10#_><Student#ID>"10"^^<http://www.w3.org/2001/XMLSchema#integer>
<Student/ID.10#_><Student#Name>"Venus Williams"
<Student/ID.10#_><Student#Sport><Sport/ID.100#_>
<Sport/ID.100#_><Sport#ID>"100"^^<http://www.w3.org/2001/XMLSchema#integer>
<Sport/ID.100#_><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><Sport>
<Sport/ID.100#_><Sport#Name>"Tennis"

R2RMLTC009

Title:Two tables to multiple graphs

Purpose: Test that results from distinct parts of the mapping can be directed to different target graphs.

Specification reference: #named-graphs

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D009-2tables1primarykey1foreingkey

Expected result: mapped.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/resource/student_10><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/ontology/Student><http://example.org/graph/students>
<http://example.com/resource/student_10><http://xmlns.com/foaf/0.1/name>"Venus Williams"<http://example.org/graph/students>
<http://example.com/resource/student_20><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/ontology/Student><http://example.org/graph/students>
<http://example.com/resource/student_20><http://xmlns.com/foaf/0.1/name>"Demi Moore"<http://example.org/graph/students>
<http://example.com/resource/sport_100><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/ontology/Sport><http://example.org/graph/sports>
<http://example.com/resource/sport_100><http://www.w3.org/2000/01/rdf-schema#label>"Tennis"<http://example.org/graph/sports>
<http://example.com/resource/student_10><http://example.com/ontology/practises><http://example.com/resource/sport_100><http://example.org/graph/practise>

R2RML mapping: R2RMLTC009

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
        
	rr:logicalTable [ rr:tableName  "Student" ];
	
    rr:subjectMap 
    [ 
        rr:template "http://example.com/resource/student_{ID}";
        rr:termType rr:IRI;
        rr:class <http://example.com/ontology/Student>;
        rr:graphMap [ rr:graph <http://example.com/graph/students> ] ;
    ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ 
             rr:column "Name";
             rr:termType rr:Literal;
      ];
      rr:graphMap [ rr:graph <http://example.com/graph/students> ];
    ];

    rr:refPredicateObjectMap
    [ 
      rr:refPredicateMap [ rr:predicate <http://example.com/ontology/practises> ]; 
      rr:refObjectMap    [ 
           rr:parentTriplesMap <TriplesMap2>;
           rr:joinCondition [
				rr:child "Sport" ;
				rr:parent "ID" ;
		   ]
      ];
      rr:graphMap [ rr:graph <http://example.com/graph/practise> ];
    ];
    .

<TriplesMap2>
    a rr:TriplesMapClass;
        
		
	rr:logicalTable [ rr:tableName  "Sport" ];

    rr:subjectMap 
    [ 
        rr:template "http://example.com/resource/sport_{ID}";
        rr:termType rr:IRI;
        rr:class <http://example.com/ontology/Sport>;
        rr:graphMap [ rr:graph <http://example.com/graph/sports> ];
    ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate rdfs:label ]; 
      rr:objectMap    [ 
             rr:column "Name"; 
             rr:termType rr:Literal;
      ];
      rr:graphMap [ rr:graph <http://example.com/graph/sports> ];
    ];
	.

										

D010-SpecialChars

Title:Table with Special Chars

Graphical representation:

Country Info
Country Code (PK)
INTEGER
Name
CHARACTER(100)
ISO 3166
CHARACTER(10)
1Bolivia, Plurinational State of BO
2Ireland IE
3Saint Martin (French part) MF

SQL:

CREATE TABLE "Country Info" (
  "Country Code" INTEGER PRIMARY KEY,
  "Name" CHAR(100),
  "ISO 3166" CHAR(10)
);
INSERT INTO "Country Info" ("Country Code", "Name", "ISO 3166") VALUES (1, 'Bolivia, Plurinational State of', 'BO');
INSERT INTO "Country Info" ("Country Code", "Name", "ISO 3166") VALUES (2, 'Ireland', 'IE');
INSERT INTO "Country Info" ("Country Code", "Name", "ISO 3166") VALUES (3, 'Saint Martin (French part)', 'MF');

								

File:D010-SpecialChars

R2RMLTC010a

Title:Table with Special Chars

Purpose: Tests a template with blank space in column

Specification reference: #dfn-template-valued-term-map

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D010-SpecialChars

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/1><http://example.com/name>"Bolivia, Plurinational State of" 
<http://example.com/2><http://example.com/name>"Ireland" 
<http://example.com/3><http://example.com/name>"Saint Martin (French part)" 

R2RML mapping: R2RMLTC010a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
        
	rr:logicalTable [ rr:tableName "Country Info"; ] ;
	
    rr:subjectMap [ rr:template "http://example.com/{Country Code}" ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC010b

Title:Table with Special Chars

Purpose: Tests a template with special chars in column value

Specification reference: #dfn-template-valued-term-map

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D010-SpecialChars

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/1Bolivia%2C%20Plurinational%20State%20of><http://example.com/name>"Bolivia, Plurinational State of" 
<http://example.com/2Ireland><http://example.com/name>"Ireland" 
<http://example.com/3Saint%20Martin%20(French%20part)><http://example.com/name>"Saint Martin (French part)" 

R2RML mapping: R2RMLTC010b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
        
	rr:logicalTable [ rr:tableName "Country Info"; ] ;
	
    rr:subjectMap [ rr:template "http://example.com/{Country Code}{Name}" ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:name ]; 
      rr:objectMap    [ rr:column "Name" ]
    ]
    .

										

R2RMLTC010c

Title:Table with Special Chars

Purpose: Tests a template with special chars in column value and backslash escapes in string templates

Specification reference: #dfn-template-valued-term-map

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D010-SpecialChars

Expected result: mappedc.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/1Bolivia%2C%20Plurinational%20State%20of><http://example.com/code>"{{{ BO }}}" 
<http://example.com/2Ireland><http://example.com/code>"{{{ IE }}}" 
<http://example.com/3Saint%20Martin%20(French%20part)><http://example.com/code>"{{{ MF }}}" 

R2RML mapping: R2RMLTC010c

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;
        
	rr:logicalTable [ rr:tableName "Country Info"; ] ;
	
    rr:subjectMap [ rr:template "http://example.com/{Country Code}{Name}" ]; 
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:code ]; 
      rr:objectMap    [ rr:template "\\{\\{\\{ {ISO 3166} \\}\\}\\}" ]
    ]
    .

										

D011-M2MRelations

Title:Many to Many relations

Graphical representation:

Student
ID (PK)
INTEGER
FirstName
VARCHAR(50)
LastName
VARCHAR(50)
10VenusWilliams
11FernandoAlonso
12DavidVilla
Student_Sport
ID_Sport (PFK)
INTEGER
ID_Student (PFK)
INTEGER
11010
11111
11211
11112
Sport
ID (PK)
INTEGER
Description
VARCHAR(50)
110Tennis
111Football
112Formula1

SQL:

CREATE TABLE "Student" (
"ID" integer PRIMARY KEY,
"FirstName" varchar(50),
"LastName" varchar(50)
);
CREATE TABLE "Sport" (
"ID" integer PRIMARY KEY,
"Description" varchar(50)
);
CREATE TABLE "Student_Sport" (
"ID_Student" integer,
"ID_Sport" integer,
PRIMARY KEY ("ID_Student","ID_Sport"),
FOREIGN KEY ("ID_Student") REFERENCES "Student"("ID"),
FOREIGN KEY ("ID_Sport") REFERENCES "Sport"("ID")
);

INSERT INTO "Student" ("ID","FirstName","LastName") VALUES (10,'Venus', 'Williams');
INSERT INTO "Student" ("ID","FirstName","LastName") VALUES (11,'Fernando', 'Alonso');
INSERT INTO "Student" ("ID","FirstName","LastName") VALUES (12,'David', 'Villa');

INSERT INTO "Sport" ("ID", "Description") VALUES (110,'Tennis');
INSERT INTO "Sport" ("ID", "Description") VALUES (111,'Football');
INSERT INTO "Sport" ("ID", "Description") VALUES (112,'Formula1');

INSERT INTO "Student_Sport" ("ID_Student", "ID_Sport") VALUES (10,110);
INSERT INTO "Student_Sport" ("ID_Student", "ID_Sport") VALUES (11,111);
INSERT INTO "Student_Sport" ("ID_Student", "ID_Sport") VALUES (11,112);
INSERT INTO "Student_Sport" ("ID_Student", "ID_Sport") VALUES (12,111);

								

File:D011-M2MRelations

Direct Graph TC0011

Title:Many to Many relations

Purpose: Tests M to M relations

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D011-M2MRelations

Expected result: Direct Graph TC0011

RDF:

SubjectPredicateObject
<Student/ID.12#_><rdf:type><Student>
<Student/ID.12#_><Student#FirstName>"David"
<Student/ID.12#_><Student#LastName>"Villa"
<Student_Sport/ID_Student.10,ID_Sport.110#_><rdf:type><Student_Sport>
<Student_Sport/ID_Student.10,ID_Sport.110#_><Student_Sport#ID_Sport><Sport/ID.110#_>
<Student_Sport/ID_Student.10,ID_Sport.110#_><Student_Sport#ID_Student><Student/ID.10#_>
<Student/ID.11#_><rdf:type><Student>
<Student/ID.11#_><Student#FirstName>"Fernando"
<Student/ID.11#_><Student#LastName>"Alonso"
<Sport/ID.111#_><Sport#Description>"Football"
<Sport/ID.110#_><rdf:type><Sport>
<Sport/ID.110#_><Sport#Description>"Tennis"
<Student_Sport/ID_Student.12,ID_Sport.111#_><rdf:type><Student_Sport>
<Student_Sport/ID_Student.12,ID_Sport.111#_><Student_Sport#ID_Sport><Sport/ID.111#_>
<Student_Sport/ID_Student.12,ID_Sport.111#_><Student_Sport#ID_Student><Student/ID.12#_>
<Student_Sport/ID_Student.11,ID_Sport.111#_><rdf:type><Student_Sport>
<Student_Sport/ID_Student.11,ID_Sport.111#_><Student_Sport#ID_Sport><Sport/ID.111#_>
<Student_Sport/ID_Student.11,ID_Sport.111#_><Student_Sport#ID_Student><Student/ID.11#_>
<Student_Sport/ID_Student.11,ID_Sport.112#_><rdf:type><Student_Sport>
<Student_Sport/ID_Student.11,ID_Sport.112#_><Student_Sport#ID_Sport><Sport/ID.112#_>
<Student_Sport/ID_Student.11,ID_Sport.112#_><Student_Sport#ID_Student><Student/ID.11#_>
<Sport/ID.112#_><rdf:type><Sport>
<Sport/ID.112#_><Sport#Description>"Formula1"
<Student/ID.10#_><rdf:type><Student>
<Student/ID.10#_><Student#FirstName>"Venus"
<Student/ID.10#_><Student#LastName>"Williams"

R2RMLTC011a

Title:M to N relation, by using a SQL query

Purpose: Tests, M to N relations, by using a SQL query

Specification reference: #r2rml-views

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D011-M2MRelations

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/110Tennis><http://example.com/description>"Tennis" 
<http://example.com/110Tennis><http://example.com/id>"110"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/10VenusWilliams><http://example.com/plays><http://example.com/110Tennis> 
<http://example.com/10VenusWilliams><http://xmlns.com/foaf/0.1/lastName>"Williams" 
<http://example.com/10VenusWilliams><http://xmlns.com/foaf/0.1/firstName>"Venus" 
<http://example.com/10VenusWilliams><http://example.com/id>"10"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/111Football><http://example.com/description>"Football" 
<http://example.com/111Football><http://example.com/id>"111"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/12DavidVilla><http://example.com/plays><http://example.com/111Football> 
<http://example.com/12DavidVilla><http://xmlns.com/foaf/0.1/lastName>"Villa" 
<http://example.com/12DavidVilla><http://xmlns.com/foaf/0.1/firstName>"David" 
<http://example.com/12DavidVilla><http://example.com/id>"12"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/112Formula1><http://example.com/description>"Formula1" 
<http://example.com/112Formula1><http://example.com/id>"112"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/11FernandoAlonso><http://example.com/plays><http://example.com/112Formula1> 
<http://example.com/11FernandoAlonso><http://example.com/plays><http://example.com/111Football> 
<http://example.com/11FernandoAlonso><http://xmlns.com/foaf/0.1/lastName>"Alonso" 
<http://example.com/11FernandoAlonso><http://xmlns.com/foaf/0.1/firstName>"Fernando" 
<http://example.com/11FernandoAlonso><http://example.com/id>"11"^^<http://www.w3.org/2001/XMLSchema#integer> 

R2RML mapping: R2RMLTC011a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;

    rr:logicalTable [ rr:sqlQuery """
       SELECT Student.ID as ID,
              Student.FirstName as FirstName,
              Student.LastName as LastName,
              Sport.Description as Description,
              Sport.ID as Sport_ID
       FROM Student,Sport,Student_Sport
       WHERE Student.ID = Student_Sport.ID_Student
       AND Sport.ID = Student_Sport.ID_Sport;
       """; ];

    rr:subjectMap [ rr:template "http://example.com/{ID}{FirstName}{LastName}" ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:firstName ]; 
      rr:objectMap    [ rr:column "FirstName" ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:lastName ]; 
      rr:objectMap    [ rr:column "LastName" ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:plays ]; 
      rr:objectMap    [ rr:template "http://example.com/{Sport_ID}{Description}" ]
    ]
    .

<TriplesMap2>
    a rr:TriplesMap;

	rr:logicalTable [ rr:tableName  "Sport" ];
	
    rr:subjectMap [ 
		rr:template "http://example.com/{ID}{Description}"; 
		rr:class ex:Sport; 
	];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:description ]; 
      rr:objectMap    [ rr:column "Description" ]
    ]
    .

										

R2RMLTC011b

Title:M to N relation, by using an additional Triples Map

Purpose: Tests, M to N relations, by using an additional Triples Map

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D011-M2MRelations

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/student/10><http://xmlns.com/foaf/0.1/lastName>"Williams" 
<http://example.com/student/10><http://xmlns.com/foaf/0.1/firstName>"Venus" 
<http://example.com/student/10><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Student> 
<http://example.com/student/12><http://xmlns.com/foaf/0.1/lastName>"Villa" 
<http://example.com/student/12><http://xmlns.com/foaf/0.1/firstName>"David" 
<http://example.com/student/12><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Student> 
<http://example.com/student/11><http://xmlns.com/foaf/0.1/lastName>"Alonso" 
<http://example.com/student/11><http://xmlns.com/foaf/0.1/firstName>"Fernando" 
<http://example.com/student/11><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Student> 
<http://example.com/sport/110><http://example.com/description>"Tennis" 
<http://example.com/sport/110><http://example.com/id>"110"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/sport/110><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Sport> 
<http://example.com/sport/111><http://example.com/description>"Football" 
<http://example.com/sport/111><http://example.com/id>"111"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/sport/111><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Sport> 
<http://example.com/sport/112><http://example.com/description>"Formula1" 
<http://example.com/sport/112><http://example.com/id>"112"^^<http://www.w3.org/2001/XMLSchema#integer> 
<http://example.com/sport/112><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/Sport> 
<http://example.com/student/10><http://example.com/plays><http://example.com/sport/110> 
<http://example.com/student/12><http://example.com/plays><http://example.com/sport/111> 
<http://example.com/student/11><http://example.com/plays><http://example.com/sport/112> 
<http://example.com/student/11><http://example.com/plays><http://example.com/sport/111> 

R2RML mapping: R2RMLTC011b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    rr:logicalTable [ rr:tableName "Student"; ] ;
    rr:subjectMap [
        rr:template "http://example.com/student/{ID}";
        rr:class ex:Student;
    ];
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:firstName ]; 
      rr:objectMap    [ rr:column "FirstName" ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:lastName ]; 
      rr:objectMap    [ rr:column "LastName" ]
    ]
	.	
    
<TriplesMap2>
    rr:logicalTable [ rr:tableName "Sport"; ] ;
    rr:subjectMap [
        rr:template "http://example.com/sport/{ID}";
        rr:class ex:Sport;
    ];
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:id ]; 
      rr:objectMap    [ rr:column "ID"; rr:datatype xsd:integer ]
    ];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:description ]; 
      rr:objectMap    [ rr:column "Description" ]
    ]
	.

<LinkMap_1_2>
   
   rr:logicalTable [ rr:tableName "Student_Sport" ];
   
   rr:subjectMap [ rr:template "http://example.com/student/{ID_Student}" ];
   
   rr:predicateObjectMap [
       rr:predicateMap [ rr:predicate ex:plays ];
       rr:objectMap [ rr:template "http://example.com/sport/{ID_Sport}" ];
   ].
   
   

										

D012-2tables2duplicates0nulls

Title:Two tables two duplicates zero nulls

Graphical representation:

IOUs
amount
DOUBLE
lname
CHARACTER(20)
fname
CHARACTER(20)
30.0E0Smith Bob
20.0E0Jones Sue
30.0E0Smith Bob
Lives
lname
CHARACTER(20)
fname
CHARACTER(20)
city
CHARACTER(20)
Smith Bob London
Jones Sue Madrid
Smith Bob London

SQL:

CREATE TABLE "IOUs" (
      "fname" CHAR(20),
      "lname" CHAR(20),
      "amount" FLOAT);
INSERT INTO "IOUs" ("fname", "lname", "amount") VALUES ('Bob', 'Smith', 30);
INSERT INTO "IOUs" ("fname", "lname", "amount") VALUES ('Sue', 'Jones', 20);
INSERT INTO "IOUs" ("fname", "lname", "amount") VALUES ('Bob', 'Smith', 30);
CREATE TABLE "Lives" (
      "fname" CHAR(20),
      "lname" CHAR(20),
      "city" CHAR(20));
INSERT INTO "Lives" ("fname", "lname", "city") VALUES ('Bob', 'Smith', 'London');
INSERT INTO "Lives" ("fname", "lname", "city") VALUES ('Sue', 'Jones', 'Madrid');
INSERT INTO "Lives" ("fname", "lname", "city") VALUES ('Bob', 'Smith', 'London');

								

File:D012-2tables2duplicates0nulls

R2RMLTC012a

Title:Duplicate tuples generate same blank node

Purpose: Tests that blank nodes with same identifier and in the same graph but generated by different logical rows are considered equivalent.

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D012-2tables2duplicates0nulls

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff3<http://example.com/amount>"30.0"^^<http://www.w3.org/2001/XMLSchema#float> 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff3<http://xmlns.com/foaf/0.1/name>"Bob Smith" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff3<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/IOU> 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff2<http://example.com/amount>"20.0"^^<http://www.w3.org/2001/XMLSchema#float> 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff2<http://xmlns.com/foaf/0.1/name>"Sue Jones" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7ff2<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/IOU> 

R2RML mapping: R2RMLTC012a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;

	rr:logicalTable [ rr:tableName  "IOUs" ];
	
    rr:subjectMap [
            rr:template "{fname}_{lname}_{amount}"; 
            rr:termType rr:BlankNode;
            rr:class ex:IOU; 
      ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ 
            rr:template "{fname} {lname}";
            rr:termType rr:Literal ;
      ]
    ];
    
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:amount ]; 
      rr:objectMap    [ 
            rr:column "amount";
            rr:termType rr:Literal ;
            rr:datatype xsd:float ;
      ]
    ];
	.

										

R2RMLTC012b

Title:Duplicate tuples generate same blank node

Purpose: Tests that blank nodes with same identifier and in the same graph but generated by different logical rows are considered equivalent.

Specification reference: #termtype

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D012-2tables2duplicates0nulls

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7fef<http://example.com/city>"London" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7fef<http://xmlns.com/foaf/0.1/name>"Bob Smith" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7fef<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/IOU> 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7fee<http://example.com/amount>"Madrid" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7fee<http://xmlns.com/foaf/0.1/name>"Sue Jones" 
_:AX2dX38ec05dcX3aX131488bea58X3aXX2dX7fee<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/IOU> 

R2RML mapping: R2RMLTC012b

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;

	rr:logicalTable [ rr:tableName  "IOUs" ]; 
	
    rr:subjectMap [
            rr:template "{fname}_{lname}"; 
            rr:termType rr:BlankNode ;
            rr:class ex:IOU; 
      ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ 
            rr:template "{fname} {lname}";
            rr:termType rr:Literal ;
      ]
    ];
    .
<TriplesMap2>
    a rr:TriplesMap;
	
	rr:logicalTable [ rr:tableName  "Lives" ]; 

    rr:subjectMap [
            rr:template "{fname}_{lname}"; 
            rr:termType rr:BlankNode;
            rr:class ex:IOU; 
      ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:city ]; 
      rr:objectMap    [ 
            rr:column "city";
            rr:termType rr:Literal ; 
      ]
    ];
	.

										

R2RMLTC012c

Title:TriplesMap without subjectMap

Purpose: Tests a R2RML with missing information, TriplesMap without subjectMap.

Specification reference: #data-errors

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D012-2tables2duplicates0nulls

R2RML mapping: R2RMLTC012c

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;

	rr:logicalTable [ rr:tableName  "IOUs" ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ 
            rr:template "{fname} {lname}";
            rr:termType rr:Literal ;
      ]
    ];
    
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:amount ]; 
      rr:objectMap    [ 
            rr:column "amount";
            rr:termType rr:Literal ;
            rr:datatype xsd:float ;
      ]
    ];
	.

										

R2RMLTC012d

Title:TriplesMap with two subjectMap

Purpose: Tests a R2RML with wrong information, TriplesMap with two subjectMap.

Specification reference: #data-errors

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D012-2tables2duplicates0nulls

R2RML mapping: R2RMLTC012d

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap1>
    a rr:TriplesMap;

	rr:logicalTable [ rr:tableName  "IOUs" ];
	
    rr:subjectMap [
            rr:template "{fname}_{lname}_{amount}"; 
            rr:termType rr:BlankNode;
            rr:class ex:IOU; 
      ];

    rr:subjectMap [
            rr:template "{amount}_{fname}_{lname}"; 
            rr:termType rr:BlankNode;
            rr:class ex:IOU; 
      ];
	  
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ 
            rr:template "{fname} {lname}";
            rr:termType rr:Literal ;
      ]
    ];
    
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate ex:amount ]; 
      rr:objectMap    [ 
            rr:column "amount";
            rr:termType rr:Literal ;
            rr:datatype xsd:float ;
      ]
    ];
	.

										

D013-1table3columns2rows1nullvalue

Title:Table with null value

Graphical representation:

Person
ID (PK)
INTEGER
Name
VARCHAR(50)
DateOfBirth
VARCHAR(50)
1AliceNULL
2BobSeptember, 2010

SQL:

CREATE TABLE "Person" (
"ID" integer,
"Name" varchar(50),
"DateOfBirth" varchar(50),
PRIMARY KEY ("ID")
);
INSERT INTO "Person" ("ID", "Name", "DateOfBirth") VALUES (1,'Alice', NULL);
INSERT INTO "Person" ("ID", "Name", "DateOfBirth") VALUES (2,'Bob', 'September, 2010');

								

File:D013-1table3columns2rows1nullvalue

Direct Graph TC0013

Title:Direct Graph of table with NULL values

Purpose: Tests Direct Graph of table with NULL values

Specification reference: #rules_table_triples

Review status: http://www.w3.org/2006/03/test-description#accepted

Input: D013-1table3columns2rows1nullvalue

Expected result: Direct Graph TC0013

RDF:

SubjectPredicateObject
<Person/ID=1><Person#Name>"Alice"
<Person/ID=2><Person#Name>"Bob"
<Person/ID=2><Person#DateOfBirth>"September, 2010"

D014-3tablesExample

Title:3 tables extended example

Graphical representation:

EMP
empno (PK)
INTEGER
deptno (FK)
INTEGER
ename
VARCHAR(100)
job
VARCHAR(30)
etype
VARCHAR(30)
736910SMITHCLERKPART_TIME
LIKES
id
INTEGER
likedObj
VARCHAR(100)
likeType
VARCHAR(30)
7369SoccerPlaying
7369BasketballWatching
DEPT
dname
VARCHAR(30)
loc
VARCHAR(100)
deptno
INTEGER
APPSERVERNEW YORK10

SQL:

CREATE TABLE "DEPT" (
      "deptno" INTEGER UNIQUE,
      "dname" VARCHAR(30),
      "loc" VARCHAR(100));
INSERT INTO "DEPT" ("deptno", "dname", "loc") VALUES (10, 'APPSERVER', 'NEW YORK');

CREATE TABLE "EMP" (
      "empno" INTEGER PRIMARY KEY,
      "ename" VARCHAR(100),
      "job" VARCHAR(30),
	  "deptno" INTEGER REFERENCES "DEPT" ("deptno"),
	  "etype" VARCHAR(30));
INSERT INTO "EMP" ("empno", "ename", "job", "deptno", "etype" ) VALUES (7369, 'SMITH', 'CLERK', 10, 'PART_TIME');

CREATE TABLE "LIKES" (
      "id" INTEGER,
      "likeType" VARCHAR(30),
      "likedObj" VARCHAR(100));
INSERT INTO "LIKES" ("id", "likeType", "likedObj") VALUES (7369, 'Playing', 'Soccer');
INSERT INTO "LIKES" ("id", "likeType", "likedObj") VALUES (7369, 'Watching', 'Basketball');

								

File:D014-3tablesExample

R2RMLTC014a

Title:3 tables extended example

Purpose: Tests a logicaltable with sqlQuery

Specification reference: #dfn-graph-map

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D014-3tablesExample

Expected result: mappeda.nq

RDF:

SubjectPredicateObjectGraph
_:Department10<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/ns#dept><http://example.com/ns#DeptGraph>
_:Department10<http://example.com/dept#deptno>"10"^^<http://www.w3.org/2001/XMLSchema#positiveInteger><http://example.com/ns#DeptGraph>
_:Department10<http://example.com/dept#name>"APPSERVER"<http://example.com/ns#DeptGraph>
_:Department10<http://example.com/dept#location>"NEW YORK"<http://example.com/ns#DeptGraph>
_:Department10<http://example.com/dept#COMPANY>"EXAMPLE Corporation"<http://example.com/ns#DeptGraph>

R2RML mapping: R2RMLTC014a

RDF:

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@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://mappingpedia.org/rdb2rdf/r2rml/tc/> .

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

    rr:subjectMap [ rr:column "deptId"; rr:termType rr:BlankNode;
                    rr:class ex:dept; 
                    rr:graphMap [ rr:graph ex:DeptGraph; ];
                    rr:inverseExpression "{deptno} = substr({deptId},length('Department')+1)"];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate dept:deptno ]; 
      rr:objectMap    [ rr:column "deptno"; rr:datatype xsd:positiveInteger ]
    ];

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

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

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

										

R2RMLTC014b

Title:3 tables extended example

Purpose: Mapping specification using SQL-based logical table definition

Specification reference: #inverse

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D014-3tablesExample

Expected result: mappedb.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/ns#emp><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#jobtype><http://example.com/emp/job/CLERK><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/emp/job/CLERK><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#emptype><http://example.com/emp/etype/PART_TIME><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/emp/etype/PART_TIME><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#empno>"7369"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/graph/CLERK/PART_TIME><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#name>"SMITH"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#job>"CLERK"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#deptNum>"10"^^<http://www.w3.org/2001/XMLSchema#integer><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#etype>"PART TIME"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#c_ref_deptno>_:Department10<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#name>"SMITH"<http://example.com/emp#empNameGraph>

R2RML mapping: R2RMLTC014b

RDF:

@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://mappingpedia.org/rdb2rdf/r2rml/tc/> .


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

    rr:subjectMap [ rr:column "deptId"; rr:termType rr:BlankNode;
                    rr:class ex:dept; 
                    rr:graphMap [ rr:graph ex:DeptGraph; ];
                    rr:inverseExpression "{deptno} = substr({deptId},length('Department')+1)"];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate dept:deptno ]; 
      rr:objectMap    [ rr:column "deptno"; rr:datatype xsd:positiveInteger ]
    ];

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

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

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate dept:COMPANY ]; 
      rr:objectMap    [ 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 SCOTT.EMP
       """ ];

    rr:subjectMap [ rr:column "empURI";
                    rr:class ex:emp; 
                    rr:graphMap [ rr:column "graphURI" ]; ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:jobtype ]; 
      rr:objectMap    [ rr:column "jobTypeURI" ]
    ];

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

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

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

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

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:name ]; 
      rr:objectMap    [ rr:column "ename" ]; 
      rr:graphMap     [ rr:graph emp:empNameGraph ];
    ];

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

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

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

    rr:predicateObjectMap [
      rr:predicateMap [ rr:predicate emp:c_ref_deptno ];
      rr:refObjectMap    [
        rr:parentTriplesMap <TriplesMap1>;
        rr:joinCondition [
          rr:child "deptno";
          rr:parent "deptno";
        ];
      ];
    ]
    .

										

R2RMLTC014c

Title:3 tables extended example

Purpose: Mapping specification using table name based logical table definition

Specification reference: #foreign-key

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D014-3tablesExample

Expected result: mappedc.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/ns#emp><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#jobtype><http://example.com/emp/job/CLERK><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/emp/job/CLERK><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#emptype><http://example.com/emp/etype/PART_TIME> <http://example.com/graph/CLERK/PART_TIME> 
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/emp/etype/PART_TIME><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#empno>"7369"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/graph/CLERK/PART_TIME><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#name>"SMITH"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#job>"CLERK"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#deptNum>"10"^^<http://www.w3.org/2001/XMLSchema#integer><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#etype>"PART TIME"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#c_ref_deptno>_:Department10<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#name>"SMITH"<http://example.com/emp#empNameGraph>

R2RML mapping: R2RMLTC014c

RDF:

@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://mappingpedia.org/rdb2rdf/r2rml/tc/> .



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

    rr:subjectMap [ rr:column "deptId"; rr:termType rr:BlankNode;
                    rr:class ex:dept; 
                    rr:graphMap [ rr:graph ex:DeptGraph; ];
                    rr:inverseExpression "{deptno} = substr({deptId},length('Department')+1)"];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate dept:deptno ]; 
      rr:objectMap    [ rr:column "deptno"; rr:datatype xsd:positiveInteger ]
    ];

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

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

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

<TriplesMap2>
    a rr:TriplesMap;

    rr:logicalTable [ rr:tableName "SCOTT.EMP" ];

    rr:subjectMap [ rr:template "http://example.com/emp/{empno}";
                    rr:class ex:emp; 
                    rr:graphMap [ rr:template "http://example.com/graph/{job}/{etype}"; ];
                  ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:jobtype ]; 
      rr:objectMap    [ rr:template "http://example.com/emp/job/{job}" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate rdf:type ]; 
      rr:objectMap    [ rr:template "http://example.com/emp/job/{job}" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:emptype ]; 
      rr:objectMap    [ rr:template "http://example.com/emp/etype/{etype}" ]
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate rdf:type ]; 
      rr:objectMap    [ rr:template "http://example.com/emp/etype/{etype}" ]
    ];

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

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:name ]; 
      rr:objectMap    [ rr:column "ename" ]; 
      rr:graphMap     [ rr:graph emp:empNameGraph ];
    ];

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

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

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

    rr:predicateObjectMap [
      rr:predicateMap [ rr:predicate emp:c_ref_deptno ];
      rr:refObjectMap    [
        rr:parentTriplesMap <TriplesMap1>;
        rr:joinCondition [
          rr:child "deptno";
          rr:parent "deptno";
        ];
      ];
    ]
    .

										

R2RMLTC014d

Title:3 tables extended example

Purpose: Mapping specification showing reuse of ObjectMap elements

Specification reference: #foreign-key

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D014-3tablesExample

Expected result: mappedd.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/ns#emp><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#jobtype><http://example.com/emp/job/CLERK><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/emp/job/CLERK><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#emptype><http://example.com/emp/etype/PART_TIME> <http://example.com/graph/CLERK/PART_TIME> 
<http://example.com/emp/7369><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://example.com/emp/etype/PART_TIME><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#empno>"7369"^^<http://www.w3.org/2001/XMLSchema#integer> <http://example.com/graph/CLERK/PART_TIME><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#name>"SMITH"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#job>"CLERK"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#deptNum>"10"^^<http://www.w3.org/2001/XMLSchema#integer><http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#etype>"PART TIME"<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#c_ref_deptno>_:Department10<http://example.com/graph/CLERK/PART_TIME>
<http://example.com/emp/7369><http://example.com/emp#name>"SMITH"<http://example.com/emp#empNameGraph>

R2RML mapping: R2RMLTC014d

RDF:

@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://mappingpedia.org/rdb2rdf/r2rml/tc/> .

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

    rr:subjectMap [ rr:column "deptId"; rr:termType rr:BlankNode;
                    rr:class ex:dept; 
                    rr:graphMap [ rr:graph ex:DeptGraph; ];
                    rr:inverseExpression "{deptno} = substr({deptId},length('Department')+1)"];

    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate dept:deptno ]; 
      rr:objectMap    [ rr:column "deptno"; rr:datatype xsd:positiveInteger ]
    ];

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

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

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


<#jobtypeObjectMap>
    a rr:ObjectMap;
    rr:template "http://example.com/emp/job/{job}"
    .

<#emptypeObjectMap>
    a rr:ObjectMap;
    rr:template "http://example.com/emp/etype/{etype}"
    .

<TriplesMap2>
    a rr:TriplesMap;

    rr:logicalTable [ rr:tableName "SCOTT.EMP" ];

    rr:subjectMap [ rr:template "http://example.com/emp/{empno}";
                    rr:class ex:emp; 
                    rr:graphMap [ rr:template "http://example.com/graph/{job}/{etype}"; ];
                  ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:jobtype ]; 
      rr:objectMap    <#jobtypeObjectMap>
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate rdf:type ]; 
      rr:objectMap    <#jobtypeObjectMap>
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:emptype ]; 
      rr:objectMap    <#emptypeObjectMap>
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate rdf:type ]; 
      rr:objectMap    <#emptypeObjectMap>
    ];

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

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:predicate emp:name ]; 
      rr:objectMap    [ rr:column "ename" ]; 
      rr:graphMap     [ rr:graph emp:empNameGraph ];
    ];

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

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

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

    rr:predicateObjectMap [
      rr:predicateMap [ rr:predicate emp:c_ref_deptno ];
      rr:refObjectMap    [
        rr:parentTriplesMap <TriplesMap1>;
        rr:joinCondition [
          rr:child "deptno";
          rr:parent "deptno";
        ];
      ];
    ]
    .

										

R2RMLTC014e

Title:3 tables extended example

Purpose: Mapping Specification for the LIKES Table

Specification reference: #dfn-output-dataset

Review status: http://www.w3.org/2006/03/test-description#unreviewed

Input: D014-3tablesExample

Expected result: mappede.nq

RDF:

SubjectPredicateObjectGraph
<http://example.com/emp/7369><http://example.com/emp/likes/Playing>"Soccer"<http://example.com/ns#LikesGraph>
<http://example.com/emp/7369><http://example.com/emp/likes/Watching>"Basketball"<http://example.com/ns#LikesGraph>

R2RML mapping: R2RMLTC014e

RDF:

@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://mappingpedia.org/rdb2rdf/r2rml/tc/> .

<TriplesMap3>
    a rr:TriplesMap;
    rr:logicalTable [ rr:sqlQuery """
      Select ('http://example.com/emp/' || id) AS empId
           , ('http://example.com/emp/likes/' || likeType) AS empLikes
           , likedObj
        from SCOTT.LIKES
      """ ];

    rr:subjectMap [
      rr:column "empId";
      rr:graphMap [ rr:graph ex:LikesGraph ];
    ];

    rr:predicateObjectMap 
    [ 
      rr:predicateMap [ rr:column "empLikes" ];
      rr:objectMap    [ rr:column "likedObj" ]
    ]
    .