SlideShare a Scribd company logo
1 of 239
Relational Database to RDF
(RDB2RDF)
Tutorial
International Semantic Web
Conference ISWC2013
Juan F. Sequeda
Daniel P. Miranker

Barry Norton
RDB2RDF Tutorial
Introduction
Juan F. Sequeda
Daniel P. Miranker

Barry Norton
What is RDB2RDF?
Alice

Person
ID NAME

AGE

CID

1

Alice

25

100

2

Bob

NULL

100

foaf:name

25

Alice

foaf:age

<Person/1>

foaf:name

<Person/2>

foaf:based_near

City
CID

NAME

100

Austin

200

Madrid

<City/100>

<City/200>
www.rdb2rdf.org - ISWC2013

foaf:name

foaf:name

Austin

Madrid
Context
RDF
Data Management

Relational Database to RDF
(RDB2RDF)

Wrapper
Systems

Extract-Transform-Load
(ETL)

Native
Triplestores
www.rdb2rdf.org - ISWC2013

Triplestores

RDBMS-backed
NoSQL
Triplestores
Triplestores
Outline
ā€¢ Historical Overview
ā€¢ 4 Scenarios
ā€¢ Overview W3C RDB2RDF Standards
ā€“ Direct Mapping
ā€“ R2RML

www.rdb2rdf.org - ISWC2013
www.rdb2rdf.org - ISWC2013
www.rdb2rdf.org - ISWC2013
www.rdb2rdf.org - ISWC2013
F2F Meeting
ISWC 2008

March 2008

1. Recommendation
to standardize a
mapping language
2. RDB2RDF Survey

October 2008

February 2009

(1) http://www.w3.org/2005/Incubator/rdb2rdf/XGR-rdb2rdf-20090126/
(2) http://www.w3.org/2005/Incubator/rdb2rdf/RDB2RDF_SurveyReport.pdf
www.rdb2rdf.org - ISWC2013
Sept 2012

Sept 2009

www.rdb2rdf.org - ISWC2013
WD
R2RML+DM
FPWD
DM

FPWD
R2RML

250

WD
R2RML+DM

Candidate Rec
R2RML + DM Proposed Rec
R2RML + DM
WD
R2RML + DM

200

150

100

50

First F2F
@Semtech 2010

www.rdb2rdf.org - ISWC2013

Photo from cygri http://www.flickr.com/photos/cygri/4719458268/

Oct-12

Sep-12

Aug-12

Jul-12

Jun-12

May-12

Apr-12

Mar-12

Feb-12

Jan-12

Dec-11

Nov-11

Oct-11

Sep-11

Aug-11

Jul-11

Jun-11

May-11

Apr-11

Mar-11

Feb-11

Jan-11

Dec-10

Nov-10

Oct-10

Sep-10

Aug-10

Jul-10

Jun-10

May-10

Apr-10

Mar-10

Feb-10

Jan-10

Dec-09

Nov-09

Oct-09

Sep-09

0

Rec
R2RML + DM
Statistics
ā€¢ 206 Actions
ā€¢ 78 Issues
ā€“ 61 Closed
ā€“ 17 Postponed

ā€¢ public-rdb2rdf-wg
ā€“ 3393 emails (Sept 2009 ā€“ Oct 2012)

ā€¢ public-rdb2rdf-comments
ā€“ 200 emails (Sept 2009 ā€“ March 2013)
www.rdb2rdf.org - ISWC2013
Outline
ā€¢ Historical Overview
ā€¢ 4 Scenarios
ā€¢ Overview W3C RDB2RDF Standards
ā€“ Direct Mapping
ā€“ R2RML

www.rdb2rdf.org - ISWC2013
How to include relational data in a
semantic application?
ā€¢ Many architectural design choices.
ā€¢ Technology Development Fluid.

ā€¢ No established ā€œbest-of-breedā€ solā€™n.

www.rdb2rdf.org - ISWC2013
Feature Space of Design Choices
ā€¢ Scope of the application
ā€“ Mash-up topic page
ā€“ Heterogeneous Enterprise Data Application

ā€¢ Size of the (native) database
ā€“ Data Model
ā€“ Contents

ā€¢ Size of the useful (in application) database
ā€“ Data Model
ā€“ Contents

ā€¢ When to translate the data?
ā€“ Wrapper
ā€“ ETL

www.rdb2rdf.org - ISWC2013
Reduction to 4 Scenarioā€™s

www.rdb2rdf.org - ISWC2013
Scenario 1: Direct Mapping
Suppose:
ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions
ā€“ Database is static.
ā€“ Herbs and conditions do not have representation in western medical ontologies.

www.rdb2rdf.org - ISWC2013
Scenario 1: Direct Mapping
Suppose:
ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions
ā€“ Database is static.
ā€“ Herbs and conditions do not have representation in western medical ontologies.

SPARQL
Relational
Database

Extract

Direct
Mapping
Engine

Triplestore

Transform

www.rdb2rdf.org - ISWC2013

Load
Scenario 1: Direct Mapping
Suppose:
ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions
SPARQL
Relational
Database

Extract

Direct
Mapping
Engine

Triplestore

Transform

Load

Then:
ā€¢ Existing table and column names are encoded into URIs
ā€¢ Data is translated into RDF and loaded into an existing, Internet
accessible triplestore.
www.rdb2rdf.org - ISWC2013
Scenario 2: R2RML
Suppose:
ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions
+ Clinical Records
ā€“ Database is static.
ā€“ Also have, patient names, demographics, outcomes

www.rdb2rdf.org - ISWC2013
Scenario 2: R2RML
Suppose:
ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions
+ Clinical Records
Domain
Ontologies
(e.g FOAF, etc)

SPARQL
R2RML
Mapping
Engine

R2RML
File

Extract

Triplestore

Transform

Relational
Database
www.rdb2rdf.org - ISWC2013

Load
Scenario 2: R2RML
ā€¢

Database of Chinese Herbal Medicine and Applicable Conditions
+ Clinical Records

Domain
Ontologies
(e.g FOAF, etc)

SPARQL
R2RML
Mapping
Engine

R2RML
File

Extract

Triplestore

Transform

Load

Relational
Database

ā€¢

Then:
ā€“ Developer says, ā€œI know FOAF, Iā€™ll write some R2RML and that data will have
canonical URIs, and people will be able to use the dataā€.

www.rdb2rdf.org - ISWC2013
Scenario 4: Automatic Mapping
Suppose:
ā€¢
ā€¢
ā€¢
ā€¢

Database of Electronic Medical Records
Application, integration of all of a hospitals IT systems
Database has 100 tables and a total of 7,000 columns
Use of existing ontologies as a unifying data model
ā€“ ICDE10 codes (> 12,000 concepts)
ā€“ SNOMED vocabulary (> 40,000 concepts)

www.rdb2rdf.org - ISWC2013
Scenario 4: Automatic Mapping
Suppose:
ā€¢ 7,000 Columns
ā€¢ Use of existing ontologies as a
unifying data model
ā€“ ICDE10 codes (> 12,000 concepts)
ā€“ SNOMED vocabulary (> 40,000 concepts)

Then:
ā€¢ Convert the database schema and
data to an ontology.
SPARQL
ā€¢ Apply ontology alignment program RDF

Automatic
Mapping

Domain
Ontologies
Source
Putative
Ontology

Refined
R2RML

Direct
Mapping as
Ontology
RDB2RDF Wrapper
Relational Database

www.rdb2rdf.org - ISWC2013
Scenario 4: Automatic Mapping
Suppose:
ā€¢ 7,000 Columns
ā€¢ Use of existing ontologies as a
unifying data model
ā€“ ICDE10 codes (> 12,000 concepts)
ā€“ SNOMED vocabulary (> 40,000 concepts)

Then:
ā€¢ A semantic system implements the
solution with no human labor
SPARQL
RDF

Automatic
Mapping

Domain
Ontologies
Source
Putative
Ontology

Refined
R2RML
Direct
Mapping as
Ontology
RDB2RDF Wrapper
Relational Database

www.rdb2rdf.org - ISWC2013
Scenario 3: Semi-automatic Mapping
Domain
Ontologies

SemiAutomatic
Mapping

Refined
R2RML

Source
Putative
Ontology

Direct
Mapping as
Ontology

SPARQL
RDF

RDB2RDF
Wrapper
Relational
Database
www.rdb2rdf.org - ISWC2013
Outline
ā€¢ Historical Overview
ā€¢ 4 Scenarios
ā€¢ Overview W3C RDB2RDF Standards
ā€“ Direct Mapping
ā€“ R2RML

www.rdb2rdf.org - ISWC2013
W3C RDB2RDF Standards
ā€¢ Standards to map relational data to RDF
ā€¢ A Direct Mapping of Relational Data to RDF
ā€“ Default automatic mapping of relational data to
RDF

ā€¢ R2RML: RDB to RDF Mapping Language
ā€“ Customizable language to map relational data to
RDF
www.rdb2rdf.org - ISWC2013
www.rdb2rdf.org - ISWC2013
Direct Mapping

Relational
Database

Direct
Mapping
Engine

Input:
Database (Schema and Data)
Primary Keys
Foreign Keys

www.rdb2rdf.org - ISWC2013

RDF

Output
RDF graph
Direct Mapping Result
25

Alice

Person
ID NAME

<Person#NAME>

AGE

Alice

<Person#AGE>

<Person#NAME>

CID

1

Alice

25

100

2

Bob

NULL

100

City

<Person/ID=1>

<Person/ID=2>

<Person#ref-CID>

CID

NAME

100

Austin

200

Madrid

<Person#ref-CID>

<City/CID=100>
<City/CID=200>
www.rdb2rdf.org - ISWC2013

<Person#NAME>
<Person#NAME>

Austin
Madrid
www.rdb2rdf.org - ISWC2013
R2RML
OWL
Ontologies
(e.g FOAF, etc)

R2RML
File

R2RML
Mapping
Engine

Relational
Database

www.rdb2rdf.org - ISWC2013

RDF
Direct Mapping as R2RML
@prefix rr: <http://www.w3.org/ns/r2rml#> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/ID={ID}";
rr:class <http://www.ex.com/Person>
];
rr:predicateObjectMap [
rr:predicate <http://www.ex.com/Person#NAME> ;
rr:objectMap [rr:column ā€NAME" ]
].
www.rdb2rdf.org - ISWC2013
Customized R2RML
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;

rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
www.rdb2rdf.org - ISWC2013
.
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableNameā€Person" ];
rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person ];
rr:predicateObjectMap [
rr:predicate
foaf:based_near ;
rr:objectMap
[
rr:parentTripelMap <TripleMap2>;
rr:joinCondition [
rr:child ā€œCIDā€;
rr:parent ā€œCIDā€;
]
]
<TriplesMap2>
]
a rr:TriplesMap;
.
rr:logicalTable [ rr:tableName ā€City" ];
rr:subjectMap [ rr:template "http://ex.com/City/{CID}";
rr:class ex:City ];
rr:predicateObjectMap [
rr:predicate
foaf:name;
rr:objectMap
[ rr:column ā€TITLE" ]
]
.
www.rdb2rdf.org - ISWC2013
R2RML View
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:sqlQuery
ā€œā€ā€SELECT ID, NAME
FROM Person WHERE gender = ā€œFā€ ā€œā€ā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class <http://www.ex.com/Woman>
];
rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
www.rdb2rdf.org - ISWC2013
.
Questions
Next: Direct Mapping
RDB2RDF Tutorial
Direct Mapping

Juan F. Sequeda
Daniel P. Miranker

Barry Norton
Direct Mapping

Relational
Database

Direct
Mapping
Engine

RDF

Completely Automatic

40
W3C Direct Mapping
ā€¢ Input:
ā€“ Database (Schema and Data)
ā€“ Primary Keys
ā€“ Foreign Keys

ā€¢ Output
ā€“ RDF graph

41
What do we need to automatically
generate?
ā€¢ Generate Identifiers
ā€“ IRI
ā€“ Blank Nodes

ā€¢ Generate Triples
ā€“ Table
ā€“ Literal
ā€“ Reference
Generating Identifiers
ā€¢ Identifier for rows, tables, columns and foreign
keys
ā€¢ If a table has a primary key,
ā€“ then the row identifier will be an IRI,
ā€“ otherwise a blank node

ā€¢ The identifiers for table, columns and foreign keys
are IRIs
ā€¢ IRIs are generated by appending to a given base
IRI
ā€¢ All strings are percent encoded
Row Node
Base IRI

ā€œTable Nameā€/ā€œPK attrā€=ā€œPK valueā€

1) <http://www.ex.com/Person/ID=1>
Base IRI

ā€œTable Nameā€/ā€œPK attrā€=ā€œPK valueā€

2) <http://www.ex.com/Person/ID=1;SID=123>

3) Fresh Blank Node
More IRI
Base IRI

ā€œTable Nameā€

1) <http://www.ex.com/Person>
Base IRI

ā€œTable Nameā€#ā€œAttributeā€

2) <http://www.ex.com/Person#NAME>
Base IRI

ā€œTable Nameā€#ref-ā€œAttributeā€

3) <http://www.ex.com/Person#ref-CID>
Table Triple
Person
ID (pk)

NAME

AGE

1

Alice

25

2

Bob

NULL

<http://www.ex.com/Person/ID=1>
rdf:type
<http://www.ex.com/Person>
46
Literal Triples
Person
ID (pk)

NAME

AGE

1

Alice

25

2

Bob

NULL

<http://www.ex.com/Person/ID=1>
<http://www.ex.com/Person#NAME>
ā€œAliceā€ .
47
Reference Triples
City

Person
ID
(pk)

AGE

CID
(fk)

CID
(pk)

NAME

TITLE

1

Alice

25

100

100

Austin

2

Bob

NULL

200

200

Madrid

<http://www.ex.com/Person/ID=1>
<http://www.ex.com/Person#ref-CID>

<http://www.ex.com/City/CID=100>.
48
Direct Mapping Result
25

Alice

Person
ID NAME

<Person#NAME>

AGE

Alice

<Person#AGE>

<Person#NAME>

CID

1

Alice

25

100

2

Bob

NULL

100

City

<Person/ID=1>

<Person/ID=2>

<Person#ref-CID>

CID

NAME

100

Austin

200

Madrid

<Person#ref-CID>

<City/CID=100>
<City/CID=200>

<Person#NAME>
<Person#NAME>

Austin
Madrid
49
Summary: Direct Mapping
ā€¢ Default and Automatic Mapping
ā€¢ URIs are automatically generated
ā€“
ā€“
ā€“
ā€“

<table>
<table#attribute>
<table#ref-attribute>
<Table#pkAttr=pkValue>

ā€¢ RDF represents the same relational schema
ā€¢ RDF can be transformed by
SPARQL CONSTRUCT
ā€“ RDF represents the structure and ontology of mapping
authorā€™s choice
50
What else is missing?
ā€¢ Relational Schema to OWL is *not* in the
W3C standard
ā€¢ NULL values
ā€¢ Many-to-Many relationships (binary tables)

ā€¢ ā€œUglyā€ IRIs
51
NULL
ā€œThe direct mapping does not generate triples
for NULL values. Note that it is not known how
to relate the behavior of the obtained RDF graph
with the standard SQL semantics of the NULL
values of the source RDB.ā€
A Direct Mapping of Relational Data to RDF.
W3C Recommendation
52
Problem
1. How can a relational database schema and
data, be automatically mapped to OWL and
RDF?

2. How can we assure correctness of mapping?

53
Product
ptID

label

prID

10

ACME Inc

4

11

FooBars

String

5

String

pt:Producer

pt:label

ex:Producer

ex:Product

String
rdf:type

rdf:type

Producer
prID

title

loc

4

Foo

5

Bar

pt:label

pr:title

pt:Producer

TX
NULL

FooBars

Input
ā€¢ Relational Schema R
ā€¢ Set Ī£ of Primary Keys PK and
Foreign Keys FK over R
ā€¢ Instance I of R

ex:Product11

Mapping

ex:Producer5

Bar

Output
ā€¢ RDF graph
ā€¢ OWL ontology as a graph

We need to be careful about two issues
ā€¢ Binary Relations
ā€¢ NULLs
54
NULLs
ā€¢ What should we do with NULLs?
ā€“ Generate a Blank Node

title

loc

4
Bar

prID

Foo

TX

5

Bar

NULL

ex:Producer5
_:a

ā€“ Donā€™t generate a triple
pr:title
ex:Producer5

Bar

How do we
reconstruct the
NULL?

55
Direct Mapping Properties
ā€¢ Fundamental Properties
ā€“ Information Preserving: no information is lost
ā€“ Query Preserving: no query is lost

ā€¢ Desirable Properties
ā€“ Monotonicity
ā€“ Semantics Preserving:
Information Preservation
Direct Mapping

RDB
Inverse Direct Mapping

57
Query Preservation
Result of Q

RDB

=

Result of Q*

Direct Mapping

58
Monotonicity
New Data

Direct Mapping

RDB

subset

RDB

subset

Direct Mapping

59
Semantics Preservation
RDB

RDB

Direct Mapping

Direct Mapping

60
Semantics Preservation
The Nugget
ā€¢ Defined a Direct Mapping DM
ā€¢ Formally defined semantics using Datalog
ā€¢ Considered RDBs that may contain NULL values
ā€¢ Studied DM wrt 4 properties
ā€“
ā€“
ā€“
ā€“

Information Preservation
Query Preservation
Monotonicity
Semantics Preservation

Sequeda, Arenas & Miranker. On Directly Mapping Relational Databases to RDF and OWL. WWW 2012
Sequeda et. al. Survey of Directly Mapping SQL Databases to the Semantic Web. J KER 2011
62
Tirmizi, Sequeda & Miranker. Translating SQL Applications to the Semantic Web. DEXA 2008
Direct Mapping
Input: A relational schema R a set of Ī£ of
primary keys and foreign keys and a database
instance I of this schema
Output: An RDF Graph
Definition:
A direct mapping M is a total function from the
set of all (R, Ī£, I) to the set of all RDF graphs
63
The Direct Mapping DM
ā€¢ Relational Schema to OWL
ā€“ S.H. Tirmizi, J.F. Sequeda and D.P. Miranker.
Translating SQL Applications to the Semantic Web.
DEXA 2008

ā€¢ Relational Data to RDF
ā€“ M. Arenas, A. Bertails, E. Prudā€™hommeaux and J.F.
Sequeda. A Direct Mapping of Relational Data to
RDF. W3C Recommendation. 27 September 2012

64
Direct Mapping RDB to RDF and OWL

R, Ī£
I

Predicates to
store (R, Ī£, I)

Datalog Rules
to generate
O from R, Ī£

Predicates to
Store Ontology O

Datalog Rules
to generate
OWL from O

Datalog Rules
to generate
RDF from O and I

OWL

RDF

65
Running Example
Consider the following relational schema:
ā€“ person(ssn, name, age) : ssn is the primary key
ā€“ student(id, degree, ssn) : id is the primary key,
ssn is a foreign key to ssn in person

Consider the following instance:
person

student
id

degree

ssn

ssn

name

age

1

Math

789

123

Juan

26

2

EE

456

456

Marcelo

27

3

CS

123

789

Daniel

NULL
66
Input: Relational Schema
student

ā€¢ Rel(r) :
ā€“ Rel(student)

ā€¢ Attr(a, r) :

id

degree

ssn

1

Math

789

2

EE

456

3

CS

123

ā€“ Attr(degree, student)

ā€¢ PKn(a1, ā€¦ , an, r) :
ā€“ PK1(id, student)

ā€¢ FKn(a1, ā€¦ , an, r, b1, ā€¦ , bn, s) :
ā€“ FK1(ssn, student, ssn, person)
67
Input: Instances
student

ā€¢ Value(v, a, t, r)
ā€“
ā€“
ā€“
ā€“
ā€“
ā€“
ā€“
ā€“
ā€“

Value( 1, id, t1, student)
Value( Math, degree, t1, student)
Value( 789, ssn, t1, student)
Value( 2, id, t2, student)
Value( EE, degree, t2, student)
Value( 456, ssn, t2, student)
Value( 3, id, t3, student)
Value( CS, degree, t3, student)
Value( 123, ssn, t3, student)

id

degree

ssn

1

Math

789

2

EE

456

3

CS

123

68
Mapping to OWL
Triple(http://ex.org/person, rdf:type, owl:Class)

Triple(U,"rdf:type","owl:Class") ā† Class(R), ClassIRI(R, U)
ClassIRI(R, X) ā† Class(R), Concat2(base, R, X)
Class(X) ā† Rel(X), Ā¬IsBinRel(X)

IsBinRel(X) ā† BinRel(X, A, B, S, C, T, D)
BinRel(R, A, B, S, C, T, D) ā†
PK2(A, B, R), Ā¬ThreeAttr(R), FK1(A,R,C,S),R =Ģø S, FK1(B,R,D,T),R =Ģø T,
Ā¬TwoFK(A, R), Ā¬TwoFK (B, R), Ā¬OneFK(A, B, R), Ā¬FKTo(R)
69
Mapping to RDF
Table triples: for each relation, store the tuples
that belongs to it
Triple(http://ex.org/person#ssn=123,
rdf:type, http://ex.org/person)

70
Mapping to RDF
Table triples: for each relation, store the tuples
that belongs to it
Triple(http://ex.org/person#ssn=123 ,
rdf:type, http://ex.org/person )

Literal triples: for each tuple, store the values in
each of its attributes
Triple(http://ex.org/person#ssn=123 ,
http://ex.org/person#name , ā€œJuanā€)
71
Mapping to RDF
Reference triples: store the references generated by
the FKs
Triple(http://ex.org/student#id=3 ,
http://ex.org/student,person#ssn,ssn ,
http://ex.org/person#ssn=123 )

72
Mapping to RDF
Triple(http://ex.org/person#ssn=123 , http://ex.org/person#name , ā€œJuanā€)

Triple(U,V, W) ā† DTP(A,R), Value(W, A, T, R), W != NULL.
TupleID(T,R,U), DTP_IRI(A,R,V)
DTP_IRI(A, R, X) ā† DTP(A,R) , Concat4(base, R,ā€#ā€, A, X)

DTP(A,R) ļƒŸ Attr(A,R), Ā¬IsBinRel(X)
TupleID(T, R, X) ļƒŸ Class(R), PKn(A1, ā€¦, An, R),
Value(V1, A1, T, R), ā€¦, Value(Vn, An, T, R),
RowIRIn(V1, ā€¦, Vn, A1, ā€¦, An, T, R, X)
73
Information Preservation
M(R, Ī£, I)

R, Ī£
I
M- (M(R, Ī£, I))
Theorem: The Direct Mapping is information preserving
Proof: Provide a computable mapping M74
Relational Algebra tuples vs.
SPARQL mappings
person
ssn
789

name
Daniel

age
NULL

t.ssn = 789
t.name = Daniel
t.age = NULL

Then, tr(t) = Ī¼ :
ā€¢ Domain of Ī¼ is {?ssn, ?name}
ā€¢ Ī¼(?ssn) = 789
ā€¢ Ī¼(?name) = Daniel
75
Query Preservation
tr(eval(Q, I))

R, Ī£
I

=

eval(Q*, M(R, Ī£, I))

M(R, Ī£, I)

Theorem: The Direct Mapping is query preserving
Proof: By induction on the structure of Q
Bottom-up algorithm for translating Q into Q*

76
Example of Query Preservation
Ļ€name, age( Ļƒdegree ā‰  EE (student)

person)

person

student
id

degree

ssn

ssn

name

age

1

CS

789

123

Juan

26

2

EE

456

456

Marcelo

27

3

Math

123

789

Daniel

NULL
77
Example of Query Preservation
Ļ€name, age( Ļƒdegree ā‰  EE (student)

person)

SELECT ?id ?degree ?ssn
WHERE {
?x rdf:type <ā€¦/student>.
OPTIONAL{?x <ā€¦/student#id> ?id. }
OPTIONAL{?x <ā€¦/student#degree> ?degree. }
OPTIONAL{?x <ā€¦/student#ssn> ?ssn. }
}

student
id

degree

ssn

1

CS

789

2

EE

456

3

Math

123
78
Example of Query Preservation
Ļ€name, age( Ļƒdegree ā‰  EE (student)

person)

SELECT ?id ?degree ?ssn
WHERE {
?x rdf:type <ā€¦/student>.
OPTIONAL{?x <ā€¦/student#id> ?id. }
OPTIONAL{?x <ā€¦/student#degree> ?degree. }
OPTIONAL{?x <ā€¦/student#ssn> ?ssn. }
FILTER(?degree != ā€œEEā€ && bound(?degree) )
}
student
id

degree

ssn

1

CS

789

2

EE

456

3

Math

123
79
Example of Query Preservation
Ļ€name, age( Ļƒdegree ā‰  EE(student)

person)

SELECT ?ssn ?name ?age
WHERE {
?x rdf:type <ā€¦/person>.
OPTIONAL{?x <ā€¦/person#ssn> ?ssn. }
OPTIONAL{?x <ā€¦/person#name> ?name. }
OPTIONAL{?x <ā€¦/person#age > ?age. }
}

person
ssn

name

age

123

Juan

26

456

Marcelo

27

789

Daniel

NULL
80
Ļ€name,age( Ļƒdegree ā‰  EE(student)
SELECT ?name ?age{
{SELECT ?id ?degree ?ssn
WHERE {
?x rdf:type <ā€¦/student>.
OPTIONAL{?x <ā€¦/student#id> ?id. }
OPTIONAL{?x <ā€¦/student#degree> ?degree. }
OPTIONAL{?x <ā€¦/student#ssn> ?ssn. }
FILTER(?degree != ā€œEEā€ && bound(?degree) )
FILTER(bound(?ssn)}
}
{SELECT ?ssn?name ?age
WHERE {
?x rdf:type <ā€¦/person>.
OPTIONAL{?x <ā€¦/person#ssn> ?ssn. }
OPTIONAL{?x <ā€¦/person#name> ?name. }
OPTIONAL{?x <ā€¦/person#age > ?age. }
FILTER(bound(?ssn)}
}
}

person)

81
Monotonicity
R, Ī£
I2
I1

M(R, Ī£, I2)

I2

M(R, Ī£, I1)

R, Ī£
I1

M(R, Ī£, I2)

M(R, Ī£, I1)

Theorem: The Direct Mapping is monotone
Proof: All negative atoms in the Datalog rules refer to the schema,
where the schema is fixed.

82
Semantics Preservation
Consistent under
OWL semantics

I satisfies Ī£

R, Ī£
I

M(R, Ī£, I)

Not consistent under
OWL semantics

I does not satisfies Ī£

R, Ī£
I

M(R, Ī£, I)

83
DM is not Semantics Preserving
person
ssn

Juan

name

123

Juan

123

DM(R, Ī£, I)

123

person#ssn

#ssn=123

Marcelo

Marcelo

ssn is the PK

I does not satisfy Ī£

however

DM(R, Ī£, I) is consistent
under OWL semantics

Theorem: No monotone direct mapping is semantics preserving
Proof: By contradiction.
84
Extending DM for Semantics
Preservation
ā€¢ Family of Datalog rules to determine violation
ā€“ Primary Keys
ā€“ Foreign Keys

ā€¢ Non-monotone direct mapping
ā€¢ Information Preserving
ā€¢ Query Preserving
ā€¢ Semantics Preserving
85
Summary
ā€¢ The Direct Mapping DM
ā€“ Formally defined semantics using Datalog
ā€“ Consider RDBs that may contain NULL values
ā€“ Monotone, Information and Query Preserving

ā€¢ If you migrate your RDB to the Semantic Web
using a monotone direct mapping, be
prepared to experience consistency when
what one would expect is inconsistency.
86
W3C Direct Mapping
ā€¢ Only maps Relational Data to RDF
ā€“ Does not consider schema

ā€¢ Monotone
ā€¢ Not Information Preserving
ā€“ Because it does not direct map the schema

ā€¢ Not Semantics Preserving

87
Questions?
Next: From Direct Mapping to R2RML
Backup Slides

89
DM is not Semantics Preserving
PREFIX ex: <http://ex.org/>
PREFIX person: <http://ex.org/person#>
ex:person rdf:type owl:Class .
person:name rdf:type owl:DatatypeProperty ;
rdfs:domain ex:person .
person:ssn rdf:type owl:DatatypeProperty ;
rdfs:domain ex:person .

person
ssn

name

123

Juan

123

DM(R, Ī£, I)

Marcelo

ssn is the PK

Juan
123

person#ssn

#ssn=123
Marcelo

I does not satisfy Ī£

however

DM(R, Ī£, I) is consistent
under OWL semantics
90
What about owl:hasKey
student

ā€¢ Student/id=NULL, rdf:type Student
ā€¢ Student/id=1, degree, math

id

degree

NULL Math

ā€¢ owl:hasKey can not make me have a value

91
owl:hasKey
student

ā€¢ Tuple 1
ā€“ Student/id=1, student#id, 1
ā€“ Student/id=1, degree, math

id

degree

1

Math

1

EE

ā€¢ Tuple 2
ā€“ Student/id=1, student#id, 1
ā€“ Student/id=1, degree, EE

ā€¢ DM generate the same IRI Student/id=1 for two
different tuples. This does not violate owl:hasKey

92
owl:hasKey
student

ā€¢ Tuple 1
ā€“ Student/id=1, student#id, 1
ā€“ Student/id=1, degree, math

id

degree

1

Math

1

EE

ā€¢ Tuple 2
ā€“ Student/id=1, student#id, 1
ā€“ Student/id=1, degree, EE

ā€¢ However, UNA works:
ā€“ Student/id=1 differentFrom Student/id=1
ā€¢ However a new DM that generates IRIs based on tuple ids
ā€“ Owl:hasKey would work

93
Semantics Preserving DMpk
ā€¢ Find violation of PK
ā€¢ Create artificial triple that will generate
contradiction

94
Semantics Preserving DMpk+fk
ā€¢ Find violation of FK
ā€¢ Create artificial triple that will generate
contradiction

95
RDB2RDF Tutorial
From Direct Mapping to R2RML

Juan F. Sequeda
Daniel P. Miranker

Barry Norton
R2RML
OWL
Ontologies
(e.g FOAF, etc)

R2RML
File

R2RML
Mapping
Engine

RDF

Relational
Database

97
W3C R2RML
ā€¢ Input
ā€“ Database (schema and data)
ā€“ Target Ontologies
ā€“ Mappings between the Database and Target
Ontologies in R2RML

ā€¢ Output
ā€“ RDF graph

98
OWL
Ontologies
(e.g FOAF, etc)

R2RML
File

R2RML
Mapping
Engine

RDF

Relational
Database
Direct Mapping helps to ā€œbootstrapā€
99
Direct Mapping as R2RML
25

Alice

Person
ID NAME

<Person#NAME>

AGE

Alice

<Person#AGE>

<Person#NAME>

CID

1

Alice

25

100

2

Bob

NULL

100

City

<Person/ID=1>

<Person/ID=2>

<Person#ref-CID>

CID

NAME

100

Austin

200

Madrid

<Person#ref-CID>

How can this be
represented as R2RML?

<City/CID=100>
<City/CID=200>

<Person#NAME>
<Person#NAME>

Austin
Madrid
100
Direct Mapping as R2RML
@prefix rr: <http://www.w3.org/ns/r2rml#> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/ID={ID}";
rr:class <http://www.ex.com/Person>
];
rr:predicateObjectMap [
rr:predicate <http://www.ex.com/Person#NAME> ;
rr:objectMap [rr:column ā€NAME" ]
].
101
Direct Mapping as R2RML
@prefix rr: <http://www.w3.org/ns/r2rml#> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€]; mapped?
Logical Table: What is being
rr:subjectMap [
rr:template "http://www.ex.com/Person/ID={ID}";
SubjectMap: How to generate the Subject?
rr:class <http://www.ex.com/Person>
];
rr:predicateObjectMap [
rr:predicate <http://www.ex.com/Person#NAME> ;
PredicateObjectMap: ā€NAME" ]
rr:objectMap [rr:column How to generate the Predicate and Object?
].
102
Logical Table
@prefix rr: <http://www.w3.org/ns/r2rml#> .

<TriplesMap1>
a rr:TriplesMap;

What is being mapped?

rr:logicalTable [ rr:tableName ā€Personā€];

rr:subjectMap [
rr:template "http://www.ex.com/Person/ID={ID}";
rr:class <http://www.ex.com/Person>
];
rr:predicateObjectMap [
rr:predicate <http://www.ex.com/Person#NAME> ;
rr:objectMap [rr:column ā€NAME" ]
]
.

103
Subject URI Template
@prefix rr: <http://www.w3.org/ns/r2rml#> .

<TriplesMap1>
a rr:TriplesMap;

Subject URI

rr:logicalTable [ rr:tableName ā€Personā€];

rr:subjectMap [
rr:template "http://www.ex.com/Person/ID={ID}";
rr:class <http://www.ex.com/Person>
];
rr:predicateObjectMap [
rr:predicate <http://www.ex.com/Person#NAME> ;
rr:objectMap [rr:column ā€NAME" ]
]
<Subject URI> rdf:type <Class
.

URI>
104
Predicate URI Constant
@prefix rr: <http://www.w3.org/ns/r2rml#> .

<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];

Predicate URI

rr:subjectMap [
rr:template "http://www.ex.com/Person/ID={ID}";
rr:class <http://www.ex.com/Person>
];
rr:predicateObjectMap [
rr:predicate <http://www.ex.com/Person#NAME> ;
rr:objectMap [rr:column ā€NAME" ]
]
.

105
Object Column Value
@prefix rr: <http://www.w3.org/ns/r2rml#> .

<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];

rr:subjectMap [
rr:template "http://www.ex.com/Person/ID={ID}";
rr:class <http://www.ex.com/Person>
];
rr:predicateObjectMap [
rr:predicate <http://www.ex.com/Person#NAME> ;
rr:objectMap [rr:column ā€NAME" ]
]
.

Object Literal

106
ā€œUglyā€ vs ā€œCoolā€ URIs
<http://www.ex.com/Person/ID=1>
<http://www.ex.com/Person#NAME>
<http://www.ex.com/Person>

<http://www.ex.com/Person/1>

foaf:name
foaf:Person
107
Customization
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;

Customized Subject URI

rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
.

Customized Class

108
What if ā€¦
Person
ID

NAME GENDER

1

Alice

F

2

Bob

M

<Woman>
rdf:type

<Person/1>

foaf:name

Alice

R2RML View

SELECT ID, NAME
FROM Person
WHERE GENDER = "F"
109
R2RML View
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;

Query instead of table

rr:logicalTable [ rr:sqlQuery
ā€œā€ā€SELECT ID, NAME
FROM Person WHERE gender = ā€œFā€ ā€œā€ā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class <http://www.ex.com/Woman>
];

rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
.

110
Quick Overview of R2RML
ā€¢ Manual and Customizable Language
ā€¢ Learning Curve

ā€¢ Direct Mapping bootstraps R2RML
ā€¢ RDF represents the structure and ontology of
mapping authorā€™s choice
111
Questions?
Next: R2RML
RDB2RDF Tutorial
R2RML

Juan F. Sequeda
Daniel P. Miranker

Barry Norton
Outline
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢

Logical Tables: What is being mapped
Term Maps: How to create RDF terms
How to create Triples from a table
How to create Triples between two tables
Languages
Datatypes
R2RML Mapping
Input Database

R2RML Mapping

Logical Table
Logical Table = base table or view or SQL query
R2RML View = SQL Query
R2RML Mapping
Student
sid name

pid

1

Juan

100

2

Martin 200
Professor
pid

name

100 Dan
200 Marcelo

R2RML Mapping
ex:Student1 rdf:type ex:Student .
ex:Student2 rdf:type ex:Student .
ex:Professor100 rdf:type ex:Professor .
ex:Professor200 rdf:type ex:Professor .
ex:Student1 foaf:name ā€œJuanā€.
ā€¦
R2RML Mapping
ā€¢ A R2RML Mapping M consists of a finite set TM
TripleMaps.
ā€¢ Each TM āˆˆTM consists of a tuple
(LT, SM, POM)
ā€“ LT: LogicalTable
ā€“ SM: SubjectMap
ā€“ POM: PredicateObjectMap

ā€¢ Each POMāˆˆPOM consists of a pair (PM, OM)*
ā€“ PM: PredicateMap
ā€“ OM: ObjectMap
* For simplicity
R2RML Mapping
ā€¢ An R2RML Mapping is represented as an RDF
Graph itself.
ā€¢ Associated RDFS schema
ā€“ http://www.w3.org/ns/r2rml

ā€¢ Turtle is the recommended syntax
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
.
119
LogicalTable
ā€¢ Tabular SQL query result that is to be mapped
to RDF
ā€“ rr:logicalTable

1. SQL base table or view
ā€“ rr:tableName

2. R2RML View
ā€“ rr:sqlQuery
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
.
121
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:sqlQuery
ā€œā€ā€SELECT ID, NAME
FROM Person WHERE gender = ā€œFā€ ā€œā€ā€];

rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class <http://www.ex.com/Woman>
];
rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
.
How to create RDF terms that define
S, P and O?
ā€¢ RDF term is either an IRI, a blank node, or a
literal
ā€¢ Answer
1. Constant Value
2. Value in the database
a. Raw Value in a Column
b. Column Value applied to a template
TermMap
ā€¢ A TermMap is a function that generates an
RDF Term from a logical table row.
ā€¢ RDF Term is either a IRI, or a Blank Node, or a
Literal
RDF Term
TermMap
Logical Table Row

IRI

Bnode
Literal
TermMap
ā€¢ A TermMap must be exactly on of the
following
ā€“ Constant-valued TermMap
ā€“ Column-valued TermMap
ā€“ Template-valued TermMap

ā€¢ If TermMaps are used to create S, P, O, then
ā€“ 3 ways to create a subject
ā€“ 3 ways to create a predicate
ā€“ 3 ways to create an object
How many ways to create a Triple?
Ptemplate
Stemplate

PConstant
Pcolumn

Otemplate
Oconstant
Ocolumn
Otemplate
Oconstant Sconstant
Ocolumn
Otemplate
Oconstant
Ocolumn
Ptemplate
Scolumn

PConstant
Pcolumn

Ptemplate
PConstant
Pcolumn
Otemplate
Oconstant
Ocolumn
Otemplate
Oconstant
Ocolumn
Otemplate
Oconstant
Ocolumn

Otemplate
Oconstant
Ocolumn
Otemplate
Oconstant
Ocolumn
Otemplate
Oconstant
Ocolumn
Constant-valued TermMap
ā€¢ A TermMap that ignores the logical table row
and always generates the same RDF term
ā€¢ rr:constant
ā€¢ Commonly used to generate constant IRIs as
the predicate
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name ]
rr:objectMap [rr:column ā€NAME" ]
]
.
129
Column-valued TermMap
ā€¢ A TermMap that maps a column value of a
column name in a logical table row
ā€¢ rr:column
ā€¢ Commonly used to generate Literals as the
object
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name ]
rr:objectMap [rr:column ā€NAME" ]
]
.
131
Template-valued TermMap
ā€¢ A TermMap that maps the column values of a
set of column names to a string template.
ā€¢ A string template is a format that can be used
to build strings from multiple components.
ā€¢ rr:template
ā€¢ Commonly used to generate IRIs as the
subject or concatenate different attributes
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name ]
rr:objectMap [rr:column ā€NAME" ]
]
.
133
Commonly usedā€¦
ā€¢ ā€¦ but any of these TermMaps can be used to
create any RDF Term (s,p,o). Recall:
ā€“ 3 ways to create a subject
ā€“ 3 ways to create a predicate
ā€“ 3 ways to create an object

ā€¢ Template-valued TermMap are commonly used to
create an IRI for a subject, but can be used to
create Literal for an object.
ā€¢ How to specify the term (IRI or Literal in this
case)?
TermType
ā€¢ Specify the type of a term that a TermMap
should generate
ā€¢ Force what the RDF term should be
ā€¢ Three types of TermType:
ā€“ rr:IRI
ā€“ rr:BlankNode
ā€“ rr:Literal
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name ]
rr:objectMap [
rr:template ā€{FIRST_NAME} {LAST_NAME}ā€;
rr:termType rr:Literal;
]
]
.

136
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template ā€person{ID}";
rr:termType rr:BlankNode;
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name ]
rr:objectMap [rr:column ā€NAME" ]
]
.

137
TermType (contā€¦)
ā€¢ Can only be applied to Template and Column
valued TermMap
ā€¢ Applying to Constant-valued TermMap has no
effect
ā€“ i.e If the constant is an IRI, the term type is
automatically an IRI
TermType Rules
ā€¢ If the Term Map is for a
1. Subject ļƒ  TermType = IRI or Blank Node
2. Predicate ļƒ  TermType = IRI
3. Object ļƒ  TermType = IRI or Blank Node or Literal
TermType is Optional
ā€¢ If a TermType is not specified then
ā€“ Default = IRI
ā€“ Unless itā€™s for an object being defined by a
Column-based TermMap or has a language tag or
specified datatype, then the TermType is a Literal

ā€¢ Thatā€™s why if there is a template in an
ObjectMap, it will always generate an IRI,
unless a TermType to Literal is specified.
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name ]
rr:objectMap [
rr:template ā€{FIRST_NAME} {LAST_NAME}ā€;
rr:termType rr:Literal;
]
]
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name ]
rr:objectMap [
rr:template ā€{FIRST_NAME} {LAST_NAME}ā€
]
]

rr:predicateObjectMap [
rr:predicateMap [rr:constant ex:role ]
rr:objectMap [
rr:template ā€http://ex.com/role/{role}ā€
]
]

141
Now we have the elements to
create Triples
Generating SPO
ā€¢ TermMap that specifies what RDF term should
be for S, P, O
ā€“ SubjectMap
ā€“ PredicateMap
ā€“ ObjectMap
SubjectMap
ā€¢
ā€¢
ā€¢
ā€¢

SubjectMap is a TermMap
rr:subjectMap
Specifies what the subject of a triple should be
3 ways to create a subject
ā€“ Template-valued Term Map
ā€“ Column-valued Term Map
ā€“ Constant-valued Term Map

ā€¢ Has to be an IRI or Blank Node
SubjectMap
ā€¢ SubjectMaps are usually Template-valued
TermMap
ā€¢ Use-case for Column-valued TermMap
ā€“ Use a column value to create a blank node
ā€“ URI exist as a column value

ā€¢ Use-case for Constant-valued TermMap
ā€“ For all tuples: <CompanyABC> <consistsOf> <Dep{id}>
SubjectMap
ā€¢ Optionally, a SubjectMap may have one or
more Class IRIs associated
ā€“ This will generate rdf:type triples

ā€¢ rr:class
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
.

Optional

148
PredicateObjectMap
ā€¢ A function that creates one or more predicateobject pairs for each logical table row.
ā€¢ rr:predicateObjectMap
ā€¢ It is used in conjunction with a SubjectMap to
generate RDF triples in a TriplesMap.
ā€¢ A predicate-object pair consists of*
ā€“ One or more PredicateMaps
ā€“ One or more ObjectMaps or
ReferencingObjectMaps
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name];
[rr:column ā€NAME" ]
]
.

rr:objectMap

150
PredicateMap
ā€¢ PredicateMap is a TermMap
ā€¢ rr:predicateMap
ā€¢ Specifies what the predicate of a triple should
be
ā€¢ 3 ways to create a predicate
ā€“ Template-valued Term Map
ā€“ Column-valued Term Map
ā€“ Constant-valued Term Map

ā€¢ Has to be an IRI
PredicateMap
ā€¢ PredicateMaps are usually Constant-valued
TermMap
ā€¢ Use-case for Column-valued TermMap
ā€“ā€¦

ā€¢ Use-case for Template-valued TermMap
ā€“ā€¦
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name];
rr:objectMap [rr:column ā€NAME" ]
]
.
153
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];

Shortcut!

rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [rr:column ā€NAME" ]
]
.
154
Constant Shortcut Properties
ā€¢ ?x rr:predicate ?y
ā€¢ ?x rr:predicateMap [ rr:constant ?y ]
ā€¢ ?x rr:subject ?y
ā€¢ ?x rr:subjectMap [ rr:constant ?y ]
ā€¢ ?x rr:object ?y
ā€¢ ?x rr:objectMap [ rr:constant ?y ]
ObjectMap
ā€¢
ā€¢
ā€¢
ā€¢

ObjectMap is a TermMap
rr:objectMap
Specifies what the object of a triple should be
3 ways to create a predicate
ā€“ Template-valued Term Map
ā€“ Column-valued Term Map
ā€“ Constant-valued Term Map

ā€¢ Has to be an IRI or Literal or Blank Node
ObjectMap
ā€¢ ObjectMaps are usually Column-valued
TermMap
ā€¢ Use-case for Template-valued TermMap
ā€“ Concatenate values
ā€“ Create IRIs

ā€¢ Use-case for Constant-valued TermMap
ā€“ All rows in a table share a role
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€Personā€];
rr:subjectMap [
rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person
];
rr:predicateObjectMap [
rr:predicateMap [rr:constant foaf:name];
rr:objectMap [rr:column ā€NAME" ]
]
.
158
Example 1
ā€¢ We now have sufficient elements to create a
mapping that will generate
ā€“ A Subject IRI
ā€“ rdf:Type triple(s)
Student
sid name

pid

1

Juan

100

2

Martin 200

TripleMap

@prefix ex: <http://example.com/ns/>.
ex:Student1 rdf:type ex:Student .
ex:Student2 rdf:type ex:Student .
Example 1
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix ex: <http://example.com/ns/>.
<#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
].

Logical Table is a Table Name
SubjectMap is a
Template-valued TermMap
And it has one Class IRI
Example 2

Student
sid name

pid

1

Juan

100

2

Martin 200

TripleMap

@prefix ex: <http://example.com/ns/>.
ex:Student1 rdf:type ex:Student .
ex:Student1 ex:name ā€œJuanā€ .
ex:Student2 rdf:type ex:Student .
ex:Student2 ex:name ā€œMartinā€ .
Example 2
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix ex: <http://example.com/ns/>.
<#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
];
rr:predicateObjectMap [
rr:predicate ex:name;
rr:objectMap [ rr:column ā€œnameā€];
].

PredicateMap which is a
Constant-valued TermMap

Logical Table is a Table Name
SubjectMap is a
Template-valued TermMap
And it has one Class IRI

PredicateObjectMap

ObjectMap which is a
Column-valued TermMap
Example 3

Student
sid name

pid

1

Juan

100

2

Martin 200

TripleMap

@prefix ex: <http://example.com/ns/>.
ex:Student1 rdf:type ex:Student .
ex:Student1 ex:comment ā€œJuan is a Studentā€ .
ex:Student2 rdf:type ex:Student .
ex:Student2 ex:comment ā€œMartin is a Studentā€ .
Example 3
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix ex: <http://example.com/ns/>.
<#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
];
rr:predicateObjectMap [
rr:predicate ex:comment;
rr:objectMap [
rr:template ā€œ{name} is a Studentā€;
rr:termType rr:Literal;
];
].

PredicateMap which is a
Constant-valued TermMap

Logical Table is a Table Name
SubjectMap is a
Template-valued TermMap
And it has one Class IRI

PredicateObjectMap

ObjectMap which is a
Template-valued TermMap
TermType
Example 4

Student
sid name

pid

1

Juan

100

2

Martin 200

TripleMap

@prefix ex: <http://example.com/ns/>.
ex:Student1 rdf:type ex:Student .
ex:Student1 ex:webpage <http://ex.com/Juan>.
ex:Student2 rdf:type ex:Student .
ex:Student2 ex:webpage <http://ex.com/Martin>.
Example 4
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix ex: <http://example.com/ns/>.
<#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
];
rr:predicateObjectMap [
rr:predicate ex:webpage;
rr:objectMap [
rr:template ā€œhttp://ex.com/{name}ā€;
];
].

PredicateMap which is a
Constant-valued TermMap

Logical Table is a Table Name
SubjectMap is a
Template-valued TermMap
And it has one Class IRI

PredicateObjectMap

ObjectMap which is a
Template-valued TermMap
Note that there is not TermType
Example 5

Student
sid name

pid

1

Juan

100

2

Martin 200

TripleMap

@prefix ex: <http://example.com/ns/>.
ex:Student1 rdf:type ex:Student .
ex:Student1 ex:studentType ex:GradStudent.
ex:Student2 rdf:type ex:Student .
ex:Student2 ex:studentType ex:GradStudent.
Example 6
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix ex: <http://example.com/ns/>.
<#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
];
rr:predicateObjectMap [
rr:predicate ex:studentType;
rr:object ex:GradStudent ;
].

PredicateMap which is a
Constant-valued TermMap

Logical Table is a Table Name
SubjectMap is a
Template-valued TermMap
And it has one Class IRI

PredicateObjectMap

ObjectMap which is a
Constant-valued TermMap
RefObjectMap
ā€¢ A RefObjectMap (Referencing ObjectMap)
allows using the subject of another TriplesMap
as the object generated by a ObjectMap.
ā€¢ rr:objectMap
ā€¢ A RefObjectMap defined by
ā€“ Exactly one ParentTripleMap, which must be a
TripleMap
ā€“ May have one or more JoinConditions
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableNameā€Person" ];
rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person ];
rr:predicateObjectMap [
rr:predicate
foaf:based_near ;
rr:objectMap
[
rr:parentTripelMap <TripleMap2>;
rr:joinCondition [
rr:child ā€œCIDā€;
rr:parent ā€œCIDā€;
]
]
<TriplesMap2>
]
a rr:TriplesMap;
.
rr:logicalTable [ rr:tableName ā€City" ];

RefObjectMap

rr:subjectMap [ rr:template "http://ex.com/City/{CID}";
rr:class ex:City ];
rr:predicateObjectMap [
rr:predicate
foaf:name;
rr:objectMap
[ rr:column ā€TITLE" ]
]
.

171
ParentTripleMap
ā€¢ The referencing TripleMap
ā€¢ rr:parentTriplesMap
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableNameā€Person" ];
rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person ];
rr:predicateObjectMap [
rr:predicate
foaf:based_near ;
rr:objectMap
[
rr:parentTripelMap <TripleMap2>;
rr:joinCondition [
rr:child ā€œCIDā€;
rr:parent ā€œCIDā€;
]
]
]
.

Parent TriplesMap
JoinCondition
ā€¢ Join between child and parent attribuets
ā€¢ rr:joinCondition
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableNameā€Person" ];
rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person ];
rr:predicateObjectMap [
rr:predicate
foaf:based_near ;
rr:objectMap
[
rr:parentTripelMap <TripleMap2>;
rr:joinCondition [
rr:child ā€œCIDā€;
rr:parent ā€œCIDā€;
]
]
]
.

JoinCondition
<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableNameā€Person" ];
rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}";
rr:class foaf:Person ];
rr:predicateObjectMap [
rr:predicate
foaf:based_near ;
rr:objectMap
[
rr:parentTripelMap <TripleMap2>;
rr:joinCondition [
rr:child ā€œCIDā€;
rr:parent ā€œCIDā€;
]
]
<TriplesMap2>
]
a rr:TriplesMap;
.
rr:logicalTable [ rr:tableName ā€City" ];

RefObjectMap
Parent TriplesMap
JoinCondition

rr:subjectMap [ rr:template "http://ex.com/City/{CID}";
rr:class ex:City ];
rr:predicateObjectMap [
rr:predicate
foaf:name;
rr:objectMap
[ rr:column ā€TITLE" ]
]
.

174
JoinCondition
ā€¢ Child Column which must
be the column name that
exists in the logical table
of the TriplesMap that
contains the
RefObjectMap
ā€¢ Parent Column which
must be the column name
that exists in the logical
table of the
RefObjectMapā€™s Parent
TriplesMap.

<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableNameā€Person" ];
...
rr:predicateObjectMap [
rr:predicate foaf:based_near ;
rr:objectMap [
rr:parentTripelMap <TripleMap2>;
rr:joinCondition [
rr:child ā€œCIDā€;
rr:parent ā€œCIDā€;]
]
].

<TriplesMap2>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€City" ];
...
.
JoinCondition
ā€¢ Child Query
ā€“ The Child Query of a
RefObjectMap is the
LogicalTable of the
TriplesMap containing the
RefObjectMap

ā€¢ Parent Query
ā€“ The ParentQuery of a
RefObjectMap is the
LogicalTable of the Parent
TriplesMap

ā€¢ If the ChildQuery and
ParentQuery are not
identical, then a
JoinCondition must exist

<TriplesMap1>
a rr:TriplesMap;
rr:logicalTable [ rr:tableNameā€Person" ];
...
rr:predicateObjectMap [
rr:predicate foaf:based_near ;
rr:objectMap [
rr:parentTripelMap <TripleMap2>;
rr:joinCondition [
rr:child ā€œCIDā€;
rr:parent ā€œCIDā€;]
]
].

<TriplesMap2>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€City" ];
...
.
Example 7
Student
sid name

pid

1

Juan

100

2

Martin 200
Professor
pid

name

100 Dan
200 Marcelo

R2RML Mapping
ex:Student1 rdf:type ex:Student .
ex:Student2 rdf:type ex:Student .
ex:Professor100 rdf:type ex:Professor .
ex:Professor200 rdf:type ex:Professor .
ex:Student1 ex:hasAdvisor ex:Professor100 .
ex:Student2 ex:hasAdvisor ex:Professor200
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix ex: <http://example.com/ns/>.
<#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
];
rr:predicateObjectMap [
rr:predicate ex:hasAdvisor;
RefObjectMap
rr:objectMap [
rr:parentTriplesMap <#TriplesMap2>;
Parent TriplesMap
rr:joinCondition [
rr:child ā€œpidā€;
JoinCondition
rr:parent ā€œpidā€;
]
]
<#TriplesMap2>
].
rr:logicalTable [ rr:tableName ā€Professorā€];
rr:subjectMap [
rr:template "http://example.com/ns/{pid}";
rr:class ex:Professor;
].
Summary
Languages
ā€¢ TermMap with a TermType of rr:Literal may
have a language tag
ā€¢ rr:language <#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
];
rr:predicateObjectMap [
rr:predicate ex:comment;
rr:objectMap [
rr:column ā€œcommentā€;
rr:language ā€œenā€;
];
].
Student

sid

name

comment

1

Juan

Excellent Student

2

Martin

Wonderful student

@prefix ex: <http://example.com/ns/>.
ex:Student1 rdf:type ex:Student .
ex:Student1 ex:comment ā€œExcellent Studentā€@en .
ex:Student2 rdf:type ex:Student .
ex:Student2 ex:comment ā€œWonderful Studentā€@en .
Issue with Languages
ā€¢ What happens if language value is in the data?
ID

COUNTRY_ID

LABEL

LANG

1

1

United States

en

2

1

Estados Unidos

es

3

2

England

en

4

2

Inglaterra

es
ID

COUNTRY_ID

LABEL

LANG

1

1

United States

en

2

1

Estados Unidos

es

3

2

England

en

4

2

Inglaterra

es

?
@prefix ex: <http://example.com/ns/>.
ex:country1 rdfs:label ā€œUnited Statesā€@en .
ex:country1 rdfs:label ā€œEstados Unidosā€@es .
ex:country2 rdfs:label ā€œEnglandā€@en .
ex:country2 rdfs:label ā€œInglaterraā€@es .
Issue with Languages
ā€¢ Mapping for each language
<#TripleMap_Countries_EN>
a rr:TriplesMap;
rr:logicalTable [ rr:sqlQuery """SELECT COUNTRY_ID, LABEL, LANG, FROM
COUNTRY WHERE LANG = ā€™en'""" ];
rr:subjectMap [
rr:template "http://example.com/country{COUNTRY_ID}"
];
rr:predicateObjectMap [
rr:predicate rdfs:label;
rr:objectMap [
rr:column ā€œLABELā€;
rr:language ā€œenā€;
];
].
Language Extension
ā€¢ Single mapping for all languages
<#TripleMap_Countries_EN>
a rr:TriplesMap;
rr:logicalTable [ rr:tableName ā€COUNTRY" ];
rr:subjectMap [
rr:template "http://example.com/country{COUNTRY_ID}"
];
rr:predicateObjectMap [
rr:predicate rdfs:label;
rr:objectMap [
rr:column ā€œLABELā€;
rrx:languageColumn ā€œLANGā€;
];
].

Column Value as Language
Datatypes
ā€¢ TermMap with a TermType of rr:Literal
ā€¢ TermMap does not have rr:language
<#TriplesMap1>
rr:logicalTable [ rr:tableName ā€Studentā€];
rr:subjectMap [
rr:template "http://example.com/ns/{sid}";
rr:class ex:Student;
];
rr:predicateObjectMap [
rr:predicate ex:startDate;
rr:objectMap [
rr:column ā€œstart_dateā€;
rr:datatype xsd:date;
];
].
Summary of Terminology
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢

R2RML Mapping
Logical Table
Input Database
R2RML View
TriplesMap
Logical Table Row
TermMap
TermType
SubjectMap
PredicateObjectMap
PredicateMap
ObjectMap

ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢
ā€¢

Constant-valued TermMap
Column-valued TermMap
Template-valued TermMap
RefObjectMap
JoinConditions
ChildQuery
ParentQuery
Language
Datatype
Questions?
Next: ETL and Musicbrainz
RDB2RDF Tutorial
ETL and Musicbrainz

Juan F. Sequeda
Daniel P. Miranker

Barry Norton
Context
RDF
Data Management

Relational Database to RDF
(RDB2RDF)

Wrapper
Systems

Extract-Transform-Load
(ETL)

Native
Triplestores

Triplestores

RDBMS-backed
NoSQL
Triplestores
Triplestores
191
Extract ā€“ Transform ā€“ Load (ETL)

SPARQL

Relational
Database

RDB2RDF
Dump

Triplestore
Analysis &
Mining Module

Visualization
Module

RDFa

Data acquisition

LD Dataset

Access

Application

EUCLID Scenario

SPARQL
Endpoint
Publishing
Vocabulary
Mapping

Interlinking

Physical Wrapper

Integrated
Dataset

Cleansing

LD Wrapper

R2R Transf.

LD Wrapper

RDF/
XML
Streaming providers

Downloads

Musical Content

Metadata

Other content
193
W3C RDB2RDF

Data acquisition

LD Dataset

Access

SPARQL
Endpoint

Publishing

Integrated
Data in
Triplestore

Vocabulary
Mapping

ā€¢ Task: Integrate data from
relational DBMS with
Linked Data

Interlinking

ā€¢ Approach: map from
relational schema to
semantic vocabulary with
R2RML

R2RML
Engine

Cleansing

ā€¢ Publishing: two
alternatives ā€“
ā€“ Translate SPARQL into SQL
on the fly
ā€“ Batch transform data into
RDF, index and provide
SPARQL access in a
triplestore

Relational
DBMS

RDB2RDF

194
MusicBrainz Next Gen Schema
ā€¢ artist
As pre-NGS, but
further attributes

ā€¢ artist_credit
Allows joint credit

ā€¢ release_group
Cf. ā€˜albumā€™
versus:

ā€¢ work
ā€¢ release ā€¢ track
ā€¢ medium ā€¢ tracklist ā€¢ recording
https://wiki.musicbrainz.org/Next_Generation_Schema
RDB2RDF

195
Music Ontology
ā€¢ MusicArtist
ā€“ ArtistEvent, member_of

ā€¢ SignalGroup
ā€˜Albumā€™ as per Release_Group

ā€¢ Release
ā€“ ReleaseEvent

ā€¢
ā€¢
ā€¢
ā€¢

Record
Track
Work
Composition

http://musicontology.com/
RDB2RDF

196
Scale
ā€¢ MusicBrainz RDF derived via R2RML:

300M
Triples

lb:artist_member a rr:TriplesMap ;
rr:logicalTable [rr:sqlQuery
"""SELECT a1.gid, a2.gid AS band
FROM artist a1
INNER JOIN l_artist_artist ON a1.id =
l_artist_artist.entity0
INNER JOIN link ON l_artist_artist.link = link.id
INNER JOIN link_type ON link_type = link_type.id
INNER JOIN artist a2 on l_artist_artist.entity1 = a2.id
WHERE link_type.gid='5be4c609-9afa-4ea0-910b-12ffb71e3821'"""]
;
rr:subjectMap [rr:template "http://musicbrainz.org/artist/{gid}#_"]
;
rr:predicateObjectMap
[rr:predicate mo:member_of ;
rr:objectMap [rr:template
"http://musicbrainz.org/artist/{band}#_" ;
rr:termType rr:IRI]] .

197
Musicbrainz
ā€¢ Musicbrainz Dumps:
ā€“ http://mbsandbox.org/~barry/

ā€¢ Musicbrainz R2RML Mappings
ā€“ https://github.com/LinkedBrainz/MusicBrainz-R2RML

ā€¢ 30 mins to generate 150M triples with Ultrawrap
ā€“ 8 Xeon cores, 16 GB Ram (2GB are usually free)
ā€“ Should be less but server was overloaded
ā€“ It use to be 8+ hours using D2RQ on a dedicated
machine
Musicbrainz Dump Statistics
(Lead) Table
area
artist
dbpedia
label
medium
recording
release_group
release
track
work

Triples
59798
36868228
172017
201832
18069143
11400354
3050818
9764887
75506495
1728955
156822527

Time (s)
2
423
13
3
163
209
31
151
794
20
1809
R2RML Class Mapping
ā€¢ Mapping tables to classes is ā€˜easyā€™:
lb:Artist a rr:TriplesMap ;
rr:logicalTable [rr:tableName "artist"] ;
rr:subjectMap
[rr:class mo:MusicArtist ;
rr:template
"http://musicbrainz.org/artist/{gid}#_"] ;
rr:predicateObjectMap
[rr:predicate mo:musicbrainz_guid ;
rr:objectMap [rr:column "gid" ;
rr:datatype xsd:string]] .

RDB2RDF

200
R2RML Property Mapping
ā€¢ Mapping columns to properties can be easy:
lb:artist_name a rr:TriplesMap ;
rr:logicalTable [rr:sqlQuery
"""SELECT artist.gid, artist_name.name
FROM artist
INNER JOIN artist_name ON artist.name =
artist_name.id"""] ;
rr:subjectMap [rr:template
"http://musicbrainz.org/artist/{gid}#_"] ;
rr:predicateObjectMap
[rr:predicate foaf:name ;
rr:objectMap [rr:column "name"]] .

RDB2RDF

201
NGS Advanced Relations
ā€¢ Major entities (Artist, Release Group, Track, etc.) plus
URL are paired
(l_artist_artist)
ā€¢ Each pairing
of instances
refers to a Link
ā€¢ Links have types
(cf. RDF properties)
and attributes

http://wiki.musicbrainz.org/Advanced_Relationship
RDB2RDF

202
Advanced Relations Mapping
ā€¢ Mapping advanced relationships (SQL joins):
lb:artist_member a rr:TriplesMap ;
rr:logicalTable [rr:sqlQuery
"""SELECT a1.gid, a2.gid AS band
FROM artist a1
INNER JOIN l_artist_artist ON a1.id = l_artist_artist.entity0
INNER JOIN link ON l_artist_artist.link = link.id
INNER JOIN link_type ON link_type = link_type.id
INNER JOIN artist a2 on l_artist_artist.entity1 = a2.id
WHERE link_type.gid='5be4c609-9afa-4ea0-910b-12ffb71e3821'"""] ;
rr:subjectMap [rr:template "http://musicbrainz.org/artist/{gid}#_"] ;
rr:predicateObjectMap
[rr:predicate mo:member_of ;
rr:objectMap [rr:template "http://musicbrainz.org/artist/{band}#_" ;
rr:termType rr:IRI]] .

RDB2RDF

203
Advanced Relations Mapping
ā€¢ Mapping advanced relationships (SQL joins):
lb:artist_dbpedia a rr:TriplesMap ;
rr:logicalTable [rr:sqlQuery
"""SELECT artist.gid,
REPLACE(REPLACE(url, 'wikipedia.org/wiki',
'dbpedia.org/resource'),
'http://en.',
'http://')
AS url
FROM artist
INNER JOIN l_artist_url ON artist.id = l_artist_url.entity0
INNER JOIN link ON l_artist_url.link = link.id
INNER JOIN link_type ON link_type = link_type.id
INNER JOIN url on l_artist_url.entity1 = url.id
WHERE link_type.gid='29651736-fa6d-48e4-aadc-a557c6add1cb'
AND url SIMILAR TO
'http://(de|el|en|es|ko|pl|pt).wikipedia.org/wiki/%'"""] ;
rr:subjectMap lb:sm_artist ;
rr:predicateObjectMap
[rr:predicate owl:sameAs ;
rr:objectMap [rr:column "url"; rr:termType rr:IRI]] .
RDB2RDF

204
SPARQL Example
ā€¢ SPARQL versus SQL
ASK {dbp:Paul_McCartney mo:member dbp:The_Beatles}
SELECT ā€¦
INNER
INNER
INNER
INNER
INNER
INNER
INNER
INNER
INNER
INNER
INNER
INNER
WHERE

JOIN
JOIN
JOIN
JOIN
JOIN
JOIN
JOIN
JOIN
JOIN
JOIN
JOIN
JOIN
AND ā€¦ AND ā€¦ AND ā€¦ AND ā€¦

RDB2RDF

205
For exercises, quiz and further material visit our website:

http://www.euclid-project.eu

Course

eBook

Other channels:

@euclid_project

EUCLID project

EUCLIDproject
206
Questions?
Next: Wrappers
RDB2RDF Tutorial
Wrappers

Juan F. Sequeda
Daniel P. Miranker

Barry Norton
Context
RDF
Data Management

Relational Database to RDF
(RDB2RDF)

Wrapper
Systems

Extract-Transform-Load
(ETL)

Native
Triplestores

Triplestores

RDBMS-backed
NoSQL
Triplestores
Triplestores
209
Wrapper Systems
SQL

Relational
Database

SPARQL
RDB2RDF
Mapping

SQL
Results

RDF

SPARQL/RDF
Results
210
ā€œComparing the overall performance [ā€¦] of
the fastest rewriter with the fastest
relational database shows an overhead for
query rewriting of 106%. This is an indicator
that there is still room for improving the
rewriting algorithmsā€
[Bizer and Schultz 2009]
Results of BSBM 2009

Larger numbers are better
http://wifo5-03.informatik.uni-mannheim.de/bizer/berlinsparqlbenchmark/results/index.html
Results of BSBM 2009
100M Triple Dataset

Larger numbers are better

After March 2009, RDB2RDF systems have not
been compared to RDBMS
http://wifo5-03.informatik.uni-mannheim.de/bizer/berlinsparqlbenchmark/results/index.html
Current rdb2rdf systems are not capable of
providing the query execution performance
required [...] it is likely that with more work
on query translation, suitable mechanisms
for translating queries could be developed.
These mechanisms should focus on
exploiting the underlying database systemā€™s
capabilities to optimize queries and process
large quantities of structure data
[Gray et al. 2009]
Why is this happening if ā€¦
ā€œSPARQL is equivalent, from an
expressive point of you, to relational
algebraā€
Angles & Gutierrez 2008
Problem
ā€¢ How can SPARQL queries be efficiently
evaluated on a RDBMS?
ā€¢ Hypothesis: Existing commercial relational
database already subsume optimizations for
effective SPARQL execution on relationally
stored data

219
Nugget
1. Defined architecture based on SQL Views
which allows RDBMS to do the optimization.
2. Identified two important optimizations that
already exist in commercial RDBMS.

Sequeda & Miranker. Ultrawrap: SPARQL Execution on Relational Data. Journal Web Semantics 2013
220
Ultrawrap
Compile Time
1. Translate SQL Schema
to OWL and Mapping
2. Define RDF Triples,
as a View

Run Time
3. SPARQL to SQL
translation
4. SQL Optimizer
creates relational
query plan

221
Creating Tripleview
ā€¢ For every ontology element (Class, Object
Property and Datatype property), create a SQL
SELECT query that outputs triples
SELECT 'Productā€™+ptID as s, ā€˜labelā€™ as p, label as o
FROM Product WHERE label IS NOT NULL
Product
ptID label

prID

S

P

O

1

ACME Inc 4

Product1 label

ACME Inc

2

Foo Bars

Product2 label

Foo Bars

5

222
Creating Tripleview

SELECT ā€˜Productā€™+ptID as s, prID as s_id, ā€˜labelā€™ as p, label as o, NULL as o_id
FROM Product WHERE label IS NOT NULL
Product
ptID label

prID

S

S_id

P

O

O_id

1

ACME Inc 4

Product1

1

label

ACME Inc

NULL

2

Foo Bars

Product2

2

label

Foo Bars

NULL

5

223
Class RDF Triples
SELECT ā€˜Productā€™+ptID as s, prID as s_id, ā€˜rdf:typeā€™ as p, ā€˜Productā€™ as o, NULL as o_id
FROM Product
S

S_id

P

O

O_id

Product1

1

rdf:type

Product

NULL

Product2

2

rdf:type

Product

NULL

Object Property RDF Triples
SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜Product#Producerā€™ as p, ā€˜Producerā€™+prID as o,
prID as o_id FROM Product

S

S_id

P

O

O_id

Product1

1

Product#Producer

Producer4

4

Product2

2

Product#Producer

Producer5

5
Creating Tripleview (ā€¦)
ā€¢ Create TripleViews (SQL View), which are
unions of the SQL SELECT query that have the
same datatype
CREATE VIEW Tripleview_varchar AS
SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜labelā€™ as p, label as o, NULL as o_id FROM Product
UNION ALL
SELECT ā€˜Producerā€™+prID as s, prID as s_id, ā€˜titleā€™ as p, title as o, NULL as o_id FROM Producer
UNION ALL ā€¦
S

S_id

P

O

O_id

Product1

1

label

ACME Inc

NULL

Product2

2

label

Foo Bars

NULL

Producer4

4

title

Foo

NULL

Producer5

5

Ttitle

Bars

NULL

225
CREATE VIEW Tripleview_int AS
SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜pnum1ā€™ as p, pnum1 as o, NULL as o_id
FROM Product
UNION ALL
SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜pnum2ā€™ as p, pnum2 as o, NULL as o_id
FROM Product

S

S_id

P

O

O_id

Product1

1

pnum1

1

NULL

Product2

2

pnum1

3

NULL

Product1

1

pnum2

2

NULL

Product2

2

pnum2

3

NULL
SPARQL and SQL
ā€¢ Translating a SPARQL query to a semantically
equivalent SQL query
SELECT ?label ?pnum1
WHERE{
?x label ?label.
?x pnum1 ?pnum1.
}

SQL on Tripleview

ļƒ 

SELECT label, pnum1
FROM product
What is
the
Query
Plan?

SELECT t1.o AS label, t2.o AS pnum1
FROM tripleview_varchar t1, tripleview_int t2
WHERE t1.p = 'label' AND
t2.p = 'pnum1' AND
t1.s_id = t2.s_id

227
Ļ€ t1.o AS label, t2.o AS pnum1

Ļƒp = ā€˜labelā€™
Tripleview_varchar t1

Ļƒp = ā€˜pnum1ā€™
Tripleview_int t2

CONTRADICTION
CONTRADICTION

U

U

Ļ€ Product+ā€™idā€™ AS s , ā€˜pnum2ā€™ AS p, pnum2 AS o

Ļ€ Product+ā€™idā€™ AS s , ā€˜pnum1ā€™ AS p, pnum1 AS o
Ļ€ Producer+ā€™idā€™ AS s , ā€˜titleā€™ AS p, title AS o
Ļƒpnum2 ā‰  NULL
Ļ€ Product+ā€™idā€™ AS s , ā€˜labelā€™ AS p, label AS o
Ļƒpnum1 ā‰  NULL
Ļƒtitle ā‰  NULL
Product
Ļƒlabel ā‰  NULL
Product
Product

Producer

228
Detection of Unsatisfiable Conditions
ā€¢ Determine that the query result will be empty
if the existence of another answer would
violate some integrity constraint in the
database.
ā€¢ This would imply that the answer to the query
is null and therefore the database does not
need to be accessed
Chakravarthy, Grant and Minker. (1990) Logic-Based Approach to Semantic Query Optimization.
229
Ļ€ t1.o AS label, t2.o AS pnum1

Ļ€ Product+ā€™idā€™ AS s , ā€˜labelā€™ AS p, label AS o

Ļ€ Product+ā€™idā€™ AS s , ā€˜pnum1ā€™ AS p, pnum1 AS o

Ļƒlabel ā‰  NULL

Ļƒpnum1 ā‰  NULL

Product

Product

Join on the same table? ļƒ  REDUNDANT

230
Self Join Elimination
ā€¢ If attributes from the same table are projected
separately and then joined, then the join can
be dropped
Self Join Elimination of Projection
SELECT p1.label, p2.pnum1
FROM product p1, product p2
WHERE
p1.id = 1 and
p1.id = p2.id

SELECT label, pnum1
FROM product
WHERE
id = 1

Self Join Elimination of Selection
SELECT p1.id
FROM product p1, product p2
WHERE
p1.pnum1 >100 and
p2.pnum2 < 500 and
p1.id = p2.id

SELECT id
FROM product
WHERE
pnum1 > 100 and
pnum2 < 500

231
Ļ€ label, pnum1
Ļƒlabel ā‰  NULL AND pnum1 ā‰  NULL
Product

232
Evaluation
ā€¢ Use Benchmarks that stores data in relational
databases, provides SPARQL queries and their
semantically equivalent SQL queries
ā€¢ BSBM - 100 Million Triples
ā€¢ Barton ā€“ 45 million triples
Detection of
Unsatisfiable
Conditions
MYSQL
MSSQL

ORACLE
DB2

Self
Join
Elimination

āœ–
āœ”
āœ–
āœ”

āœ–
āœ–
āœ”
āœ”
234
Ultrawrap Experiment
Augmented Ultrawrap Experiment
ā€¢ Implemented DoUC
ā€“ Hash predicate to SQL query
ā€“ Few LOC
SPARQL as Fast as SQL

Berlin Benchmark on 100 Million Triples on Oracle 11g using
Ultrawrap
237
Discussion
ā€¢ Self join elimination
ā€¢ Push Selects and Join Predicates
ā€¢ Join Ordering

ā€¢ Left Outer Join
Questions?
Next: Hands-On

More Related Content

What's hot

Apache spark ģ†Œź°œ ė° ģ‹¤ģŠµ
Apache spark ģ†Œź°œ ė° ģ‹¤ģŠµApache spark ģ†Œź°œ ė° ģ‹¤ģŠµ
Apache spark ģ†Œź°œ ė° ģ‹¤ģŠµė™ķ˜„ ź°•
Ā 
Introduction to apache spark
Introduction to apache spark Introduction to apache spark
Introduction to apache spark Aakashdata
Ā 
Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...
Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...
Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...Edureka!
Ā 
PySpark dataframe
PySpark dataframePySpark dataframe
PySpark dataframeJaemun Jung
Ā 
Spark overview
Spark overviewSpark overview
Spark overviewLisa Hua
Ā 
Introduction to sqoop
Introduction to sqoopIntroduction to sqoop
Introduction to sqoopUday Vakalapudi
Ā 
Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹
Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹
Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹KnowledgeGraph
Ā 
ć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻ
ć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻ
ć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻKouji Kozaki
Ā 
Hive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep DiveHive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep DiveDataWorks Summit
Ā 
Re-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and SparkRe-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and SparkDatabricks
Ā 
Introducing DataFrames in Spark for Large Scale Data Science
Introducing DataFrames in Spark for Large Scale Data ScienceIntroducing DataFrames in Spark for Large Scale Data Science
Introducing DataFrames in Spark for Large Scale Data ScienceDatabricks
Ā 
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Edureka!
Ā 
Introduction to PySpark
Introduction to PySparkIntroduction to PySpark
Introduction to PySparkRussell Jurney
Ā 
Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)
Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)
Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)Yongho Ha
Ā 
ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLꦂ要
ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLę¦‚č¦ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLꦂ要
ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLꦂ要Kenta Oku
Ā 
Introduction to Apache Sqoop
Introduction to Apache SqoopIntroduction to Apache Sqoop
Introduction to Apache SqoopAvkash Chauhan
Ā 

What's hot (20)

Apache spark ģ†Œź°œ ė° ģ‹¤ģŠµ
Apache spark ģ†Œź°œ ė° ģ‹¤ģŠµApache spark ģ†Œź°œ ė° ģ‹¤ģŠµ
Apache spark ģ†Œź°œ ė° ģ‹¤ģŠµ
Ā 
Introduction to apache spark
Introduction to apache spark Introduction to apache spark
Introduction to apache spark
Ā 
Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...
Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...
Apache Spark Training | Spark Tutorial For Beginners | Apache Spark Certifica...
Ā 
PySpark dataframe
PySpark dataframePySpark dataframe
PySpark dataframe
Ā 
Spark overview
Spark overviewSpark overview
Spark overview
Ā 
Introduction to sqoop
Introduction to sqoopIntroduction to sqoop
Introduction to sqoop
Ā 
RDF Refine恮ä½æć„ę–¹
RDF Refine恮ä½æć„ę–¹RDF Refine恮ä½æć„ę–¹
RDF Refine恮ä½æć„ę–¹
Ā 
Linked Open DataćØćÆ
Linked Open DataćØćÆLinked Open DataćØćÆ
Linked Open DataćØćÆ
Ā 
Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹
Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹
Linked Open Data勉強会2020 前ē·Øļ¼šLOD恮åŸŗē¤Žćƒ»ä½œęˆćƒ»å…¬é–‹
Ā 
ć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻ
ć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻ
ć‚Ŗćƒ¼ćƒ—ćƒ³ćƒ‡ćƒ¼ć‚æ悒LODåŒ–ć™ć‚‹ćƒ‡ćƒ¼ć‚æć‚½ćƒ³ in 高ꧻ
Ā 
Hive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep DiveHive + Tez: A Performance Deep Dive
Hive + Tez: A Performance Deep Dive
Ā 
Re-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and SparkRe-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and Spark
Ā 
Introducing DataFrames in Spark for Large Scale Data Science
Introducing DataFrames in Spark for Large Scale Data ScienceIntroducing DataFrames in Spark for Large Scale Data Science
Introducing DataFrames in Spark for Large Scale Data Science
Ā 
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Ā 
Introduction to PySpark
Introduction to PySparkIntroduction to PySpark
Introduction to PySpark
Ā 
Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)
Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)
Spark ģ˜ ķ•µģ‹¬ģ€ ė¬“ģ—‡ģøź°€? RDD! (RDD paper review)
Ā 
Spark
SparkSpark
Spark
Ā 
ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLꦂ要
ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLę¦‚č¦ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLꦂ要
ćƒ‡ćƒ¼ć‚æćƒ™ćƒ¼ć‚¹02 - SQLꦂ要
Ā 
Internal Hive
Internal HiveInternal Hive
Internal Hive
Ā 
Introduction to Apache Sqoop
Introduction to Apache SqoopIntroduction to Apache Sqoop
Introduction to Apache Sqoop
Ā 

Similar to RDB2RDF Tutorial (R2RML and Direct Mapping) at ISWC 2013

Relational Database to RDF (RDB2RDF)
Relational Database to RDF (RDB2RDF)Relational Database to RDF (RDB2RDF)
Relational Database to RDF (RDB2RDF)EUCLID project
Ā 
Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011Juan Sequeda
Ā 
Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)Sid Anand
Ā 
Querying Linked Data
Querying Linked DataQuerying Linked Data
Querying Linked DataEUCLID project
Ā 
A Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebA Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebShamod Lacoul
Ā 
Incremental Export of Relational Database Contents into RDF Graphs
Incremental Export of Relational Database Contents into RDF GraphsIncremental Export of Relational Database Contents into RDF Graphs
Incremental Export of Relational Database Contents into RDF GraphsNikolaos Konstantinou
Ā 
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014Amazon Web Services
Ā 
SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)andyseaborne
Ā 
Data Integration And Visualization
Data Integration And VisualizationData Integration And Visualization
Data Integration And VisualizationIvan Ermilov
Ā 
MariaDB Platform for hybrid transactional/analytical workloads
MariaDB Platform for hybrid transactional/analytical workloadsMariaDB Platform for hybrid transactional/analytical workloads
MariaDB Platform for hybrid transactional/analytical workloadsMariaDB plc
Ā 
Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02eswcsummerschool
Ā 
Big Data Redis Mongodb Dynamodb Sharding
Big Data Redis Mongodb Dynamodb ShardingBig Data Redis Mongodb Dynamodb Sharding
Big Data Redis Mongodb Dynamodb ShardingAraf Karsh Hamid
Ā 
A hands on overview of the semantic web
A hands on overview of the semantic webA hands on overview of the semantic web
A hands on overview of the semantic webMarakana Inc.
Ā 
Semantic web application architecture
Semantic web   application architectureSemantic web   application architecture
Semantic web application architectureDon Willems
Ā 
Geo Replicated Databases For Disaster Recovery Using CRDT
Geo Replicated Databases For Disaster Recovery Using CRDTGeo Replicated Databases For Disaster Recovery Using CRDT
Geo Replicated Databases For Disaster Recovery Using CRDTRedis Labs
Ā 
Mapping Relational Databases to Linked Data
Mapping Relational Databases to Linked DataMapping Relational Databases to Linked Data
Mapping Relational Databases to Linked DataEUCLID project
Ā 
Sustainable queryable access to Linked Data
Sustainable queryable access to Linked DataSustainable queryable access to Linked Data
Sustainable queryable access to Linked DataRuben Verborgh
Ā 
Practical Cross-Dataset Queries with SPARQL (Introduction)
Practical Cross-Dataset Queries with SPARQL (Introduction)Practical Cross-Dataset Queries with SPARQL (Introduction)
Practical Cross-Dataset Queries with SPARQL (Introduction)Richard Cyganiak
Ā 
GDG Meets U event - Big data & Wikidata - no lies codelab
GDG Meets U event - Big data & Wikidata -  no lies codelabGDG Meets U event - Big data & Wikidata -  no lies codelab
GDG Meets U event - Big data & Wikidata - no lies codelabCAMELIA BOBAN
Ā 

Similar to RDB2RDF Tutorial (R2RML and Direct Mapping) at ISWC 2013 (20)

Relational Database to RDF (RDB2RDF)
Relational Database to RDF (RDB2RDF)Relational Database to RDF (RDB2RDF)
Relational Database to RDF (RDB2RDF)
Ā 
Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011
Ā 
Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)
Ā 
Efficient RDF Interchange (ERI) Format for RDF Data Streams
Efficient RDF Interchange (ERI) Format for RDF Data StreamsEfficient RDF Interchange (ERI) Format for RDF Data Streams
Efficient RDF Interchange (ERI) Format for RDF Data Streams
Ā 
Querying Linked Data
Querying Linked DataQuerying Linked Data
Querying Linked Data
Ā 
A Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebA Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic Web
Ā 
Incremental Export of Relational Database Contents into RDF Graphs
Incremental Export of Relational Database Contents into RDF GraphsIncremental Export of Relational Database Contents into RDF Graphs
Incremental Export of Relational Database Contents into RDF Graphs
Ā 
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
Ā 
SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)
Ā 
Data Integration And Visualization
Data Integration And VisualizationData Integration And Visualization
Data Integration And Visualization
Ā 
MariaDB Platform for hybrid transactional/analytical workloads
MariaDB Platform for hybrid transactional/analytical workloadsMariaDB Platform for hybrid transactional/analytical workloads
MariaDB Platform for hybrid transactional/analytical workloads
Ā 
Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02
Ā 
Big Data Redis Mongodb Dynamodb Sharding
Big Data Redis Mongodb Dynamodb ShardingBig Data Redis Mongodb Dynamodb Sharding
Big Data Redis Mongodb Dynamodb Sharding
Ā 
A hands on overview of the semantic web
A hands on overview of the semantic webA hands on overview of the semantic web
A hands on overview of the semantic web
Ā 
Semantic web application architecture
Semantic web   application architectureSemantic web   application architecture
Semantic web application architecture
Ā 
Geo Replicated Databases For Disaster Recovery Using CRDT
Geo Replicated Databases For Disaster Recovery Using CRDTGeo Replicated Databases For Disaster Recovery Using CRDT
Geo Replicated Databases For Disaster Recovery Using CRDT
Ā 
Mapping Relational Databases to Linked Data
Mapping Relational Databases to Linked DataMapping Relational Databases to Linked Data
Mapping Relational Databases to Linked Data
Ā 
Sustainable queryable access to Linked Data
Sustainable queryable access to Linked DataSustainable queryable access to Linked Data
Sustainable queryable access to Linked Data
Ā 
Practical Cross-Dataset Queries with SPARQL (Introduction)
Practical Cross-Dataset Queries with SPARQL (Introduction)Practical Cross-Dataset Queries with SPARQL (Introduction)
Practical Cross-Dataset Queries with SPARQL (Introduction)
Ā 
GDG Meets U event - Big data & Wikidata - no lies codelab
GDG Meets U event - Big data & Wikidata -  no lies codelabGDG Meets U event - Big data & Wikidata -  no lies codelab
GDG Meets U event - Big data & Wikidata - no lies codelab
Ā 

More from Juan Sequeda

Integrating Semantic Web with the Real World - A Journey between Two Cities ...
Integrating Semantic Web with the Real World  - A Journey between Two Cities ...Integrating Semantic Web with the Real World  - A Journey between Two Cities ...
Integrating Semantic Web with the Real World - A Journey between Two Cities ...Juan Sequeda
Ā 
Integrating Semantic Web in the Real World: A Journey between Two Cities
Integrating Semantic Web in the Real World: A Journey between Two Cities Integrating Semantic Web in the Real World: A Journey between Two Cities
Integrating Semantic Web in the Real World: A Journey between Two Cities Juan Sequeda
Ā 
Integrating Relational Databases with the Semantic Web: A Reflection
Integrating Relational Databases with the Semantic Web: A ReflectionIntegrating Relational Databases with the Semantic Web: A Reflection
Integrating Relational Databases with the Semantic Web: A ReflectionJuan Sequeda
Ā 
Graph Query Languages: update from LDBC
Graph Query Languages: update from LDBCGraph Query Languages: update from LDBC
Graph Query Languages: update from LDBCJuan Sequeda
Ā 
Virtualizing Relational Databases as Graphs: a multi-model approach
Virtualizing Relational Databases as Graphs: a multi-model approachVirtualizing Relational Databases as Graphs: a multi-model approach
Virtualizing Relational Databases as Graphs: a multi-model approachJuan Sequeda
Ā 
Do I need a Graph Database?
Do I need a Graph Database?Do I need a Graph Database?
Do I need a Graph Database?Juan Sequeda
Ā 
Linked Data tutorial at Semtech 2012
Linked Data tutorial at Semtech 2012Linked Data tutorial at Semtech 2012
Linked Data tutorial at Semtech 2012Juan Sequeda
Ā 
WTF is the Semantic Web and Linked Data
WTF is the Semantic Web and Linked DataWTF is the Semantic Web and Linked Data
WTF is the Semantic Web and Linked DataJuan Sequeda
Ā 
WTF is the Semantic Web
WTF is the Semantic WebWTF is the Semantic Web
WTF is the Semantic WebJuan Sequeda
Ā 
Drupal 7 and Semantic Web Hands-on Tutorial
Drupal 7 and Semantic Web Hands-on TutorialDrupal 7 and Semantic Web Hands-on Tutorial
Drupal 7 and Semantic Web Hands-on TutorialJuan Sequeda
Ā 
Free Money (a.k.a Fellowships)
Free Money (a.k.a Fellowships)Free Money (a.k.a Fellowships)
Free Money (a.k.a Fellowships)Juan Sequeda
Ā 
Conclusions - Linked Data
Conclusions - Linked DataConclusions - Linked Data
Conclusions - Linked DataJuan Sequeda
Ā 
Consuming Linked Data 4/5 Semtech2011
Consuming Linked Data 4/5 Semtech2011Consuming Linked Data 4/5 Semtech2011
Consuming Linked Data 4/5 Semtech2011Juan Sequeda
Ā 
Introduction to Linked Data 1/5
Introduction to Linked Data 1/5Introduction to Linked Data 1/5
Introduction to Linked Data 1/5Juan Sequeda
Ā 
Welcome to Linked Data 0/5 Semtech2011
Welcome to Linked Data 0/5 Semtech2011Welcome to Linked Data 0/5 Semtech2011
Welcome to Linked Data 0/5 Semtech2011Juan Sequeda
Ā 
Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Juan Sequeda
Ā 
Introduccion a la Web Semantica
Introduccion a la Web SemanticaIntroduccion a la Web Semantica
Introduccion a la Web SemanticaJuan Sequeda
Ā 
What is the Semantic Web
What is the Semantic WebWhat is the Semantic Web
What is the Semantic WebJuan Sequeda
Ā 
Consuming Linked Data SemTech2010
Consuming Linked Data SemTech2010Consuming Linked Data SemTech2010
Consuming Linked Data SemTech2010Juan Sequeda
Ā 
Welcome to Consuming Linked Data tutorial WWW2010
Welcome to Consuming Linked Data tutorial WWW2010Welcome to Consuming Linked Data tutorial WWW2010
Welcome to Consuming Linked Data tutorial WWW2010Juan Sequeda
Ā 

More from Juan Sequeda (20)

Integrating Semantic Web with the Real World - A Journey between Two Cities ...
Integrating Semantic Web with the Real World  - A Journey between Two Cities ...Integrating Semantic Web with the Real World  - A Journey between Two Cities ...
Integrating Semantic Web with the Real World - A Journey between Two Cities ...
Ā 
Integrating Semantic Web in the Real World: A Journey between Two Cities
Integrating Semantic Web in the Real World: A Journey between Two Cities Integrating Semantic Web in the Real World: A Journey between Two Cities
Integrating Semantic Web in the Real World: A Journey between Two Cities
Ā 
Integrating Relational Databases with the Semantic Web: A Reflection
Integrating Relational Databases with the Semantic Web: A ReflectionIntegrating Relational Databases with the Semantic Web: A Reflection
Integrating Relational Databases with the Semantic Web: A Reflection
Ā 
Graph Query Languages: update from LDBC
Graph Query Languages: update from LDBCGraph Query Languages: update from LDBC
Graph Query Languages: update from LDBC
Ā 
Virtualizing Relational Databases as Graphs: a multi-model approach
Virtualizing Relational Databases as Graphs: a multi-model approachVirtualizing Relational Databases as Graphs: a multi-model approach
Virtualizing Relational Databases as Graphs: a multi-model approach
Ā 
Do I need a Graph Database?
Do I need a Graph Database?Do I need a Graph Database?
Do I need a Graph Database?
Ā 
Linked Data tutorial at Semtech 2012
Linked Data tutorial at Semtech 2012Linked Data tutorial at Semtech 2012
Linked Data tutorial at Semtech 2012
Ā 
WTF is the Semantic Web and Linked Data
WTF is the Semantic Web and Linked DataWTF is the Semantic Web and Linked Data
WTF is the Semantic Web and Linked Data
Ā 
WTF is the Semantic Web
WTF is the Semantic WebWTF is the Semantic Web
WTF is the Semantic Web
Ā 
Drupal 7 and Semantic Web Hands-on Tutorial
Drupal 7 and Semantic Web Hands-on TutorialDrupal 7 and Semantic Web Hands-on Tutorial
Drupal 7 and Semantic Web Hands-on Tutorial
Ā 
Free Money (a.k.a Fellowships)
Free Money (a.k.a Fellowships)Free Money (a.k.a Fellowships)
Free Money (a.k.a Fellowships)
Ā 
Conclusions - Linked Data
Conclusions - Linked DataConclusions - Linked Data
Conclusions - Linked Data
Ā 
Consuming Linked Data 4/5 Semtech2011
Consuming Linked Data 4/5 Semtech2011Consuming Linked Data 4/5 Semtech2011
Consuming Linked Data 4/5 Semtech2011
Ā 
Introduction to Linked Data 1/5
Introduction to Linked Data 1/5Introduction to Linked Data 1/5
Introduction to Linked Data 1/5
Ā 
Welcome to Linked Data 0/5 Semtech2011
Welcome to Linked Data 0/5 Semtech2011Welcome to Linked Data 0/5 Semtech2011
Welcome to Linked Data 0/5 Semtech2011
Ā 
Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011
Ā 
Introduccion a la Web Semantica
Introduccion a la Web SemanticaIntroduccion a la Web Semantica
Introduccion a la Web Semantica
Ā 
What is the Semantic Web
What is the Semantic WebWhat is the Semantic Web
What is the Semantic Web
Ā 
Consuming Linked Data SemTech2010
Consuming Linked Data SemTech2010Consuming Linked Data SemTech2010
Consuming Linked Data SemTech2010
Ā 
Welcome to Consuming Linked Data tutorial WWW2010
Welcome to Consuming Linked Data tutorial WWW2010Welcome to Consuming Linked Data tutorial WWW2010
Welcome to Consuming Linked Data tutorial WWW2010
Ā 

Recently uploaded

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervƩ Boutemy
Ā 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
Ā 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
Ā 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
Ā 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
Ā 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
Ā 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
Ā 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
Ā 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
Ā 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
Ā 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
Ā 
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Patryk Bandurski
Ā 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
Ā 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
Ā 
Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)
Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)
Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)Wonjun Hwang
Ā 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
Ā 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
Ā 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
Ā 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
Ā 

Recently uploaded (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
Ā 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
Ā 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Ā 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Ā 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
Ā 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Ā 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
Ā 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
Ā 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
Ā 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
Ā 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
Ā 
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Ā 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
Ā 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
Ā 
Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)
Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)
Bun (KitWorks Team Study ė…øė³„ė§ˆė£Ø ė°œķ‘œ 2024.4.22)
Ā 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
Ā 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
Ā 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
Ā 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
Ā 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
Ā 

RDB2RDF Tutorial (R2RML and Direct Mapping) at ISWC 2013

  • 1. Relational Database to RDF (RDB2RDF) Tutorial International Semantic Web Conference ISWC2013 Juan F. Sequeda Daniel P. Miranker Barry Norton
  • 2. RDB2RDF Tutorial Introduction Juan F. Sequeda Daniel P. Miranker Barry Norton
  • 3. What is RDB2RDF? Alice Person ID NAME AGE CID 1 Alice 25 100 2 Bob NULL 100 foaf:name 25 Alice foaf:age <Person/1> foaf:name <Person/2> foaf:based_near City CID NAME 100 Austin 200 Madrid <City/100> <City/200> www.rdb2rdf.org - ISWC2013 foaf:name foaf:name Austin Madrid
  • 4. Context RDF Data Management Relational Database to RDF (RDB2RDF) Wrapper Systems Extract-Transform-Load (ETL) Native Triplestores www.rdb2rdf.org - ISWC2013 Triplestores RDBMS-backed NoSQL Triplestores Triplestores
  • 5. Outline ā€¢ Historical Overview ā€¢ 4 Scenarios ā€¢ Overview W3C RDB2RDF Standards ā€“ Direct Mapping ā€“ R2RML www.rdb2rdf.org - ISWC2013
  • 9. F2F Meeting ISWC 2008 March 2008 1. Recommendation to standardize a mapping language 2. RDB2RDF Survey October 2008 February 2009 (1) http://www.w3.org/2005/Incubator/rdb2rdf/XGR-rdb2rdf-20090126/ (2) http://www.w3.org/2005/Incubator/rdb2rdf/RDB2RDF_SurveyReport.pdf www.rdb2rdf.org - ISWC2013
  • 11. WD R2RML+DM FPWD DM FPWD R2RML 250 WD R2RML+DM Candidate Rec R2RML + DM Proposed Rec R2RML + DM WD R2RML + DM 200 150 100 50 First F2F @Semtech 2010 www.rdb2rdf.org - ISWC2013 Photo from cygri http://www.flickr.com/photos/cygri/4719458268/ Oct-12 Sep-12 Aug-12 Jul-12 Jun-12 May-12 Apr-12 Mar-12 Feb-12 Jan-12 Dec-11 Nov-11 Oct-11 Sep-11 Aug-11 Jul-11 Jun-11 May-11 Apr-11 Mar-11 Feb-11 Jan-11 Dec-10 Nov-10 Oct-10 Sep-10 Aug-10 Jul-10 Jun-10 May-10 Apr-10 Mar-10 Feb-10 Jan-10 Dec-09 Nov-09 Oct-09 Sep-09 0 Rec R2RML + DM
  • 12. Statistics ā€¢ 206 Actions ā€¢ 78 Issues ā€“ 61 Closed ā€“ 17 Postponed ā€¢ public-rdb2rdf-wg ā€“ 3393 emails (Sept 2009 ā€“ Oct 2012) ā€¢ public-rdb2rdf-comments ā€“ 200 emails (Sept 2009 ā€“ March 2013) www.rdb2rdf.org - ISWC2013
  • 13. Outline ā€¢ Historical Overview ā€¢ 4 Scenarios ā€¢ Overview W3C RDB2RDF Standards ā€“ Direct Mapping ā€“ R2RML www.rdb2rdf.org - ISWC2013
  • 14. How to include relational data in a semantic application? ā€¢ Many architectural design choices. ā€¢ Technology Development Fluid. ā€¢ No established ā€œbest-of-breedā€ solā€™n. www.rdb2rdf.org - ISWC2013
  • 15. Feature Space of Design Choices ā€¢ Scope of the application ā€“ Mash-up topic page ā€“ Heterogeneous Enterprise Data Application ā€¢ Size of the (native) database ā€“ Data Model ā€“ Contents ā€¢ Size of the useful (in application) database ā€“ Data Model ā€“ Contents ā€¢ When to translate the data? ā€“ Wrapper ā€“ ETL www.rdb2rdf.org - ISWC2013
  • 16. Reduction to 4 Scenarioā€™s www.rdb2rdf.org - ISWC2013
  • 17. Scenario 1: Direct Mapping Suppose: ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions ā€“ Database is static. ā€“ Herbs and conditions do not have representation in western medical ontologies. www.rdb2rdf.org - ISWC2013
  • 18. Scenario 1: Direct Mapping Suppose: ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions ā€“ Database is static. ā€“ Herbs and conditions do not have representation in western medical ontologies. SPARQL Relational Database Extract Direct Mapping Engine Triplestore Transform www.rdb2rdf.org - ISWC2013 Load
  • 19. Scenario 1: Direct Mapping Suppose: ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions SPARQL Relational Database Extract Direct Mapping Engine Triplestore Transform Load Then: ā€¢ Existing table and column names are encoded into URIs ā€¢ Data is translated into RDF and loaded into an existing, Internet accessible triplestore. www.rdb2rdf.org - ISWC2013
  • 20. Scenario 2: R2RML Suppose: ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions + Clinical Records ā€“ Database is static. ā€“ Also have, patient names, demographics, outcomes www.rdb2rdf.org - ISWC2013
  • 21. Scenario 2: R2RML Suppose: ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions + Clinical Records Domain Ontologies (e.g FOAF, etc) SPARQL R2RML Mapping Engine R2RML File Extract Triplestore Transform Relational Database www.rdb2rdf.org - ISWC2013 Load
  • 22. Scenario 2: R2RML ā€¢ Database of Chinese Herbal Medicine and Applicable Conditions + Clinical Records Domain Ontologies (e.g FOAF, etc) SPARQL R2RML Mapping Engine R2RML File Extract Triplestore Transform Load Relational Database ā€¢ Then: ā€“ Developer says, ā€œI know FOAF, Iā€™ll write some R2RML and that data will have canonical URIs, and people will be able to use the dataā€. www.rdb2rdf.org - ISWC2013
  • 23. Scenario 4: Automatic Mapping Suppose: ā€¢ ā€¢ ā€¢ ā€¢ Database of Electronic Medical Records Application, integration of all of a hospitals IT systems Database has 100 tables and a total of 7,000 columns Use of existing ontologies as a unifying data model ā€“ ICDE10 codes (> 12,000 concepts) ā€“ SNOMED vocabulary (> 40,000 concepts) www.rdb2rdf.org - ISWC2013
  • 24. Scenario 4: Automatic Mapping Suppose: ā€¢ 7,000 Columns ā€¢ Use of existing ontologies as a unifying data model ā€“ ICDE10 codes (> 12,000 concepts) ā€“ SNOMED vocabulary (> 40,000 concepts) Then: ā€¢ Convert the database schema and data to an ontology. SPARQL ā€¢ Apply ontology alignment program RDF Automatic Mapping Domain Ontologies Source Putative Ontology Refined R2RML Direct Mapping as Ontology RDB2RDF Wrapper Relational Database www.rdb2rdf.org - ISWC2013
  • 25. Scenario 4: Automatic Mapping Suppose: ā€¢ 7,000 Columns ā€¢ Use of existing ontologies as a unifying data model ā€“ ICDE10 codes (> 12,000 concepts) ā€“ SNOMED vocabulary (> 40,000 concepts) Then: ā€¢ A semantic system implements the solution with no human labor SPARQL RDF Automatic Mapping Domain Ontologies Source Putative Ontology Refined R2RML Direct Mapping as Ontology RDB2RDF Wrapper Relational Database www.rdb2rdf.org - ISWC2013
  • 26. Scenario 3: Semi-automatic Mapping Domain Ontologies SemiAutomatic Mapping Refined R2RML Source Putative Ontology Direct Mapping as Ontology SPARQL RDF RDB2RDF Wrapper Relational Database www.rdb2rdf.org - ISWC2013
  • 27. Outline ā€¢ Historical Overview ā€¢ 4 Scenarios ā€¢ Overview W3C RDB2RDF Standards ā€“ Direct Mapping ā€“ R2RML www.rdb2rdf.org - ISWC2013
  • 28. W3C RDB2RDF Standards ā€¢ Standards to map relational data to RDF ā€¢ A Direct Mapping of Relational Data to RDF ā€“ Default automatic mapping of relational data to RDF ā€¢ R2RML: RDB to RDF Mapping Language ā€“ Customizable language to map relational data to RDF www.rdb2rdf.org - ISWC2013
  • 30. Direct Mapping Relational Database Direct Mapping Engine Input: Database (Schema and Data) Primary Keys Foreign Keys www.rdb2rdf.org - ISWC2013 RDF Output RDF graph
  • 31. Direct Mapping Result 25 Alice Person ID NAME <Person#NAME> AGE Alice <Person#AGE> <Person#NAME> CID 1 Alice 25 100 2 Bob NULL 100 City <Person/ID=1> <Person/ID=2> <Person#ref-CID> CID NAME 100 Austin 200 Madrid <Person#ref-CID> <City/CID=100> <City/CID=200> www.rdb2rdf.org - ISWC2013 <Person#NAME> <Person#NAME> Austin Madrid
  • 34. Direct Mapping as R2RML @prefix rr: <http://www.w3.org/ns/r2rml#> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/ID={ID}"; rr:class <http://www.ex.com/Person> ]; rr:predicateObjectMap [ rr:predicate <http://www.ex.com/Person#NAME> ; rr:objectMap [rr:column ā€NAME" ] ]. www.rdb2rdf.org - ISWC2013
  • 35. Customized R2RML @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] www.rdb2rdf.org - ISWC2013 .
  • 36. <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableNameā€Person" ]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:based_near ; rr:objectMap [ rr:parentTripelMap <TripleMap2>; rr:joinCondition [ rr:child ā€œCIDā€; rr:parent ā€œCIDā€; ] ] <TriplesMap2> ] a rr:TriplesMap; . rr:logicalTable [ rr:tableName ā€City" ]; rr:subjectMap [ rr:template "http://ex.com/City/{CID}"; rr:class ex:City ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [ rr:column ā€TITLE" ] ] . www.rdb2rdf.org - ISWC2013
  • 37. R2RML View @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery ā€œā€ā€SELECT ID, NAME FROM Person WHERE gender = ā€œFā€ ā€œā€ā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class <http://www.ex.com/Woman> ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] www.rdb2rdf.org - ISWC2013 .
  • 39. RDB2RDF Tutorial Direct Mapping Juan F. Sequeda Daniel P. Miranker Barry Norton
  • 41. W3C Direct Mapping ā€¢ Input: ā€“ Database (Schema and Data) ā€“ Primary Keys ā€“ Foreign Keys ā€¢ Output ā€“ RDF graph 41
  • 42. What do we need to automatically generate? ā€¢ Generate Identifiers ā€“ IRI ā€“ Blank Nodes ā€¢ Generate Triples ā€“ Table ā€“ Literal ā€“ Reference
  • 43. Generating Identifiers ā€¢ Identifier for rows, tables, columns and foreign keys ā€¢ If a table has a primary key, ā€“ then the row identifier will be an IRI, ā€“ otherwise a blank node ā€¢ The identifiers for table, columns and foreign keys are IRIs ā€¢ IRIs are generated by appending to a given base IRI ā€¢ All strings are percent encoded
  • 44. Row Node Base IRI ā€œTable Nameā€/ā€œPK attrā€=ā€œPK valueā€ 1) <http://www.ex.com/Person/ID=1> Base IRI ā€œTable Nameā€/ā€œPK attrā€=ā€œPK valueā€ 2) <http://www.ex.com/Person/ID=1;SID=123> 3) Fresh Blank Node
  • 45. More IRI Base IRI ā€œTable Nameā€ 1) <http://www.ex.com/Person> Base IRI ā€œTable Nameā€#ā€œAttributeā€ 2) <http://www.ex.com/Person#NAME> Base IRI ā€œTable Nameā€#ref-ā€œAttributeā€ 3) <http://www.ex.com/Person#ref-CID>
  • 49. Direct Mapping Result 25 Alice Person ID NAME <Person#NAME> AGE Alice <Person#AGE> <Person#NAME> CID 1 Alice 25 100 2 Bob NULL 100 City <Person/ID=1> <Person/ID=2> <Person#ref-CID> CID NAME 100 Austin 200 Madrid <Person#ref-CID> <City/CID=100> <City/CID=200> <Person#NAME> <Person#NAME> Austin Madrid 49
  • 50. Summary: Direct Mapping ā€¢ Default and Automatic Mapping ā€¢ URIs are automatically generated ā€“ ā€“ ā€“ ā€“ <table> <table#attribute> <table#ref-attribute> <Table#pkAttr=pkValue> ā€¢ RDF represents the same relational schema ā€¢ RDF can be transformed by SPARQL CONSTRUCT ā€“ RDF represents the structure and ontology of mapping authorā€™s choice 50
  • 51. What else is missing? ā€¢ Relational Schema to OWL is *not* in the W3C standard ā€¢ NULL values ā€¢ Many-to-Many relationships (binary tables) ā€¢ ā€œUglyā€ IRIs 51
  • 52. NULL ā€œThe direct mapping does not generate triples for NULL values. Note that it is not known how to relate the behavior of the obtained RDF graph with the standard SQL semantics of the NULL values of the source RDB.ā€ A Direct Mapping of Relational Data to RDF. W3C Recommendation 52
  • 53. Problem 1. How can a relational database schema and data, be automatically mapped to OWL and RDF? 2. How can we assure correctness of mapping? 53
  • 54. Product ptID label prID 10 ACME Inc 4 11 FooBars String 5 String pt:Producer pt:label ex:Producer ex:Product String rdf:type rdf:type Producer prID title loc 4 Foo 5 Bar pt:label pr:title pt:Producer TX NULL FooBars Input ā€¢ Relational Schema R ā€¢ Set Ī£ of Primary Keys PK and Foreign Keys FK over R ā€¢ Instance I of R ex:Product11 Mapping ex:Producer5 Bar Output ā€¢ RDF graph ā€¢ OWL ontology as a graph We need to be careful about two issues ā€¢ Binary Relations ā€¢ NULLs 54
  • 55. NULLs ā€¢ What should we do with NULLs? ā€“ Generate a Blank Node title loc 4 Bar prID Foo TX 5 Bar NULL ex:Producer5 _:a ā€“ Donā€™t generate a triple pr:title ex:Producer5 Bar How do we reconstruct the NULL? 55
  • 56. Direct Mapping Properties ā€¢ Fundamental Properties ā€“ Information Preserving: no information is lost ā€“ Query Preserving: no query is lost ā€¢ Desirable Properties ā€“ Monotonicity ā€“ Semantics Preserving:
  • 58. Query Preservation Result of Q RDB = Result of Q* Direct Mapping 58
  • 62. The Nugget ā€¢ Defined a Direct Mapping DM ā€¢ Formally defined semantics using Datalog ā€¢ Considered RDBs that may contain NULL values ā€¢ Studied DM wrt 4 properties ā€“ ā€“ ā€“ ā€“ Information Preservation Query Preservation Monotonicity Semantics Preservation Sequeda, Arenas & Miranker. On Directly Mapping Relational Databases to RDF and OWL. WWW 2012 Sequeda et. al. Survey of Directly Mapping SQL Databases to the Semantic Web. J KER 2011 62 Tirmizi, Sequeda & Miranker. Translating SQL Applications to the Semantic Web. DEXA 2008
  • 63. Direct Mapping Input: A relational schema R a set of Ī£ of primary keys and foreign keys and a database instance I of this schema Output: An RDF Graph Definition: A direct mapping M is a total function from the set of all (R, Ī£, I) to the set of all RDF graphs 63
  • 64. The Direct Mapping DM ā€¢ Relational Schema to OWL ā€“ S.H. Tirmizi, J.F. Sequeda and D.P. Miranker. Translating SQL Applications to the Semantic Web. DEXA 2008 ā€¢ Relational Data to RDF ā€“ M. Arenas, A. Bertails, E. Prudā€™hommeaux and J.F. Sequeda. A Direct Mapping of Relational Data to RDF. W3C Recommendation. 27 September 2012 64
  • 65. Direct Mapping RDB to RDF and OWL R, Ī£ I Predicates to store (R, Ī£, I) Datalog Rules to generate O from R, Ī£ Predicates to Store Ontology O Datalog Rules to generate OWL from O Datalog Rules to generate RDF from O and I OWL RDF 65
  • 66. Running Example Consider the following relational schema: ā€“ person(ssn, name, age) : ssn is the primary key ā€“ student(id, degree, ssn) : id is the primary key, ssn is a foreign key to ssn in person Consider the following instance: person student id degree ssn ssn name age 1 Math 789 123 Juan 26 2 EE 456 456 Marcelo 27 3 CS 123 789 Daniel NULL 66
  • 67. Input: Relational Schema student ā€¢ Rel(r) : ā€“ Rel(student) ā€¢ Attr(a, r) : id degree ssn 1 Math 789 2 EE 456 3 CS 123 ā€“ Attr(degree, student) ā€¢ PKn(a1, ā€¦ , an, r) : ā€“ PK1(id, student) ā€¢ FKn(a1, ā€¦ , an, r, b1, ā€¦ , bn, s) : ā€“ FK1(ssn, student, ssn, person) 67
  • 68. Input: Instances student ā€¢ Value(v, a, t, r) ā€“ ā€“ ā€“ ā€“ ā€“ ā€“ ā€“ ā€“ ā€“ Value( 1, id, t1, student) Value( Math, degree, t1, student) Value( 789, ssn, t1, student) Value( 2, id, t2, student) Value( EE, degree, t2, student) Value( 456, ssn, t2, student) Value( 3, id, t3, student) Value( CS, degree, t3, student) Value( 123, ssn, t3, student) id degree ssn 1 Math 789 2 EE 456 3 CS 123 68
  • 69. Mapping to OWL Triple(http://ex.org/person, rdf:type, owl:Class) Triple(U,"rdf:type","owl:Class") ā† Class(R), ClassIRI(R, U) ClassIRI(R, X) ā† Class(R), Concat2(base, R, X) Class(X) ā† Rel(X), Ā¬IsBinRel(X) IsBinRel(X) ā† BinRel(X, A, B, S, C, T, D) BinRel(R, A, B, S, C, T, D) ā† PK2(A, B, R), Ā¬ThreeAttr(R), FK1(A,R,C,S),R =Ģø S, FK1(B,R,D,T),R =Ģø T, Ā¬TwoFK(A, R), Ā¬TwoFK (B, R), Ā¬OneFK(A, B, R), Ā¬FKTo(R) 69
  • 70. Mapping to RDF Table triples: for each relation, store the tuples that belongs to it Triple(http://ex.org/person#ssn=123, rdf:type, http://ex.org/person) 70
  • 71. Mapping to RDF Table triples: for each relation, store the tuples that belongs to it Triple(http://ex.org/person#ssn=123 , rdf:type, http://ex.org/person ) Literal triples: for each tuple, store the values in each of its attributes Triple(http://ex.org/person#ssn=123 , http://ex.org/person#name , ā€œJuanā€) 71
  • 72. Mapping to RDF Reference triples: store the references generated by the FKs Triple(http://ex.org/student#id=3 , http://ex.org/student,person#ssn,ssn , http://ex.org/person#ssn=123 ) 72
  • 73. Mapping to RDF Triple(http://ex.org/person#ssn=123 , http://ex.org/person#name , ā€œJuanā€) Triple(U,V, W) ā† DTP(A,R), Value(W, A, T, R), W != NULL. TupleID(T,R,U), DTP_IRI(A,R,V) DTP_IRI(A, R, X) ā† DTP(A,R) , Concat4(base, R,ā€#ā€, A, X) DTP(A,R) ļƒŸ Attr(A,R), Ā¬IsBinRel(X) TupleID(T, R, X) ļƒŸ Class(R), PKn(A1, ā€¦, An, R), Value(V1, A1, T, R), ā€¦, Value(Vn, An, T, R), RowIRIn(V1, ā€¦, Vn, A1, ā€¦, An, T, R, X) 73
  • 74. Information Preservation M(R, Ī£, I) R, Ī£ I M- (M(R, Ī£, I)) Theorem: The Direct Mapping is information preserving Proof: Provide a computable mapping M74
  • 75. Relational Algebra tuples vs. SPARQL mappings person ssn 789 name Daniel age NULL t.ssn = 789 t.name = Daniel t.age = NULL Then, tr(t) = Ī¼ : ā€¢ Domain of Ī¼ is {?ssn, ?name} ā€¢ Ī¼(?ssn) = 789 ā€¢ Ī¼(?name) = Daniel 75
  • 76. Query Preservation tr(eval(Q, I)) R, Ī£ I = eval(Q*, M(R, Ī£, I)) M(R, Ī£, I) Theorem: The Direct Mapping is query preserving Proof: By induction on the structure of Q Bottom-up algorithm for translating Q into Q* 76
  • 77. Example of Query Preservation Ļ€name, age( Ļƒdegree ā‰  EE (student) person) person student id degree ssn ssn name age 1 CS 789 123 Juan 26 2 EE 456 456 Marcelo 27 3 Math 123 789 Daniel NULL 77
  • 78. Example of Query Preservation Ļ€name, age( Ļƒdegree ā‰  EE (student) person) SELECT ?id ?degree ?ssn WHERE { ?x rdf:type <ā€¦/student>. OPTIONAL{?x <ā€¦/student#id> ?id. } OPTIONAL{?x <ā€¦/student#degree> ?degree. } OPTIONAL{?x <ā€¦/student#ssn> ?ssn. } } student id degree ssn 1 CS 789 2 EE 456 3 Math 123 78
  • 79. Example of Query Preservation Ļ€name, age( Ļƒdegree ā‰  EE (student) person) SELECT ?id ?degree ?ssn WHERE { ?x rdf:type <ā€¦/student>. OPTIONAL{?x <ā€¦/student#id> ?id. } OPTIONAL{?x <ā€¦/student#degree> ?degree. } OPTIONAL{?x <ā€¦/student#ssn> ?ssn. } FILTER(?degree != ā€œEEā€ && bound(?degree) ) } student id degree ssn 1 CS 789 2 EE 456 3 Math 123 79
  • 80. Example of Query Preservation Ļ€name, age( Ļƒdegree ā‰  EE(student) person) SELECT ?ssn ?name ?age WHERE { ?x rdf:type <ā€¦/person>. OPTIONAL{?x <ā€¦/person#ssn> ?ssn. } OPTIONAL{?x <ā€¦/person#name> ?name. } OPTIONAL{?x <ā€¦/person#age > ?age. } } person ssn name age 123 Juan 26 456 Marcelo 27 789 Daniel NULL 80
  • 81. Ļ€name,age( Ļƒdegree ā‰  EE(student) SELECT ?name ?age{ {SELECT ?id ?degree ?ssn WHERE { ?x rdf:type <ā€¦/student>. OPTIONAL{?x <ā€¦/student#id> ?id. } OPTIONAL{?x <ā€¦/student#degree> ?degree. } OPTIONAL{?x <ā€¦/student#ssn> ?ssn. } FILTER(?degree != ā€œEEā€ && bound(?degree) ) FILTER(bound(?ssn)} } {SELECT ?ssn?name ?age WHERE { ?x rdf:type <ā€¦/person>. OPTIONAL{?x <ā€¦/person#ssn> ?ssn. } OPTIONAL{?x <ā€¦/person#name> ?name. } OPTIONAL{?x <ā€¦/person#age > ?age. } FILTER(bound(?ssn)} } } person) 81
  • 82. Monotonicity R, Ī£ I2 I1 M(R, Ī£, I2) I2 M(R, Ī£, I1) R, Ī£ I1 M(R, Ī£, I2) M(R, Ī£, I1) Theorem: The Direct Mapping is monotone Proof: All negative atoms in the Datalog rules refer to the schema, where the schema is fixed. 82
  • 83. Semantics Preservation Consistent under OWL semantics I satisfies Ī£ R, Ī£ I M(R, Ī£, I) Not consistent under OWL semantics I does not satisfies Ī£ R, Ī£ I M(R, Ī£, I) 83
  • 84. DM is not Semantics Preserving person ssn Juan name 123 Juan 123 DM(R, Ī£, I) 123 person#ssn #ssn=123 Marcelo Marcelo ssn is the PK I does not satisfy Ī£ however DM(R, Ī£, I) is consistent under OWL semantics Theorem: No monotone direct mapping is semantics preserving Proof: By contradiction. 84
  • 85. Extending DM for Semantics Preservation ā€¢ Family of Datalog rules to determine violation ā€“ Primary Keys ā€“ Foreign Keys ā€¢ Non-monotone direct mapping ā€¢ Information Preserving ā€¢ Query Preserving ā€¢ Semantics Preserving 85
  • 86. Summary ā€¢ The Direct Mapping DM ā€“ Formally defined semantics using Datalog ā€“ Consider RDBs that may contain NULL values ā€“ Monotone, Information and Query Preserving ā€¢ If you migrate your RDB to the Semantic Web using a monotone direct mapping, be prepared to experience consistency when what one would expect is inconsistency. 86
  • 87. W3C Direct Mapping ā€¢ Only maps Relational Data to RDF ā€“ Does not consider schema ā€¢ Monotone ā€¢ Not Information Preserving ā€“ Because it does not direct map the schema ā€¢ Not Semantics Preserving 87
  • 88. Questions? Next: From Direct Mapping to R2RML
  • 90. DM is not Semantics Preserving PREFIX ex: <http://ex.org/> PREFIX person: <http://ex.org/person#> ex:person rdf:type owl:Class . person:name rdf:type owl:DatatypeProperty ; rdfs:domain ex:person . person:ssn rdf:type owl:DatatypeProperty ; rdfs:domain ex:person . person ssn name 123 Juan 123 DM(R, Ī£, I) Marcelo ssn is the PK Juan 123 person#ssn #ssn=123 Marcelo I does not satisfy Ī£ however DM(R, Ī£, I) is consistent under OWL semantics 90
  • 91. What about owl:hasKey student ā€¢ Student/id=NULL, rdf:type Student ā€¢ Student/id=1, degree, math id degree NULL Math ā€¢ owl:hasKey can not make me have a value 91
  • 92. owl:hasKey student ā€¢ Tuple 1 ā€“ Student/id=1, student#id, 1 ā€“ Student/id=1, degree, math id degree 1 Math 1 EE ā€¢ Tuple 2 ā€“ Student/id=1, student#id, 1 ā€“ Student/id=1, degree, EE ā€¢ DM generate the same IRI Student/id=1 for two different tuples. This does not violate owl:hasKey 92
  • 93. owl:hasKey student ā€¢ Tuple 1 ā€“ Student/id=1, student#id, 1 ā€“ Student/id=1, degree, math id degree 1 Math 1 EE ā€¢ Tuple 2 ā€“ Student/id=1, student#id, 1 ā€“ Student/id=1, degree, EE ā€¢ However, UNA works: ā€“ Student/id=1 differentFrom Student/id=1 ā€¢ However a new DM that generates IRIs based on tuple ids ā€“ Owl:hasKey would work 93
  • 94. Semantics Preserving DMpk ā€¢ Find violation of PK ā€¢ Create artificial triple that will generate contradiction 94
  • 95. Semantics Preserving DMpk+fk ā€¢ Find violation of FK ā€¢ Create artificial triple that will generate contradiction 95
  • 96. RDB2RDF Tutorial From Direct Mapping to R2RML Juan F. Sequeda Daniel P. Miranker Barry Norton
  • 98. W3C R2RML ā€¢ Input ā€“ Database (schema and data) ā€“ Target Ontologies ā€“ Mappings between the Database and Target Ontologies in R2RML ā€¢ Output ā€“ RDF graph 98
  • 100. Direct Mapping as R2RML 25 Alice Person ID NAME <Person#NAME> AGE Alice <Person#AGE> <Person#NAME> CID 1 Alice 25 100 2 Bob NULL 100 City <Person/ID=1> <Person/ID=2> <Person#ref-CID> CID NAME 100 Austin 200 Madrid <Person#ref-CID> How can this be represented as R2RML? <City/CID=100> <City/CID=200> <Person#NAME> <Person#NAME> Austin Madrid 100
  • 101. Direct Mapping as R2RML @prefix rr: <http://www.w3.org/ns/r2rml#> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/ID={ID}"; rr:class <http://www.ex.com/Person> ]; rr:predicateObjectMap [ rr:predicate <http://www.ex.com/Person#NAME> ; rr:objectMap [rr:column ā€NAME" ] ]. 101
  • 102. Direct Mapping as R2RML @prefix rr: <http://www.w3.org/ns/r2rml#> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; mapped? Logical Table: What is being rr:subjectMap [ rr:template "http://www.ex.com/Person/ID={ID}"; SubjectMap: How to generate the Subject? rr:class <http://www.ex.com/Person> ]; rr:predicateObjectMap [ rr:predicate <http://www.ex.com/Person#NAME> ; PredicateObjectMap: ā€NAME" ] rr:objectMap [rr:column How to generate the Predicate and Object? ]. 102
  • 103. Logical Table @prefix rr: <http://www.w3.org/ns/r2rml#> . <TriplesMap1> a rr:TriplesMap; What is being mapped? rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/ID={ID}"; rr:class <http://www.ex.com/Person> ]; rr:predicateObjectMap [ rr:predicate <http://www.ex.com/Person#NAME> ; rr:objectMap [rr:column ā€NAME" ] ] . 103
  • 104. Subject URI Template @prefix rr: <http://www.w3.org/ns/r2rml#> . <TriplesMap1> a rr:TriplesMap; Subject URI rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/ID={ID}"; rr:class <http://www.ex.com/Person> ]; rr:predicateObjectMap [ rr:predicate <http://www.ex.com/Person#NAME> ; rr:objectMap [rr:column ā€NAME" ] ] <Subject URI> rdf:type <Class . URI> 104
  • 105. Predicate URI Constant @prefix rr: <http://www.w3.org/ns/r2rml#> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; Predicate URI rr:subjectMap [ rr:template "http://www.ex.com/Person/ID={ID}"; rr:class <http://www.ex.com/Person> ]; rr:predicateObjectMap [ rr:predicate <http://www.ex.com/Person#NAME> ; rr:objectMap [rr:column ā€NAME" ] ] . 105
  • 106. Object Column Value @prefix rr: <http://www.w3.org/ns/r2rml#> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/ID={ID}"; rr:class <http://www.ex.com/Person> ]; rr:predicateObjectMap [ rr:predicate <http://www.ex.com/Person#NAME> ; rr:objectMap [rr:column ā€NAME" ] ] . Object Literal 106
  • 107. ā€œUglyā€ vs ā€œCoolā€ URIs <http://www.ex.com/Person/ID=1> <http://www.ex.com/Person#NAME> <http://www.ex.com/Person> <http://www.ex.com/Person/1> foaf:name foaf:Person 107
  • 108. Customization @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; Customized Subject URI rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] . Customized Class 108
  • 109. What if ā€¦ Person ID NAME GENDER 1 Alice F 2 Bob M <Woman> rdf:type <Person/1> foaf:name Alice R2RML View SELECT ID, NAME FROM Person WHERE GENDER = "F" 109
  • 110. R2RML View @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; Query instead of table rr:logicalTable [ rr:sqlQuery ā€œā€ā€SELECT ID, NAME FROM Person WHERE gender = ā€œFā€ ā€œā€ā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class <http://www.ex.com/Woman> ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] . 110
  • 111. Quick Overview of R2RML ā€¢ Manual and Customizable Language ā€¢ Learning Curve ā€¢ Direct Mapping bootstraps R2RML ā€¢ RDF represents the structure and ontology of mapping authorā€™s choice 111
  • 113. RDB2RDF Tutorial R2RML Juan F. Sequeda Daniel P. Miranker Barry Norton
  • 114. Outline ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ Logical Tables: What is being mapped Term Maps: How to create RDF terms How to create Triples from a table How to create Triples between two tables Languages Datatypes
  • 115. R2RML Mapping Input Database R2RML Mapping Logical Table Logical Table = base table or view or SQL query R2RML View = SQL Query
  • 116. R2RML Mapping Student sid name pid 1 Juan 100 2 Martin 200 Professor pid name 100 Dan 200 Marcelo R2RML Mapping ex:Student1 rdf:type ex:Student . ex:Student2 rdf:type ex:Student . ex:Professor100 rdf:type ex:Professor . ex:Professor200 rdf:type ex:Professor . ex:Student1 foaf:name ā€œJuanā€. ā€¦
  • 117. R2RML Mapping ā€¢ A R2RML Mapping M consists of a finite set TM TripleMaps. ā€¢ Each TM āˆˆTM consists of a tuple (LT, SM, POM) ā€“ LT: LogicalTable ā€“ SM: SubjectMap ā€“ POM: PredicateObjectMap ā€¢ Each POMāˆˆPOM consists of a pair (PM, OM)* ā€“ PM: PredicateMap ā€“ OM: ObjectMap * For simplicity
  • 118. R2RML Mapping ā€¢ An R2RML Mapping is represented as an RDF Graph itself. ā€¢ Associated RDFS schema ā€“ http://www.w3.org/ns/r2rml ā€¢ Turtle is the recommended syntax
  • 119. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] . 119
  • 120. LogicalTable ā€¢ Tabular SQL query result that is to be mapped to RDF ā€“ rr:logicalTable 1. SQL base table or view ā€“ rr:tableName 2. R2RML View ā€“ rr:sqlQuery
  • 121. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] . 121
  • 122. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery ā€œā€ā€SELECT ID, NAME FROM Person WHERE gender = ā€œFā€ ā€œā€ā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class <http://www.ex.com/Woman> ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] .
  • 123.
  • 124. How to create RDF terms that define S, P and O? ā€¢ RDF term is either an IRI, a blank node, or a literal ā€¢ Answer 1. Constant Value 2. Value in the database a. Raw Value in a Column b. Column Value applied to a template
  • 125. TermMap ā€¢ A TermMap is a function that generates an RDF Term from a logical table row. ā€¢ RDF Term is either a IRI, or a Blank Node, or a Literal RDF Term TermMap Logical Table Row IRI Bnode Literal
  • 126. TermMap ā€¢ A TermMap must be exactly on of the following ā€“ Constant-valued TermMap ā€“ Column-valued TermMap ā€“ Template-valued TermMap ā€¢ If TermMaps are used to create S, P, O, then ā€“ 3 ways to create a subject ā€“ 3 ways to create a predicate ā€“ 3 ways to create an object
  • 127. How many ways to create a Triple? Ptemplate Stemplate PConstant Pcolumn Otemplate Oconstant Ocolumn Otemplate Oconstant Sconstant Ocolumn Otemplate Oconstant Ocolumn Ptemplate Scolumn PConstant Pcolumn Ptemplate PConstant Pcolumn Otemplate Oconstant Ocolumn Otemplate Oconstant Ocolumn Otemplate Oconstant Ocolumn Otemplate Oconstant Ocolumn Otemplate Oconstant Ocolumn Otemplate Oconstant Ocolumn
  • 128. Constant-valued TermMap ā€¢ A TermMap that ignores the logical table row and always generates the same RDF term ā€¢ rr:constant ā€¢ Commonly used to generate constant IRIs as the predicate
  • 129. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name ] rr:objectMap [rr:column ā€NAME" ] ] . 129
  • 130. Column-valued TermMap ā€¢ A TermMap that maps a column value of a column name in a logical table row ā€¢ rr:column ā€¢ Commonly used to generate Literals as the object
  • 131. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name ] rr:objectMap [rr:column ā€NAME" ] ] . 131
  • 132. Template-valued TermMap ā€¢ A TermMap that maps the column values of a set of column names to a string template. ā€¢ A string template is a format that can be used to build strings from multiple components. ā€¢ rr:template ā€¢ Commonly used to generate IRIs as the subject or concatenate different attributes
  • 133. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name ] rr:objectMap [rr:column ā€NAME" ] ] . 133
  • 134. Commonly usedā€¦ ā€¢ ā€¦ but any of these TermMaps can be used to create any RDF Term (s,p,o). Recall: ā€“ 3 ways to create a subject ā€“ 3 ways to create a predicate ā€“ 3 ways to create an object ā€¢ Template-valued TermMap are commonly used to create an IRI for a subject, but can be used to create Literal for an object. ā€¢ How to specify the term (IRI or Literal in this case)?
  • 135. TermType ā€¢ Specify the type of a term that a TermMap should generate ā€¢ Force what the RDF term should be ā€¢ Three types of TermType: ā€“ rr:IRI ā€“ rr:BlankNode ā€“ rr:Literal
  • 136. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name ] rr:objectMap [ rr:template ā€{FIRST_NAME} {LAST_NAME}ā€; rr:termType rr:Literal; ] ] . 136
  • 137. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template ā€person{ID}"; rr:termType rr:BlankNode; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name ] rr:objectMap [rr:column ā€NAME" ] ] . 137
  • 138. TermType (contā€¦) ā€¢ Can only be applied to Template and Column valued TermMap ā€¢ Applying to Constant-valued TermMap has no effect ā€“ i.e If the constant is an IRI, the term type is automatically an IRI
  • 139. TermType Rules ā€¢ If the Term Map is for a 1. Subject ļƒ  TermType = IRI or Blank Node 2. Predicate ļƒ  TermType = IRI 3. Object ļƒ  TermType = IRI or Blank Node or Literal
  • 140. TermType is Optional ā€¢ If a TermType is not specified then ā€“ Default = IRI ā€“ Unless itā€™s for an object being defined by a Column-based TermMap or has a language tag or specified datatype, then the TermType is a Literal ā€¢ Thatā€™s why if there is a template in an ObjectMap, it will always generate an IRI, unless a TermType to Literal is specified.
  • 141. rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name ] rr:objectMap [ rr:template ā€{FIRST_NAME} {LAST_NAME}ā€; rr:termType rr:Literal; ] ] rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name ] rr:objectMap [ rr:template ā€{FIRST_NAME} {LAST_NAME}ā€ ] ] rr:predicateObjectMap [ rr:predicateMap [rr:constant ex:role ] rr:objectMap [ rr:template ā€http://ex.com/role/{role}ā€ ] ] 141
  • 142.
  • 143. Now we have the elements to create Triples
  • 144. Generating SPO ā€¢ TermMap that specifies what RDF term should be for S, P, O ā€“ SubjectMap ā€“ PredicateMap ā€“ ObjectMap
  • 145. SubjectMap ā€¢ ā€¢ ā€¢ ā€¢ SubjectMap is a TermMap rr:subjectMap Specifies what the subject of a triple should be 3 ways to create a subject ā€“ Template-valued Term Map ā€“ Column-valued Term Map ā€“ Constant-valued Term Map ā€¢ Has to be an IRI or Blank Node
  • 146. SubjectMap ā€¢ SubjectMaps are usually Template-valued TermMap ā€¢ Use-case for Column-valued TermMap ā€“ Use a column value to create a blank node ā€“ URI exist as a column value ā€¢ Use-case for Constant-valued TermMap ā€“ For all tuples: <CompanyABC> <consistsOf> <Dep{id}>
  • 147. SubjectMap ā€¢ Optionally, a SubjectMap may have one or more Class IRIs associated ā€“ This will generate rdf:type triples ā€¢ rr:class
  • 148. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] . Optional 148
  • 149. PredicateObjectMap ā€¢ A function that creates one or more predicateobject pairs for each logical table row. ā€¢ rr:predicateObjectMap ā€¢ It is used in conjunction with a SubjectMap to generate RDF triples in a TriplesMap. ā€¢ A predicate-object pair consists of* ā€“ One or more PredicateMaps ā€“ One or more ObjectMaps or ReferencingObjectMaps
  • 150. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name]; [rr:column ā€NAME" ] ] . rr:objectMap 150
  • 151. PredicateMap ā€¢ PredicateMap is a TermMap ā€¢ rr:predicateMap ā€¢ Specifies what the predicate of a triple should be ā€¢ 3 ways to create a predicate ā€“ Template-valued Term Map ā€“ Column-valued Term Map ā€“ Constant-valued Term Map ā€¢ Has to be an IRI
  • 152. PredicateMap ā€¢ PredicateMaps are usually Constant-valued TermMap ā€¢ Use-case for Column-valued TermMap ā€“ā€¦ ā€¢ Use-case for Template-valued TermMap ā€“ā€¦
  • 153. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name]; rr:objectMap [rr:column ā€NAME" ] ] . 153
  • 154. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; Shortcut! rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [rr:column ā€NAME" ] ] . 154
  • 155. Constant Shortcut Properties ā€¢ ?x rr:predicate ?y ā€¢ ?x rr:predicateMap [ rr:constant ?y ] ā€¢ ?x rr:subject ?y ā€¢ ?x rr:subjectMap [ rr:constant ?y ] ā€¢ ?x rr:object ?y ā€¢ ?x rr:objectMap [ rr:constant ?y ]
  • 156. ObjectMap ā€¢ ā€¢ ā€¢ ā€¢ ObjectMap is a TermMap rr:objectMap Specifies what the object of a triple should be 3 ways to create a predicate ā€“ Template-valued Term Map ā€“ Column-valued Term Map ā€“ Constant-valued Term Map ā€¢ Has to be an IRI or Literal or Blank Node
  • 157. ObjectMap ā€¢ ObjectMaps are usually Column-valued TermMap ā€¢ Use-case for Template-valued TermMap ā€“ Concatenate values ā€“ Create IRIs ā€¢ Use-case for Constant-valued TermMap ā€“ All rows in a table share a role
  • 158. @prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€Personā€]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicateMap [rr:constant foaf:name]; rr:objectMap [rr:column ā€NAME" ] ] . 158
  • 159.
  • 160. Example 1 ā€¢ We now have sufficient elements to create a mapping that will generate ā€“ A Subject IRI ā€“ rdf:Type triple(s) Student sid name pid 1 Juan 100 2 Martin 200 TripleMap @prefix ex: <http://example.com/ns/>. ex:Student1 rdf:type ex:Student . ex:Student2 rdf:type ex:Student .
  • 161. Example 1 @prefix rr: <http://www.w3.org/ns/r2rml#>. @prefix ex: <http://example.com/ns/>. <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]. Logical Table is a Table Name SubjectMap is a Template-valued TermMap And it has one Class IRI
  • 162. Example 2 Student sid name pid 1 Juan 100 2 Martin 200 TripleMap @prefix ex: <http://example.com/ns/>. ex:Student1 rdf:type ex:Student . ex:Student1 ex:name ā€œJuanā€ . ex:Student2 rdf:type ex:Student . ex:Student2 ex:name ā€œMartinā€ .
  • 163. Example 2 @prefix rr: <http://www.w3.org/ns/r2rml#>. @prefix ex: <http://example.com/ns/>. <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]; rr:predicateObjectMap [ rr:predicate ex:name; rr:objectMap [ rr:column ā€œnameā€]; ]. PredicateMap which is a Constant-valued TermMap Logical Table is a Table Name SubjectMap is a Template-valued TermMap And it has one Class IRI PredicateObjectMap ObjectMap which is a Column-valued TermMap
  • 164. Example 3 Student sid name pid 1 Juan 100 2 Martin 200 TripleMap @prefix ex: <http://example.com/ns/>. ex:Student1 rdf:type ex:Student . ex:Student1 ex:comment ā€œJuan is a Studentā€ . ex:Student2 rdf:type ex:Student . ex:Student2 ex:comment ā€œMartin is a Studentā€ .
  • 165. Example 3 @prefix rr: <http://www.w3.org/ns/r2rml#>. @prefix ex: <http://example.com/ns/>. <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]; rr:predicateObjectMap [ rr:predicate ex:comment; rr:objectMap [ rr:template ā€œ{name} is a Studentā€; rr:termType rr:Literal; ]; ]. PredicateMap which is a Constant-valued TermMap Logical Table is a Table Name SubjectMap is a Template-valued TermMap And it has one Class IRI PredicateObjectMap ObjectMap which is a Template-valued TermMap TermType
  • 166. Example 4 Student sid name pid 1 Juan 100 2 Martin 200 TripleMap @prefix ex: <http://example.com/ns/>. ex:Student1 rdf:type ex:Student . ex:Student1 ex:webpage <http://ex.com/Juan>. ex:Student2 rdf:type ex:Student . ex:Student2 ex:webpage <http://ex.com/Martin>.
  • 167. Example 4 @prefix rr: <http://www.w3.org/ns/r2rml#>. @prefix ex: <http://example.com/ns/>. <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]; rr:predicateObjectMap [ rr:predicate ex:webpage; rr:objectMap [ rr:template ā€œhttp://ex.com/{name}ā€; ]; ]. PredicateMap which is a Constant-valued TermMap Logical Table is a Table Name SubjectMap is a Template-valued TermMap And it has one Class IRI PredicateObjectMap ObjectMap which is a Template-valued TermMap Note that there is not TermType
  • 168. Example 5 Student sid name pid 1 Juan 100 2 Martin 200 TripleMap @prefix ex: <http://example.com/ns/>. ex:Student1 rdf:type ex:Student . ex:Student1 ex:studentType ex:GradStudent. ex:Student2 rdf:type ex:Student . ex:Student2 ex:studentType ex:GradStudent.
  • 169. Example 6 @prefix rr: <http://www.w3.org/ns/r2rml#>. @prefix ex: <http://example.com/ns/>. <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]; rr:predicateObjectMap [ rr:predicate ex:studentType; rr:object ex:GradStudent ; ]. PredicateMap which is a Constant-valued TermMap Logical Table is a Table Name SubjectMap is a Template-valued TermMap And it has one Class IRI PredicateObjectMap ObjectMap which is a Constant-valued TermMap
  • 170. RefObjectMap ā€¢ A RefObjectMap (Referencing ObjectMap) allows using the subject of another TriplesMap as the object generated by a ObjectMap. ā€¢ rr:objectMap ā€¢ A RefObjectMap defined by ā€“ Exactly one ParentTripleMap, which must be a TripleMap ā€“ May have one or more JoinConditions
  • 171. <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableNameā€Person" ]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:based_near ; rr:objectMap [ rr:parentTripelMap <TripleMap2>; rr:joinCondition [ rr:child ā€œCIDā€; rr:parent ā€œCIDā€; ] ] <TriplesMap2> ] a rr:TriplesMap; . rr:logicalTable [ rr:tableName ā€City" ]; RefObjectMap rr:subjectMap [ rr:template "http://ex.com/City/{CID}"; rr:class ex:City ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [ rr:column ā€TITLE" ] ] . 171
  • 172. ParentTripleMap ā€¢ The referencing TripleMap ā€¢ rr:parentTriplesMap <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableNameā€Person" ]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:based_near ; rr:objectMap [ rr:parentTripelMap <TripleMap2>; rr:joinCondition [ rr:child ā€œCIDā€; rr:parent ā€œCIDā€; ] ] ] . Parent TriplesMap
  • 173. JoinCondition ā€¢ Join between child and parent attribuets ā€¢ rr:joinCondition <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableNameā€Person" ]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:based_near ; rr:objectMap [ rr:parentTripelMap <TripleMap2>; rr:joinCondition [ rr:child ā€œCIDā€; rr:parent ā€œCIDā€; ] ] ] . JoinCondition
  • 174. <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableNameā€Person" ]; rr:subjectMap [ rr:template "http://www.ex.com/Person/{ID}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate foaf:based_near ; rr:objectMap [ rr:parentTripelMap <TripleMap2>; rr:joinCondition [ rr:child ā€œCIDā€; rr:parent ā€œCIDā€; ] ] <TriplesMap2> ] a rr:TriplesMap; . rr:logicalTable [ rr:tableName ā€City" ]; RefObjectMap Parent TriplesMap JoinCondition rr:subjectMap [ rr:template "http://ex.com/City/{CID}"; rr:class ex:City ]; rr:predicateObjectMap [ rr:predicate foaf:name; rr:objectMap [ rr:column ā€TITLE" ] ] . 174
  • 175. JoinCondition ā€¢ Child Column which must be the column name that exists in the logical table of the TriplesMap that contains the RefObjectMap ā€¢ Parent Column which must be the column name that exists in the logical table of the RefObjectMapā€™s Parent TriplesMap. <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableNameā€Person" ]; ... rr:predicateObjectMap [ rr:predicate foaf:based_near ; rr:objectMap [ rr:parentTripelMap <TripleMap2>; rr:joinCondition [ rr:child ā€œCIDā€; rr:parent ā€œCIDā€;] ] ]. <TriplesMap2> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€City" ]; ... .
  • 176. JoinCondition ā€¢ Child Query ā€“ The Child Query of a RefObjectMap is the LogicalTable of the TriplesMap containing the RefObjectMap ā€¢ Parent Query ā€“ The ParentQuery of a RefObjectMap is the LogicalTable of the Parent TriplesMap ā€¢ If the ChildQuery and ParentQuery are not identical, then a JoinCondition must exist <TriplesMap1> a rr:TriplesMap; rr:logicalTable [ rr:tableNameā€Person" ]; ... rr:predicateObjectMap [ rr:predicate foaf:based_near ; rr:objectMap [ rr:parentTripelMap <TripleMap2>; rr:joinCondition [ rr:child ā€œCIDā€; rr:parent ā€œCIDā€;] ] ]. <TriplesMap2> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€City" ]; ... .
  • 177.
  • 178. Example 7 Student sid name pid 1 Juan 100 2 Martin 200 Professor pid name 100 Dan 200 Marcelo R2RML Mapping ex:Student1 rdf:type ex:Student . ex:Student2 rdf:type ex:Student . ex:Professor100 rdf:type ex:Professor . ex:Professor200 rdf:type ex:Professor . ex:Student1 ex:hasAdvisor ex:Professor100 . ex:Student2 ex:hasAdvisor ex:Professor200
  • 179. @prefix rr: <http://www.w3.org/ns/r2rml#>. @prefix ex: <http://example.com/ns/>. <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]; rr:predicateObjectMap [ rr:predicate ex:hasAdvisor; RefObjectMap rr:objectMap [ rr:parentTriplesMap <#TriplesMap2>; Parent TriplesMap rr:joinCondition [ rr:child ā€œpidā€; JoinCondition rr:parent ā€œpidā€; ] ] <#TriplesMap2> ]. rr:logicalTable [ rr:tableName ā€Professorā€]; rr:subjectMap [ rr:template "http://example.com/ns/{pid}"; rr:class ex:Professor; ].
  • 181. Languages ā€¢ TermMap with a TermType of rr:Literal may have a language tag ā€¢ rr:language <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]; rr:predicateObjectMap [ rr:predicate ex:comment; rr:objectMap [ rr:column ā€œcommentā€; rr:language ā€œenā€; ]; ].
  • 182. Student sid name comment 1 Juan Excellent Student 2 Martin Wonderful student @prefix ex: <http://example.com/ns/>. ex:Student1 rdf:type ex:Student . ex:Student1 ex:comment ā€œExcellent Studentā€@en . ex:Student2 rdf:type ex:Student . ex:Student2 ex:comment ā€œWonderful Studentā€@en .
  • 183. Issue with Languages ā€¢ What happens if language value is in the data? ID COUNTRY_ID LABEL LANG 1 1 United States en 2 1 Estados Unidos es 3 2 England en 4 2 Inglaterra es
  • 184. ID COUNTRY_ID LABEL LANG 1 1 United States en 2 1 Estados Unidos es 3 2 England en 4 2 Inglaterra es ? @prefix ex: <http://example.com/ns/>. ex:country1 rdfs:label ā€œUnited Statesā€@en . ex:country1 rdfs:label ā€œEstados Unidosā€@es . ex:country2 rdfs:label ā€œEnglandā€@en . ex:country2 rdfs:label ā€œInglaterraā€@es .
  • 185. Issue with Languages ā€¢ Mapping for each language <#TripleMap_Countries_EN> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """SELECT COUNTRY_ID, LABEL, LANG, FROM COUNTRY WHERE LANG = ā€™en'""" ]; rr:subjectMap [ rr:template "http://example.com/country{COUNTRY_ID}" ]; rr:predicateObjectMap [ rr:predicate rdfs:label; rr:objectMap [ rr:column ā€œLABELā€; rr:language ā€œenā€; ]; ].
  • 186. Language Extension ā€¢ Single mapping for all languages <#TripleMap_Countries_EN> a rr:TriplesMap; rr:logicalTable [ rr:tableName ā€COUNTRY" ]; rr:subjectMap [ rr:template "http://example.com/country{COUNTRY_ID}" ]; rr:predicateObjectMap [ rr:predicate rdfs:label; rr:objectMap [ rr:column ā€œLABELā€; rrx:languageColumn ā€œLANGā€; ]; ]. Column Value as Language
  • 187. Datatypes ā€¢ TermMap with a TermType of rr:Literal ā€¢ TermMap does not have rr:language <#TriplesMap1> rr:logicalTable [ rr:tableName ā€Studentā€]; rr:subjectMap [ rr:template "http://example.com/ns/{sid}"; rr:class ex:Student; ]; rr:predicateObjectMap [ rr:predicate ex:startDate; rr:objectMap [ rr:column ā€œstart_dateā€; rr:datatype xsd:date; ]; ].
  • 188. Summary of Terminology ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ R2RML Mapping Logical Table Input Database R2RML View TriplesMap Logical Table Row TermMap TermType SubjectMap PredicateObjectMap PredicateMap ObjectMap ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ ā€¢ Constant-valued TermMap Column-valued TermMap Template-valued TermMap RefObjectMap JoinConditions ChildQuery ParentQuery Language Datatype
  • 189. Questions? Next: ETL and Musicbrainz
  • 190. RDB2RDF Tutorial ETL and Musicbrainz Juan F. Sequeda Daniel P. Miranker Barry Norton
  • 191. Context RDF Data Management Relational Database to RDF (RDB2RDF) Wrapper Systems Extract-Transform-Load (ETL) Native Triplestores Triplestores RDBMS-backed NoSQL Triplestores Triplestores 191
  • 192. Extract ā€“ Transform ā€“ Load (ETL) SPARQL Relational Database RDB2RDF Dump Triplestore
  • 193. Analysis & Mining Module Visualization Module RDFa Data acquisition LD Dataset Access Application EUCLID Scenario SPARQL Endpoint Publishing Vocabulary Mapping Interlinking Physical Wrapper Integrated Dataset Cleansing LD Wrapper R2R Transf. LD Wrapper RDF/ XML Streaming providers Downloads Musical Content Metadata Other content 193
  • 194. W3C RDB2RDF Data acquisition LD Dataset Access SPARQL Endpoint Publishing Integrated Data in Triplestore Vocabulary Mapping ā€¢ Task: Integrate data from relational DBMS with Linked Data Interlinking ā€¢ Approach: map from relational schema to semantic vocabulary with R2RML R2RML Engine Cleansing ā€¢ Publishing: two alternatives ā€“ ā€“ Translate SPARQL into SQL on the fly ā€“ Batch transform data into RDF, index and provide SPARQL access in a triplestore Relational DBMS RDB2RDF 194
  • 195. MusicBrainz Next Gen Schema ā€¢ artist As pre-NGS, but further attributes ā€¢ artist_credit Allows joint credit ā€¢ release_group Cf. ā€˜albumā€™ versus: ā€¢ work ā€¢ release ā€¢ track ā€¢ medium ā€¢ tracklist ā€¢ recording https://wiki.musicbrainz.org/Next_Generation_Schema RDB2RDF 195
  • 196. Music Ontology ā€¢ MusicArtist ā€“ ArtistEvent, member_of ā€¢ SignalGroup ā€˜Albumā€™ as per Release_Group ā€¢ Release ā€“ ReleaseEvent ā€¢ ā€¢ ā€¢ ā€¢ Record Track Work Composition http://musicontology.com/ RDB2RDF 196
  • 197. Scale ā€¢ MusicBrainz RDF derived via R2RML: 300M Triples lb:artist_member a rr:TriplesMap ; rr:logicalTable [rr:sqlQuery """SELECT a1.gid, a2.gid AS band FROM artist a1 INNER JOIN l_artist_artist ON a1.id = l_artist_artist.entity0 INNER JOIN link ON l_artist_artist.link = link.id INNER JOIN link_type ON link_type = link_type.id INNER JOIN artist a2 on l_artist_artist.entity1 = a2.id WHERE link_type.gid='5be4c609-9afa-4ea0-910b-12ffb71e3821'"""] ; rr:subjectMap [rr:template "http://musicbrainz.org/artist/{gid}#_"] ; rr:predicateObjectMap [rr:predicate mo:member_of ; rr:objectMap [rr:template "http://musicbrainz.org/artist/{band}#_" ; rr:termType rr:IRI]] . 197
  • 198. Musicbrainz ā€¢ Musicbrainz Dumps: ā€“ http://mbsandbox.org/~barry/ ā€¢ Musicbrainz R2RML Mappings ā€“ https://github.com/LinkedBrainz/MusicBrainz-R2RML ā€¢ 30 mins to generate 150M triples with Ultrawrap ā€“ 8 Xeon cores, 16 GB Ram (2GB are usually free) ā€“ Should be less but server was overloaded ā€“ It use to be 8+ hours using D2RQ on a dedicated machine
  • 199. Musicbrainz Dump Statistics (Lead) Table area artist dbpedia label medium recording release_group release track work Triples 59798 36868228 172017 201832 18069143 11400354 3050818 9764887 75506495 1728955 156822527 Time (s) 2 423 13 3 163 209 31 151 794 20 1809
  • 200. R2RML Class Mapping ā€¢ Mapping tables to classes is ā€˜easyā€™: lb:Artist a rr:TriplesMap ; rr:logicalTable [rr:tableName "artist"] ; rr:subjectMap [rr:class mo:MusicArtist ; rr:template "http://musicbrainz.org/artist/{gid}#_"] ; rr:predicateObjectMap [rr:predicate mo:musicbrainz_guid ; rr:objectMap [rr:column "gid" ; rr:datatype xsd:string]] . RDB2RDF 200
  • 201. R2RML Property Mapping ā€¢ Mapping columns to properties can be easy: lb:artist_name a rr:TriplesMap ; rr:logicalTable [rr:sqlQuery """SELECT artist.gid, artist_name.name FROM artist INNER JOIN artist_name ON artist.name = artist_name.id"""] ; rr:subjectMap [rr:template "http://musicbrainz.org/artist/{gid}#_"] ; rr:predicateObjectMap [rr:predicate foaf:name ; rr:objectMap [rr:column "name"]] . RDB2RDF 201
  • 202. NGS Advanced Relations ā€¢ Major entities (Artist, Release Group, Track, etc.) plus URL are paired (l_artist_artist) ā€¢ Each pairing of instances refers to a Link ā€¢ Links have types (cf. RDF properties) and attributes http://wiki.musicbrainz.org/Advanced_Relationship RDB2RDF 202
  • 203. Advanced Relations Mapping ā€¢ Mapping advanced relationships (SQL joins): lb:artist_member a rr:TriplesMap ; rr:logicalTable [rr:sqlQuery """SELECT a1.gid, a2.gid AS band FROM artist a1 INNER JOIN l_artist_artist ON a1.id = l_artist_artist.entity0 INNER JOIN link ON l_artist_artist.link = link.id INNER JOIN link_type ON link_type = link_type.id INNER JOIN artist a2 on l_artist_artist.entity1 = a2.id WHERE link_type.gid='5be4c609-9afa-4ea0-910b-12ffb71e3821'"""] ; rr:subjectMap [rr:template "http://musicbrainz.org/artist/{gid}#_"] ; rr:predicateObjectMap [rr:predicate mo:member_of ; rr:objectMap [rr:template "http://musicbrainz.org/artist/{band}#_" ; rr:termType rr:IRI]] . RDB2RDF 203
  • 204. Advanced Relations Mapping ā€¢ Mapping advanced relationships (SQL joins): lb:artist_dbpedia a rr:TriplesMap ; rr:logicalTable [rr:sqlQuery """SELECT artist.gid, REPLACE(REPLACE(url, 'wikipedia.org/wiki', 'dbpedia.org/resource'), 'http://en.', 'http://') AS url FROM artist INNER JOIN l_artist_url ON artist.id = l_artist_url.entity0 INNER JOIN link ON l_artist_url.link = link.id INNER JOIN link_type ON link_type = link_type.id INNER JOIN url on l_artist_url.entity1 = url.id WHERE link_type.gid='29651736-fa6d-48e4-aadc-a557c6add1cb' AND url SIMILAR TO 'http://(de|el|en|es|ko|pl|pt).wikipedia.org/wiki/%'"""] ; rr:subjectMap lb:sm_artist ; rr:predicateObjectMap [rr:predicate owl:sameAs ; rr:objectMap [rr:column "url"; rr:termType rr:IRI]] . RDB2RDF 204
  • 205. SPARQL Example ā€¢ SPARQL versus SQL ASK {dbp:Paul_McCartney mo:member dbp:The_Beatles} SELECT ā€¦ INNER INNER INNER INNER INNER INNER INNER INNER INNER INNER INNER INNER WHERE JOIN JOIN JOIN JOIN JOIN JOIN JOIN JOIN JOIN JOIN JOIN JOIN AND ā€¦ AND ā€¦ AND ā€¦ AND ā€¦ RDB2RDF 205
  • 206. For exercises, quiz and further material visit our website: http://www.euclid-project.eu Course eBook Other channels: @euclid_project EUCLID project EUCLIDproject 206
  • 208. RDB2RDF Tutorial Wrappers Juan F. Sequeda Daniel P. Miranker Barry Norton
  • 209. Context RDF Data Management Relational Database to RDF (RDB2RDF) Wrapper Systems Extract-Transform-Load (ETL) Native Triplestores Triplestores RDBMS-backed NoSQL Triplestores Triplestores 209
  • 211. ā€œComparing the overall performance [ā€¦] of the fastest rewriter with the fastest relational database shows an overhead for query rewriting of 106%. This is an indicator that there is still room for improving the rewriting algorithmsā€ [Bizer and Schultz 2009]
  • 212. Results of BSBM 2009 Larger numbers are better http://wifo5-03.informatik.uni-mannheim.de/bizer/berlinsparqlbenchmark/results/index.html
  • 213. Results of BSBM 2009 100M Triple Dataset Larger numbers are better After March 2009, RDB2RDF systems have not been compared to RDBMS http://wifo5-03.informatik.uni-mannheim.de/bizer/berlinsparqlbenchmark/results/index.html
  • 214. Current rdb2rdf systems are not capable of providing the query execution performance required [...] it is likely that with more work on query translation, suitable mechanisms for translating queries could be developed. These mechanisms should focus on exploiting the underlying database systemā€™s capabilities to optimize queries and process large quantities of structure data [Gray et al. 2009]
  • 215.
  • 216.
  • 217. Why is this happening if ā€¦
  • 218. ā€œSPARQL is equivalent, from an expressive point of you, to relational algebraā€ Angles & Gutierrez 2008
  • 219. Problem ā€¢ How can SPARQL queries be efficiently evaluated on a RDBMS? ā€¢ Hypothesis: Existing commercial relational database already subsume optimizations for effective SPARQL execution on relationally stored data 219
  • 220. Nugget 1. Defined architecture based on SQL Views which allows RDBMS to do the optimization. 2. Identified two important optimizations that already exist in commercial RDBMS. Sequeda & Miranker. Ultrawrap: SPARQL Execution on Relational Data. Journal Web Semantics 2013 220
  • 221. Ultrawrap Compile Time 1. Translate SQL Schema to OWL and Mapping 2. Define RDF Triples, as a View Run Time 3. SPARQL to SQL translation 4. SQL Optimizer creates relational query plan 221
  • 222. Creating Tripleview ā€¢ For every ontology element (Class, Object Property and Datatype property), create a SQL SELECT query that outputs triples SELECT 'Productā€™+ptID as s, ā€˜labelā€™ as p, label as o FROM Product WHERE label IS NOT NULL Product ptID label prID S P O 1 ACME Inc 4 Product1 label ACME Inc 2 Foo Bars Product2 label Foo Bars 5 222
  • 223. Creating Tripleview SELECT ā€˜Productā€™+ptID as s, prID as s_id, ā€˜labelā€™ as p, label as o, NULL as o_id FROM Product WHERE label IS NOT NULL Product ptID label prID S S_id P O O_id 1 ACME Inc 4 Product1 1 label ACME Inc NULL 2 Foo Bars Product2 2 label Foo Bars NULL 5 223
  • 224. Class RDF Triples SELECT ā€˜Productā€™+ptID as s, prID as s_id, ā€˜rdf:typeā€™ as p, ā€˜Productā€™ as o, NULL as o_id FROM Product S S_id P O O_id Product1 1 rdf:type Product NULL Product2 2 rdf:type Product NULL Object Property RDF Triples SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜Product#Producerā€™ as p, ā€˜Producerā€™+prID as o, prID as o_id FROM Product S S_id P O O_id Product1 1 Product#Producer Producer4 4 Product2 2 Product#Producer Producer5 5
  • 225. Creating Tripleview (ā€¦) ā€¢ Create TripleViews (SQL View), which are unions of the SQL SELECT query that have the same datatype CREATE VIEW Tripleview_varchar AS SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜labelā€™ as p, label as o, NULL as o_id FROM Product UNION ALL SELECT ā€˜Producerā€™+prID as s, prID as s_id, ā€˜titleā€™ as p, title as o, NULL as o_id FROM Producer UNION ALL ā€¦ S S_id P O O_id Product1 1 label ACME Inc NULL Product2 2 label Foo Bars NULL Producer4 4 title Foo NULL Producer5 5 Ttitle Bars NULL 225
  • 226. CREATE VIEW Tripleview_int AS SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜pnum1ā€™ as p, pnum1 as o, NULL as o_id FROM Product UNION ALL SELECT ā€˜Productā€™+ptID as s, ptID as s_id, ā€˜pnum2ā€™ as p, pnum2 as o, NULL as o_id FROM Product S S_id P O O_id Product1 1 pnum1 1 NULL Product2 2 pnum1 3 NULL Product1 1 pnum2 2 NULL Product2 2 pnum2 3 NULL
  • 227. SPARQL and SQL ā€¢ Translating a SPARQL query to a semantically equivalent SQL query SELECT ?label ?pnum1 WHERE{ ?x label ?label. ?x pnum1 ?pnum1. } SQL on Tripleview ļƒ  SELECT label, pnum1 FROM product What is the Query Plan? SELECT t1.o AS label, t2.o AS pnum1 FROM tripleview_varchar t1, tripleview_int t2 WHERE t1.p = 'label' AND t2.p = 'pnum1' AND t1.s_id = t2.s_id 227
  • 228. Ļ€ t1.o AS label, t2.o AS pnum1 Ļƒp = ā€˜labelā€™ Tripleview_varchar t1 Ļƒp = ā€˜pnum1ā€™ Tripleview_int t2 CONTRADICTION CONTRADICTION U U Ļ€ Product+ā€™idā€™ AS s , ā€˜pnum2ā€™ AS p, pnum2 AS o Ļ€ Product+ā€™idā€™ AS s , ā€˜pnum1ā€™ AS p, pnum1 AS o Ļ€ Producer+ā€™idā€™ AS s , ā€˜titleā€™ AS p, title AS o Ļƒpnum2 ā‰  NULL Ļ€ Product+ā€™idā€™ AS s , ā€˜labelā€™ AS p, label AS o Ļƒpnum1 ā‰  NULL Ļƒtitle ā‰  NULL Product Ļƒlabel ā‰  NULL Product Product Producer 228
  • 229. Detection of Unsatisfiable Conditions ā€¢ Determine that the query result will be empty if the existence of another answer would violate some integrity constraint in the database. ā€¢ This would imply that the answer to the query is null and therefore the database does not need to be accessed Chakravarthy, Grant and Minker. (1990) Logic-Based Approach to Semantic Query Optimization. 229
  • 230. Ļ€ t1.o AS label, t2.o AS pnum1 Ļ€ Product+ā€™idā€™ AS s , ā€˜labelā€™ AS p, label AS o Ļ€ Product+ā€™idā€™ AS s , ā€˜pnum1ā€™ AS p, pnum1 AS o Ļƒlabel ā‰  NULL Ļƒpnum1 ā‰  NULL Product Product Join on the same table? ļƒ  REDUNDANT 230
  • 231. Self Join Elimination ā€¢ If attributes from the same table are projected separately and then joined, then the join can be dropped Self Join Elimination of Projection SELECT p1.label, p2.pnum1 FROM product p1, product p2 WHERE p1.id = 1 and p1.id = p2.id SELECT label, pnum1 FROM product WHERE id = 1 Self Join Elimination of Selection SELECT p1.id FROM product p1, product p2 WHERE p1.pnum1 >100 and p2.pnum2 < 500 and p1.id = p2.id SELECT id FROM product WHERE pnum1 > 100 and pnum2 < 500 231
  • 232. Ļ€ label, pnum1 Ļƒlabel ā‰  NULL AND pnum1 ā‰  NULL Product 232
  • 233. Evaluation ā€¢ Use Benchmarks that stores data in relational databases, provides SPARQL queries and their semantically equivalent SQL queries ā€¢ BSBM - 100 Million Triples ā€¢ Barton ā€“ 45 million triples
  • 236. Augmented Ultrawrap Experiment ā€¢ Implemented DoUC ā€“ Hash predicate to SQL query ā€“ Few LOC
  • 237. SPARQL as Fast as SQL Berlin Benchmark on 100 Million Triples on Oracle 11g using Ultrawrap 237
  • 238. Discussion ā€¢ Self join elimination ā€¢ Push Selects and Join Predicates ā€¢ Join Ordering ā€¢ Left Outer Join

Editor's Notes

  1. Goal of Slide: What is the Problem and My Contribution IP: No information is being lost. Ability of reconstructing the original database from the result of the direct mappingQP: No query is being lostEvery relational query over a RDB can be translated to a equivalent SPARQL query over directly mapped RDF.
  2. Goal of Slide: Example of MappingIt seems easyā€¦ however, there are special issues
  3. Goal of Slide: NULLs is an issue where this is not straightforward
  4. Why is this hard and important ļƒ  because of NULLs. Need to be able to reconstruct the original database instance with nulls======The inverse direct mapping N : G -&gt; I must be computable A mapping is computable if there exists an algorithm that, given G āˆˆ G, computes N (G).
  5. Why is this hard and important ļƒ  because of NULLs.
  6. Why is this hard and important ļƒ  adding new data wonā€™t make you rerun the complete mapping
  7. Goal of Slide: How does the Direct Mapping work?5 Predicates for RDB12 Rules for RDB -&gt; Ontology3 Predicates for Ontology10 Rules for Ontology -&gt; OWL10 Rules for Ontology + Instances -&gt; RDFW3C Standard only has the 10 rules for Ontology + Instances -&gt; RDF
  8. R is a binary relation between two relations S and T if both S and T are different from R, R has exactly two attributes A and B, which form a primary key of R, A is the attribute of a foreign key in R that points to S, B is the attribute of a foreign key in R that points to T , A is not the attribute of two distinct foreign keys in R, B is not the attribute of two distinct foreign keys in R, A and B are not the attributes of a composite foreign key in R, and relation R does not have incoming foreign keys.
  9. Goal of Slide: What is Information PreservationAbility of reconstructing the original database from the result of the direct mappingMapping is losslessNo information is being lostWhy is this hard and important ļƒ  because of NULLs. Need to be able to reconstruct the original database instance with nulls
  10. Goal of Slide: What is Query PreservationEvery relational query over a RDB can be translated to a equivalent SPARQL query over directly mapped RDF. WHAT ABOUT SPARQL -&gt; SQLopen issue is to prove that for any sparql query, there exist a relational algebra query. my future work aims at proving a more general result:for any mapping between any db and any ontologythis would be a corrollary.
  11. Goal of Slide: What is MonotonicityDesired PropertyAssures that a re-computation of the entire mapping is not needed after any updates to the DB
  12. Goal of Slide: What is Semantics PreservationSatisfaction of a set of integrity constraints are encoded in the mapping result
  13. Goal of Slide: Monotone canā€™t be Semantics Preserving
  14. Does this mean that our direct mapping is incorrect? What could we do to create a direct mapping that is semantics preserving?
  15. Getty has a use case for Column-valued TermMap
  16. These numbers are Query Mixes per Hour. Each query mix consists of 25 queries that represent ecommerce navigationThe reduced query mix takes out 2 types of queries (query 5 and 6) You can see the sparql and semantically equivalent sql here: http://www4.wiwiss.fu-berlin.de/bizer/BerlinSPARQLBenchmark/spec/ExploreUseCase/index.htmlThey were taken out because Q5: has ā€œcomplexā€ FiltersQ6: has free text search
  17. Goal of Slide: What is the Problem and My Contribution ----- Meeting Notes (5/8/13 18:03) -----assuming wrapper
  18. A first implementation naively represented the relational data as RDF using only three columnsWe observe that the preconditions for applying optimizations were not being satisfiedļƒ  Indexes were not being exploited
  19. With this refinement, the preconditions for applying optimizations were being satisfiedļƒ  Indexes were being exploited
  20. Another precondition for applying optimization was the objects in the views need to be have the same datatype
  21. Goal of the Slide = What is the SPARQL to SQL translationTV(X, ā€˜labelā€™, Y) &lt;- Product(X, Y, _)TV(X, ā€˜pnum1ā€™, Z) &lt;- Product(X, _, Z)Q(S,T) &lt;-TV(X, ā€˜labelā€™, S), TV(X, ā€˜pnum1ā€™, T) Q(S,T) &lt;-Product(X, S, _), Product(X, _, T)