The document discusses generating RDF datasets from non-RDF data sources using R2RML (RDB to RDF Mapping Language). It provides background on RDF, RDF Schema, SPARQL, Linked Data, and describes how R2RML can be used to map relational databases to RDF according to the W3C recommendation. Direct mappings are discussed as well as content negotiation in transforming data to RDF.
4. Background – RDF
• Stands for Resource Descrip4on Framework
• RDF is not a language but a model (!!!)
• RDF is a W3C recommenda-on
• RDF is designed to be read by computers
• RDF is for describing resources on the Web
in terms of triples (subject – predicate – object) [in graphs]
• RDF uses URIs to iden-fy and refer to resources on the Web
• RDF/XML is just one way of serializing RDF
– We will use the Terse RDF Triple Language – TURTLE, which does not
provide support for named graphs
– A serializa-on format with support for named graphs is N-QUADS
04/11/17 christophe.debruyne@adaptcentre.ie 4
7. Background – RDFS
@base <http://foo.bar/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#Cat> a rdfs:Class ; rdfs:label "Cat" .
<#owns> a rdf:Property ; rdfs:label "owns" ;
rdfs:domain foaf:Person ; rdfs:range <#Cat> .
<#victor> a <#Cat> ; foaf:name "Victor" .
<#louis> a <#Cat> ; foaf:name "Louis" .
<#bettina> a <#Cat> ; foaf:name "Bettina" .
<#chrdebru> a foaf:Person ; foaf:name "Christophe Debruyne" ;
<#owns> <#victor> ; <#owns> <#louis> ;
<#owns> <#bettina> .
7
Exercise: What could we infer from <#kevin> <#owns> <#gomez> ?
04/11/17 christophe.debruyne@adaptcentre.ie
8. Background – SPARQL
• Stands for SPARQL Protocol and RDF Query Language
– Recursive acronym
• SPARQL 1.1 is a W3C Recommenda-on since March 2013
(h>p://www.w3.org/TR/sparql11-overview/)
• SPARQL allows us to:
– Pull values from structured and semi-structured data
– Explore data by querying unknown rela-onships
– Perform complex joins of disparate databases in a single, simple query
– Transform RDF data from one vocabulary to another
– …
8 04/11/17 christophe.debruyne@adaptcentre.ie
12. Background – GeoSPARQL
Give a me a list of coun-es whose
borders touch County Dublin
12
SELECT ?county ?w2 WHERE {
?dublin a osi:County .
?dublin rdfs:label "DUBLIN" .
?county a osi:County .
?dublin geo:hasGeometry ?g1 .
?g1 geo:asWKT ?w1 .
?county geo:hasGeometry ?g2 .
?g2 geo:asWKT ?w2
FILTER (geof:sfTouches(?w1, ?w2)) .
}
RDF allows one to engage with data in a declara-ve
manner, not bound to par-cular structure.
04/11/17 christophe.debruyne@adaptcentre.ie
19. RDB2RDF
04/11/17 christophe.debruyne@adaptcentre.ie 19
foaf:based_near
<person/1> <person/2>
foaf:Person
<city/1> <city/2>
ChristopheDebruyne Kevin
GhentDublin
rdf:type rdf:type
foaf:firstNamefoaf:lastName
foaf:namefoaf:name
foaf:based_near
foaf:firstName
Person
ID First Last CityID
1 Christophe Debruyne 1
2 Kevin NULL 2
City
ID Name
1 Dublin
2 Ghent
27. R2RML
• R2RML: RDB to RDF Mapping Language
– A W3C Recommenda-on since fall 2012
– h>p://www.w3.org/TR/r2rml/
• Crea-ng an R2RML file that annotates a rela-onal database with exis-ng
vocabularies and/or ontologies (RDFS or OWL).
• That R2RML file goes through an R2RML Mapping Engine to produce RDF.
• R2RML specified
– An ontology to specify those mappings;
– How those mappings should be interpreted to produce RDF.
– R2RML files are thus stored as RDF.
04/11/17 christophe.debruyne@adaptcentre.ie 27
43. Implementa-ons
• Stardog -- h>p://stardog.com/
– implements both R2RML and their own mapping language.
• Virtuoso – h>p://virtuoso.openlinksw.com/
• Oracle Spa-al and Graph –h>ps://www.oracle.com/database/spa-al/index.html
– Support for both transforming rela-onal databases into RDF using R2RML as well
as crea-ng R2RML views using those mappings
• OnTop -- h>p://ontop.inf.unibz.it/
– Access rela-onal databases as virtual graphs using mappings
• D2RQ -- h>p://d2rq.org/
– Direct mapping and D2RQ mapping language. No complete support for R2RML yet.
– Comes with a SPARQL Endpoint and Linked Data Frontend based on Pubby.
04/11/17 christophe.debruyne@adaptcentre.ie 43
50. RML
• Developed by iMinds (now imec) at Ugent
– h>p://semweb.mmlab.be/rml/spec.html
– h>ps://github.com/mmlab/RMLProcessor
• An extension of R2RML to support XML, HTML, CSV, JSON…
– Basically a superset of R2RML.
• See also: A. Dimou, M. Vander Sande, P. Colpaert, R. Verborgh, E.
Mannens, R. Van De Walle: “RML: A Generic Language for Integrated RDF
Mappings of Heterogeneous Data”, in Proceedings of the 7th Workshop
on Linked Data on the Web, WWW14, 2014 Seoul, Korea.
04/11/17 christophe.debruyne@adaptcentre.ie 50
51. TARQL
• SPARQL for Tables
h>ps://tarql.github.io/
• Use SPARQL CONSTRUCT
queries to transform data in
CSV/TSV into RDF
• Construct queries can be
regarded as rules declaring how
to transform data
• It adopts a W3C standard
(SPARQL), through relies on
some bespoke data
transforma-on func-ons (e.g.,
string explosion)
• But not captured as RDF
CONSTRUCT {
?URI a ex:Organization;
ex:name ?NameWithLang;
ex:CIK ?CIK;
ex:LEI ?LEI;
ex:ticker ?Stock_ticker;
}
FROM <file:companies.csv>
WHERE {
BIND(URI(CONCAT('org/', ?Stock_ticker)) AS ?URI)
BIND(STRLANG(?Name, "en") AS ?NameWithLang)
}
04/11/17 christophe.debruyne@adaptcentre.ie 51
Example from h>ps://tarql.github.io/
54. Fingal County Council Weather Sta-ons
• Example from the h>p://data.gov.ie/ portal
• Create instances of geo:Feature and geo:Geometry from GeoSPARQL
• Use RDFS for labels
• Assume h>p://data.fingalcoco.ie/ as the base URI for the resources and
h>p://www.fingalcoco.ie/ont# as the namespace for predicates specific
for this dataset
04/11/17 christophe.debruyne@adaptcentre.ie 54
Records in fccweathersta-onsp20110829-2221.csv
Name Weather Reading Agency LAT LONG
M50 Blanchardstown h>p://… Na-onal Roads Authority 53.37046603 -6.380851447
M50 Dublin Airport h>p://… Na-onal Roads Authority 53.40964111 -6.227597428
Dublin Airport h>p://… Met Éireann 53.42150608 -6.29784754
56. Tutorial 1
• Add the following namespaces
– rr: h>p://www.w3.org/ns/r2rml#
– fcc: h>p://www.fingalcoco.ie/ont#
– geo: h>p://www.opengis.net/ont/geosparql#
• Create a Triples Map for weather sta-ons, and make the subjects and
instance of geo:Feature and fcc:WeatherSta-on
04/11/17 christophe.debruyne@adaptcentre.ie 56
71. Blank nodes at the OSi
@prefix geo: <http://www.opengis.net/ont/geosparql#> .
@prefix osi: <http://ontologies.geohive.ie/osi#> .
<http://data.geohive.ie/resource/county/2AE19629144F13A3E055000000000001>
a osi:County ;
a geo:Feature ;
rdfs:label "Baile Átha Cliath"@ga ;
rdfs:label "DUBLIN"@en ;
rdfs:label "DUBLIN" ;
geo:hasGeometry [
a geo:Geometry ;
geo:asWKT "MULTIPOLYGON (((-6.1 53.4, ..."^^geo:wktLiteral ;
] ;
.
04/11/17 71
Encourage one to link to features
rather than their geometries, which
are “merely” an a>ribute.
christophe.debruyne@adaptcentre.ie