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

R2RML Test Cases v1

From RDB2RDF
Jump to: navigation, search

Go to TestCases description page

Test Cases

The table owner for the whole set of dbs: boricles.

1table0rows

Graphical Representation:

Student
Name

SQL:

CREATE TABLE Student (
Name varchar(50)
);


Direct Graph TC0000

Title: Empty table

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

Specification Reference: 1.30

Review Status: Accepted

Expected Result:

# empty graph

R2RMLTC0000

Title: Empty table

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

Specification Reference: 1.30

Review Status: Accepted.

Expected Result:

RDF:


R2RML Mapping:

@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:TriplesMapClass;
        
    rr:tableOwner "boricles";
    rr:tableName "Student";

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

1table1row

Graphical Representation:

Student
Name
Venus

SQL:

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


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: 1.30

Review Status: Accepted

Expected Result:

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

R2RMLTC0001a

Id: 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: 1.30

Review Status: Accepted

Expected Result:

RDF:

@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .

ex:Venus foaf:name "Venus".


R2RML Mapping:

@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:TriplesMapClass;
    
    rr:tableOwner "boricles";
    rr:tableName "Student";

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

R2RMLTC0001b

Id: 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: 1.30

Review Status: Accepted

Expected Result:

RDF:

@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .

_:Venus foaf:name "Venus".


R2RML Mapping:

@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:TriplesMapClass;
    
    rr:tableOwner "boricles";
    rr:tableName "Student";

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

1table2columns1row

Graphical Representation:

Student
ID Name
10 Venus

SQL:

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

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: 1.30

Review Status: Accepted

Expected Result:

_:a a <Student> .
_:a <Student#id> 10 .
_:a <Student#name> "Venus" .

R2RMLTC0002a

Id: 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

Specification Reference: 1.30

Review Status: Accepted

Expected Result:

RDF:

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

ex:10Venus rdf:type foaf:Person;
           ex:id "10"^^xsd:integer;
           foaf:name "Venus".

R2RML Mapping:

@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:TriplesMapClass;
    
    rr:tableOwner "boricles";
    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

Id: 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: 1.30

Review Status: Accepted

Expected Result:

RDF:

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

_:Student10 rdf:type foaf:Person;
            ex:id "10"^^xsd:integer;
            foaf:name "Venus".

R2RML Mapping:

@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:TriplesMapClass;
    
    rr:SQLQuery """
       Select ('Student' || ID ) AS "StudentId"
            , ID
            , Name
         from Student
       """;

    rr:subjectMap [ rr:column "StudentId"; rr:termtype "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" ]
    ]
    .

1table3columns1row

Graphical Representation:

Student
ID FirstName LastName
10 Venus Williams

SQL:

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

Direct Graph TC0003

Title: Three column mapping

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

Specification Reference: 1.30

Review Status: Accepted


Expected Result:

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

R2RMLTC0003a

Id: R2RMLTC0003a

Title: Three column mapping

Purpose: Tests: (1)three column mapping, no primary key; (2) Subject URI generated by concatenation of three column values and a constant value; (3) One column to one property

Specification Reference: 1.30

Review Status: Accepted

Expected Result:

RDF:

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

ex:Student10VenusWilliams rdf:type foaf:Person
                          ex:id "10"^^xsd:integer;
                          foaf:firstName "Venus";
                          foaf:lastName "Williams".

R2RML Mapping:

@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:TriplesMapClass;

    rr:tableOwner "boricles";
    rr:tableName "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

Id: R2RMLTC0003b

Title: Two column mapping, a concatenation operation

Purpose: Tests: (1) two column mapping, no primary key; (2) subject URI generated by concatenation of three column values and a constant value; (3) Two column to one property – concat operation

Specification Reference: 1.30

Review Status: Accepted.

Expected Result:

RDF:

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

ex:Student10VenusWilliams rdf:type foaf:Person
                          ex:id "10"^^xsd:integer;
                          foaf:name "Venus Williams".

R2RML Mapping:

@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:TriplesMapClass;

      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

Id: R2RMLTC0003c

Title: Three column mapping

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

Specification Reference: 1.30

Review Status: Accepted

Expected Result:

RDF:

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

_:Student10VenusWilliams rdf:type foaf:Person
                         ex:id "10"^^xsd:integer;
                         foaf:firstName "Venus";
                         foaf:lastName "Williams".

R2RML Mapping:

@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:TriplesMapClass;

      rr:SQLQuery """
      SELECT ('Student' || ID || FirstName || LastName) as StudentID,
             ID,
             FirstName,
             LastName
      FROM Student
      """;

    rr:subjectMap [ rr:column "StudentID"; rr:termtype "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:firstName ]; 
      rr:objectMap    [ rr:column "FirstName" ]
    ];

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

R2RMLTC0003d

Id: R2RMLTC0003d

Title: Two column mapping, a concatenation operation

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

Specification Reference: 1.30

Review Status: Accepted

Expected Result:

RDF:

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

_:Student10VenusWilliams rdf:type foaf:Person
                         ex:id "10"^^xsd:integer;
                         foaf:name "Venus Williams".

R2RML Mapping:

@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:TriplesMapClass;

      rr:SQLQuery """
      SELECT ('Student' || ID || FirstName || LastName) as StudentID,
             ID,
             (FirstName || ' ' || LastName) AS Name
      FROM Student
      """;

    rr:subjectMap [ rr:column "StudentID"; rr:termtype "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" ]
    ]
    .

1table2columnsprojection

Graphical Representation:

Student_Sport
Student Sport
Venus Tennis

SQL:

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

Direct Graph TC0004

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: 1.30

Review Status: Accepted

Expected Result:

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

R2RMLTC0004a

Id: 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: 1.30

Review Status: unreviewed

Expected Result:

RDF:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .

ex:Venus rdf:type ex:Student;
         foaf:name "Venus".

ex:Tennis rdf:type ex:Sport;
          foaf:name "Tennis".

R2RML Mapping:

@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:TriplesMapClass;

    rr:tableOwner "boricles";
    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:TriplesMapClass;

    rr:tableOwner "boricles";
    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

Id: 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: 1.30

Review Status: unreviewed

Expected Result:

RDF:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .

_:StudentVenus rdf:type ex:Student;
               foaf:name "Venus".

_:SportTennis rdf:type ex:Sport;
              foaf:name "Tennis".

R2RML Mapping:

@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:TriplesMapClass;

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

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

<TriplesMap2>
    a rr:TriplesMapClass;

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

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

2duplicates0nulls

Graphical Representation:

IOUs
fname lname amount
Bob Smith 30
Sue Jones 20
Bob Smith 30

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);

Direct Graph TC0005

Title: Duplicate tuples, no primary key

Purpose: Tests the generation of Blank Nodes for duplicate tuples

Specification Reference: 1.30

Review Status: Accepted


Expected Result:

 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
  
  _:a a <IOUs> .
  _:a <IOUs#fname> "Bob" .
  _:a <IOUs#lname> "Smith" .
  _:a <IOUs#amount> "30"^^xsd:float .
  
  _:b a <IOUs> .
  _:b <IOUs#fname> "Sue" .
  _:b <IOUs#lname> "Jones" .
  _:b <IOUs#amount> "20"^^xsd:float .
  
  _:c a <IOUs> .
  _:c <IOUs#fname> "Bob" .
  _:c <IOUs#lname> "Smith" .
  _:c <IOUs#amount> "30"^^xsd:float .

R2RMLTC0005a

1table1primarykey1column1row

Graphical Representation:

Student
Name (PK)
Venus

SQL:

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


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: 1.30

Review Status: Accepted


Expected Result:

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

R2RMLTC0006

1table1primarykey2columns1row

Graphical Representation:

Student
ID (PK) Name
10 Venus

SQL:

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


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: 1.30

Review Status: Accepted


Expected Result:

<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> .

R2RMLTC0007

1table1compositeprimarykey3columns1row

Graphical Representation:

Student
ID (PK) Name (PK) Sport
10 Venus Williams Tennis

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");


Direct Graph TC0008

Title: Composite primary key

Purpose: Tests a table with a composite primary key

Specification Reference: 1.30

Review Status: Accepted

Expected Result:

<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> .

R2RMLTC0008

2tables1primarykey1foreingkey

Graphical Representation:

Student
ID (PK) Name Sport (FK)
10 Venus Williams 100
20 Demi Moore NULL
Sport
ID (PK) Name
100 Tennis


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);

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: 1.30

Review Status: Accepted


Expected Result:

<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" .

R2RMLTC0009

Id: R2RMLTC0009

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: 1.30

Review Status: unreviewed

Expected Result:

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/> .

<http://example.org/graph/students> 
    { 
       <http://example.com/resource/student_10> a <http://example.com/ontology/Student> .
       <http://example.com/resource/student_10> foaf:name "Venus Williams" .
       <http://example.com/resource/student_20> a <http://example.com/ontology/Student> .
       <http://example.com/resource/student_20> foaf:name "Demi Moore" .
    }

<http://example.org/graph/sports>
    { 
       <http://example.com/resource/sport_100> a <http://example.com/ontology/Sport> .
       <http://example.com/resource/sport_100> rdf:label "Tennis" .
    }
 
<http://example.org/graph/practise>
    { 
       <http://example.com/resource/student_10> <http://example.com/ontology/practises> <http://example.com/resource/sport_100> .
    }


R2RML Mapping:

@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:TriplesMapClass;
        
    rr:tableOwner "alex";
    rr:tableName "Student";

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

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

<TriplesMap2>
    a rr:TriplesMapClass;
        
    rr:tableOwner "alex";
    rr:tableName "Sport";

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

I18NnoSpecialChars

Graphical Representation:

植物
使用部 条件
シソ 新鮮な
成分
植物名 使用部
しそのとまと シソ

SQL:

CREATE TABLE `植物` (
  `名` CHAR(10),
  `使用部` CHAR(10),
  `条件` CHAR(10),
  PRIMARY KEY (`名`, `使用部`)
);
INSERT INTO `植物` (`名`, `使用部`, `条件`) VALUES ("しそ", "葉", "新鮮な");

CREATE TABLE `成分` (
  `皿`  CHAR(10),
  `植物名` CHAR(10),
  `使用部` CHAR(10),
  FOREIGN KEY (`植物名`, `使用部`) REFERENCES `植物`(`名`, `使用部`)
);
INSERT INTO `成分` (`皿`, `植物名`, `使用部`) VALUES ("しそのとまと", "しそ", "葉");


Direct Graph TC0010

Title: I18N No Special Chars

Purpose: Do we want to encode all [^0-9A-Za-z]?

Specification Reference: @@1.30

Review Status: proposed

Expected Result:

<植物/名.しそ,使用部.葉#_>
      a       <植物> ;
      <植物#使用部> "葉" ;
      <植物#名>  "しそ" ;
      <植物#条件> "新鮮な" .

_:a    a       <成分> ;
       <成分#使用部> "葉" ;
       <成分#植物名> "しそ" ;
       <成分#植物名,使用部> <植物/名.しそ,使用部.葉#_> ;
       <成分#皿>  "しそのとまと" .

vs.

_:a    a       <%E6%88%90%E5%88%86> ;
       <%E6%88%90%E5%88%86#%E4%BD%BF%E7%94%A8%E9%83%A8>
              "葉" ;
       <%E6%88%90%E5%88%86#%E6%A4%8D%E7%89%A9%E5%90%8D>
              "しそ" ;
       <%E6%88%90%E5%88%86#%E6%A4%8D%E7%89%A9%E5%90%8D,%E4%BD%BF%E7%94%A8%E9%83%A8>
              <%E6%A4%8D%E7%89%A9/%E5%90%8D.%E3%81%97%E3%81%9D,%E4%BD%BF%E7%94%A8%E9%83%A8.%E8%91%89#_> ;
       <%E6%88%90%E5%88%86#%E7%9A%BF>
              "しそのとまと" .

<%E6%A4%8D%E7%89%A9/%E5%90%8D.%E3%81%97%E3%81%9D,%E4%BD%BF%E7%94%A8%E9%83%A8.%E8%91%89#_>
      a       <%E6%A4%8D%E7%89%A9> ;
      <%E6%A4%8D%E7%89%A9#%E4%BD%BF%E7%94%A8%E9%83%A8>
              "葉" ;
      <%E6%A4%8D%E7%89%A9#%E5%90%8D>
              "しそ" ;
      <%E6%A4%8D%E7%89%A9#%E6%9D%A1%E4%BB%B6>
              "新鮮な" .

R2RMLTC0010

Title: @@

Purpose: @@

Specification Reference: @@1.30

Review Status: templated.

Expected Result:

RDF:


R2RML Mapping:


M2MRelations

Graphical Representation:

Student
ID (PK) FirstName LastName
10 Venus Williams
11 Fernando Alonso
12 David Villa
Student_Sport
ID_Student (FK - Student(ID)) ID_Sport (FK - Sport(ID))
10 110
11 111
11 112
12 111
Sport
ID (PK) Description
110 Tennis
111 Football
112 Formula1


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);

Direct Graph TC0011

Title: Many to Many relations

Purpose: Tests M to M relations

Specification Reference: 1.30

Review Status: Accepted

Expected Result:

<Student/ID.12#_> <rdf:type> <Student> .
<Student/ID.12#_> <Student#FirstName> "David".
<Student/ID.12#_> <Student#ID> 12 .
<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#ID> 11 .
<Student/ID.11#_> <Student#LastName> "Alonso" .

<Sport/ID.111#_>  <rdf:type>  <Sport>.
<Sport/ID.111#_> <Sport#Description> "Football" .
<Sport/ID.111#_> <Sport#ID> 111 .

<Sport/ID.110#_> <rdf:type>  <Sport> .
<Sport/ID.110#_> <Sport#Description> "Tennis" .
<Sport/ID.110#_> <Sport#ID> 110 .

<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" .
<Sport/ID.112#_>  <Sport#ID> 112 .

<Student/ID.10#_> <rdf:type>  <Student> .
<Student/ID.10#_> <Student#FirstName> "Venus" .
<Student/ID.10#_> <Student#ID> 10 .
<Student/ID.10#_> <Student#LastName> "Williams" .


R2RMLTC0011

Id: R2RMLTC0011

Title: M to N relation

Purpose: Tests, M to N relations

Specification Reference: 1.30

Review Status: unreviewed

Expected Result:

RDF:

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

ex:10VenusWilliams ex:id "10"^^xsd:integer;
                   foaf:firstName "Venus";
                   foaf:lastName "Williams";
                   ex:plays ex:110Tennis.

ex:11FernandoAlonso ex:id "11"^^xsd:integer;
                    foaf:firstName "Fernando";
                    foaf:lastName "Alonso";
                    ex:plays ex:111Football;
                    ex:plays ex:112Formula1. 

ex:12DavidVilla ex:id "12"^^xsd:integer;
                   foaf:firstName "David";
                   foaf:lastName "Villa";
                   ex:plays ex:111Football.

ex:110Tennis ex:id "110"^^xsd:integer;
             ex:description "Tennis".

ex:111Football ex:id "111"^^xsd:integer;
               ex:description "Football".

ex:112Formula1 ex:id "112"^^xsd:integer;
               ex:description "Formula1".

R2RML Mapping:

@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:TriplesMapClass;

       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:TriplesMapClass;

    rr:tableOwner "boricles";
    rr:tableName "Sport";

    rr:subjectMap [ rr:template "http://example.com/{ID}{Description}" ];

    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" ]
    ]
    .

2tables2duplicates0nulls

Graphical Representation:

IOUs
fname lname amount
Bob Smith 30
Sue Jones 20
Bob Smith 30
Lives
fname lname city
Bob Smith London
Sue Jones Madrid
Bob Smith 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 IOUs (fname, lname, amount) VALUES ("Bob", "Smith", "London");
INSERT INTO IOUs (fname, lname, amount) VALUES ("Sue", "Jones", "Madrid");
INSERT INTO IOUs (fname, lname, amount) VALUES ("Bob", "Smith", "London");


Direct Graph TC0012

R2RMLTC0012a

Id: R2RMLTC0012a

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:


Review Status: unreviewed

Expected Result:

RDF:

 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
 @prefix foaf: <http://xmlns.com/foaf/0.1/> .
 @prefix ex: <http://example.com/> .
  
  _:a a ex:IOU .
  _:a foaf:name "Bob Smith" .
  _:a ex:amount "30"^^xsd:float .
  
  _:b a ex:IOU .
  _:b foaf:name "Sue Jones" .
  _:b ex:amount "20"^^xsd:float .

R2RML Mapping:

@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:TriplesMapClass;

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

R2RMLTC0012b

Id: R2RMLTC0012b

Title: Same blank node generated from different part of the map.

Purpose: Tests that blank nodes with same identifier and in the same graph but generated by via different part of the mapping are considered equivalent.

Specification Reference:


Review Status: unreviewed

Expected Result:

RDF:

 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
 @prefix foaf: <http://xmlns.com/foaf/0.1/> .
 @prefix ex: <http://example.com/> .
  
  _:a a ex:IOU .
  _:a foaf:name "Bob Smith" .
  _:a ex:city "London" .
  
  _:b a ex:IOU .
  _:b foaf:name "Sue Jones" .
  _:b ex:amount "Madrid" .

R2RML Mapping:

@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:TriplesMapClass;
    rr:tableName "IOUs"
    rr:tableOwner "alex"

    rr:subjectMap [
            rr:template "{fname}_{lname}"; 
            rr:termtype "BlankNode";
            rr:class ex:IOU; 
      ];
	
    rr:predicateObjectMap
    [ 
      rr:predicateMap [ rr:predicate foaf:name ]; 
      rr:objectMap    [ 
            rr:template "{fname} {lname}";
            rr:termtype "Literal" 
      ]
    ];
    .
<TriplesMap2>
    a rr:TriplesMapClass;
    rr:tableName "Lives"
    rr:tableOwner "alex"

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

1table3columns2rows1nullvalue

Graphical Representation:

Person
ID (PK) Name DateOfBirth
1 Alice NULL
2 Bob September, 2010

SQL:

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

Direct Graph TC0013

Title: Direct Graph of table with NULL values

Purpose: Tests Direct Graph of table with NULL values

Specification Reference: 1.30

Review Status: Accepted


Expected Result:

<Person#ID> rdfs:domain <Person> .
<Person#Name> rdfs:domain <Person> .
<Person#DateOfBirth> rdfs:domain <Person> .

<Person/ID=1> a <Person> .
<Person/ID=1> <Person#Name> "Alice" .

<Person/ID=2> a <Person> .
<Person/ID=2> <Person#Name> "Bob" .
<Person/ID=2> <Person#DateOfBirth> "September, 2010" .

R2RMLTC0013

Id:


Title:


Purpose:

Specification Reference:


Review Status:


Expected Result:

RDF:


R2RML Mapping: