Tordf& Sparql: Training Module 1.3
Tordf& Sparql: Training Module 1.3
Introduction
to RDF &
SPARQL
PwC firms help organisations and individuals create the value they’re looking for. We’re a network of firms in 158 countries with close to 180,000 people who are committed to
delivering quality in assurance, tax and advisory services. Tell us what matters to you and find out more by visiting us at www.pwc.com.
PwC refers to the PwC network and/or one or more of its member firms, each of which is a separate legal entity. Please see www.pwc.com/structure for further details.
This presentation has been created by PwC
Authors:
Michiel De Keyzer, Nikolaos Loutas and Stijn
Goedertier
Presentation
metadata Disclaimers
1.The views expressed in this presentation are purely those of the authors and may not, in any
circumstances, be interpreted as stating an official position of the European Commission.
The European Commission does not guarantee the accuracy of the information included in this
Open Data Support is funded by presentation, nor does it accept any responsibility for any use thereof.
the European Commission Reference herein to any specific products, specifications, process, or service by trade name,
under SMART 2012/0107 ‘Lot trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement,
2: Provision of services for the recommendation, or favouring by the European Commission.
Publication, Access and Reuse of All care has been taken by the author to ensure that s/he has obtained, where necessary,
Open Public Data across the permission to use any parts of manuscripts including illustrations, maps, and graphs, on which
intellectual property rights already exist from the titular holder(s) of such rights or from her/his
European Union, through
or their legal representative.
existing open data
portals’(Contract No. 30-CE- 2.This presentation has been carefully compiled by PwC, but no representation is made or
0530965/00-17). warranty given (either express or implied) as to the completeness or accuracy of the information it
contains. PwC is not liable for the information in this presentation or any decision or consequence
based on the use of it.. PwC will not be liable for any damages arising from the use of the
© 2014 European Commission
information contained in this presentation. The information contained in this presentation is of a
general nature and is solely for guidance on matters of general interest. This presentation is not a
substitute for professional advice on any particular matter. No reader should act on the basis of
any matter contained in this publication without considering appropriate professional advice.
Slide 2
Learning objectives
Slide 3
Content
Slide 4
Resource
Description
Framework
An introduction on RDF.
Slide 5
RDF in the stack of Semantic Web technologies
Slide 6
Where can I find the RDF Specification
http://www.w3.org/RDF/
Slide 7
Example: RDF description of an organisation
<rdf:RDF
<rdf:RDF
xmlns:rdfs=“http://www.w3.org/2000/01/rdf-schema#”
xmlns:rdfs=“http://www.w3.org/2000/01/rdf-schema#”
xmlns:org=“http://www.w3.org/ns/org#”
xmlns:org=“http://www.w3.org/ns/org#”
xmlns:locn=“http://www.w3.org/ns/locn#”
xmlns:locn=“http://www.w3.org/ns/locn#” >
>
<org:Organization
<org:Organization rdf:about=“http://publications.europa.eu/resource/authority/corporate-
rdf:about=“http://publications.europa.eu/resource/authority/corporate-
body/PUBL”>
body/PUBL”>
<rdfs:label>
<rdfs:label> “Publications
“Publications Office”<
Office”< /rdfs:label>
/rdfs:label>
<org:hasSite
<org:hasSite rdf:resource=“http://example.com/site/1234”/>
rdf:resource=“http://example.com/site/1234”/>
</org:Organization>
</org:Organization>
<locn:Address
<locn:Address rdf:about=“http://example.com/site/1234”/>
rdf:about=“http://example.com/site/1234”/>
<locn:fullAddress>”2,
<locn:fullAddress>”2, rue
rue Mercier,
Mercier, 2985
2985 Luxembourg,
Luxembourg, LUXEMBOURG”</locn:fullAddress>
LUXEMBOURG”</locn:fullAddress>
</locn:Address>
</locn:Address>
</rdf:RDF>
</rdf:RDF>
Slide 8
RDF structure
Triples, graphs and syntax.
Slide 9
What is a triple?
Slide 10
RDF is graph based
Graph = Publications
Publications Office
Office
http://open-
http://open-
data.europa.eu/en/data/publisher/publ
data.europa.eu/en/data/publisher/publ
has a publisher
http://publications.europa.eu/resource/a
http://publications.europa.eu/resource/a
uthority/file-type/
uthority/file-type/
has a title
File
File types
types Name
Name Authority
Authority List
List
Slide 11
RDF Syntax
RDF/XML
<rdf:RDF
<dcat:Dataset rdf:about=“http://publications.europa.eu/resource/authority/file-type/”>
<dct:title> “File types Name Authority List”< /dct:title>
Graph
<dct:publisher rdf:resource=“http://open-data.europa.eu/en/data/publisher/publ”/>
</dcat:Dataset>
<dct:Agent rdf:about=“http://open-data.europa.eu/en/data/publisher/publ”/>
<dct:title>”Publications Office”</dct:title>
</dct:Publisher>
Object
Slide 12
RDF Syntax
Turtle
< http://publications.europa.eu/resource/authority/file-type/>
a <dcat:Dataset> ;
Graph
dct:title “File types Name Authority List“;
dct:publisher <http://open-data.europa.eu/en/data/publisher/publ> .
<http://open-data.europa.eu/en/data/publisher/publ>
a <dct:Agent> ; Description of data – triples
dct:title “Publications Office” .
Object
See
Seealso:
also:
http://www.w3.org/2009/12/rdf-ws/papers/ws11
http://www.w3.org/2009/12/rdf-ws/papers/ws11
Slide 13
RDF Syntax
RDFa
Subject
Predicate
Object
See
Seealso:
also:
http://www.w3.org/TR/2012/NOTE-rdfa-primer-20120607/
http://www.w3.org/TR/2012/NOTE-rdfa-primer-20120607/
Slide 14
How to
represent data
in RDF
Classes, properties and vocabularies
Slide 15
RDF Vocabulary
Slide 16
What are classes, relationships and properties?
Slide 17
Examples of classes, relationships and properties
Class
Dataset Agent
a Relationshi
a
p
publisher
http://.../authority/fil
http://.../publisher/publ
e-type/
Property
title title
“Publications Office”
“File types Name Authority List”
Slide 18
Reusing RDF vocabularies
See
Seealso:
also:
https://joinup.ec.europa.eu/community/semic/document/cookbook-transl
https://joinup.ec.europa.eu/community/semic/document/cookbook-transl
ating-data-models-rdf-schemas
ating-data-models-rdf-schemas
http://www.slideshare.net/OpenDataSupport/model-your-data-metadata
http://www.slideshare.net/OpenDataSupport/model-your-data-metadata
Slide 19
Where can I find existing vocabularies?
http://joinup.ec.europa.eu/
Slide 20
See
Seealso:
also:
http://www.w3.org/wiki/TaskForces/CommunityPro
http://www.w3.org/wiki/TaskForces/CommunityPro
jects/LinkingOpenData/CommonVocabularies
jects/LinkingOpenData/CommonVocabularies
Well-known vocabularies
DCAT-AP Vocabulary for describing datasets in Europe
Vocabulary to describe the fundamental characteristics of
Core Person Vocabulary
a person, e.g. the name, the gender, the date of birth...
DOAP Vocabulary for describing projects
Slide 21
Model your own vocabulary as an RDF Schema
See
Seealso:
also:
http://www.slideshare.net/OpenDataSupport/model-your-
http://www.slideshare.net/OpenDataSupport/model-your-
data-metadata
data-metadata
Slide 22
Introduction to
SPARQL
The RDF Query Language
Slide 23
About SPARQL
Slide 24
Types of SPARQL queries
• SELECT
Return a table of all X, Y, etc. satisfying the following conditions ...
• CONSTRUCT
Find all X, Y, etc. satisfying the following conditions ... and substitute
them into the following template in order to generate (possibly new)
RDF statements, creating a new graph.
• DESCRIBE
Find all statements in the dataset that provide information about the
following resource(s) ... (identified by name or description)
• ASK
Are there any X, Y, etc. satisfying the following conditions ...
See
Seealso:
also:
http://www.euclid-project.eu/modules/chapter2
http://www.euclid-project.eu/modules/chapter2
Slide 25
Structure of a SPARQL Query
Slide 26
SELECT – return the name of a dataset with
particular URI
Sample data
<http://.../authority/file-type/>
<http://.../authority/file-type/> rdf:type
rdf:type dcat:Dataset.
dcat:Dataset.
<http://.../authority/file-type/>
<http://.../authority/file-type/> dct:title “File types
dct:title “File types Name
Name Authority
Authority List“
List“ ..
<http://.../authority/file-type/>
<http://.../authority/file-type/> dct:publisher
dct:publisher << http://open-data.europa.eu/en/data/publisher/publ>.
http://open-data.europa.eu/en/data/publisher/publ>.
<< http://.../publisher/publ>
http://.../publisher/publ> rdf:type
rdf:type dct:Agent
dct:Agent ..
<< http://.../publisher/publ>
http://.../publisher/publ> dct:title
dct:title “Publications
“Publications Office”
Office” ..
Query
PREFIX
PREFIX dcat:
dcat: <http://www.w3.org/TR/vocab-dcat/>
<http://www.w3.org/TR/vocab-dcat/>
PREFIX
PREFIX dct:
dct: <http://purl.org/dc/terms/>
<http://purl.org/dc/terms/>
SELECT
SELECT ?dataset
?dataset
WHERE
WHERE
{{
<http://.../authority/file-type/>
<http://.../authority/file-type/> org:hasRegisteredSite
org:hasRegisteredSite ?dataset
?dataset ..
}}
Result
name
Slide 27
SELECT - return the name and publisher of a
dataset
Sample data
<http://.../authority/file-type/>
<http://.../authority/file-type/> rdf:type
rdf:type dcat:Dataset.
dcat:Dataset.
<http://.../authority/file-type/>
<http://.../authority/file-type/> dct:title
dct:title “File
“File types
types Name
Name Authority
Authority List“
List“ ..
<http://.../authority/file-type/>
<http://.../authority/file-type/> dct:publisher
dct:publisher << http://open-data.europa.eu/en/data/publisher/publ>.
http://open-data.europa.eu/en/data/publisher/publ>.
<< http://.../publisher/publ>
http://.../publisher/publ> rdf:type
rdf:type dct:Agent
dct:Agent ..
<< http://.../publisher/publ>
http://.../publisher/publ> dct:title “Publications Office”
dct:title “Publications Office” ..
Query
PREFIX
PREFIX dcat:
dcat: <http://www.w3.org/TR/vocab-dcat/>
<http://www.w3.org/TR/vocab-dcat/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT
SELECT ?dataset
?dataset ?publisher
?publisher
WHERE
WHERE
{http://.../authority/file-type/
{http://.../authority/file-type/ dct:publisher
dct:publisher ?publisherURI.
?publisherURI.
http://.../authority/file-type/
http://.../authority/file-type/ dct:title
dct:title ?dataset.
?dataset.
?publisherURI
?publisherURI dct:title
dct:title ?publisher
?publisher .. }}
Result
dataset pubisher
“File types Name Authority List” “Dahliastraat 24, 2160 Wommelgem”
Slide 28
SPARQL Example – EU ODP (1)
Slide 29
SPARQL Example – EU ODP (2)
Slide 30
SPARQL Example – EU ODP (2)
Slide 31
SPARQL Update
See
Seealso:
also:
http://www.euclid-project.eu/modules/chapter2
http://www.euclid-project.eu/modules/chapter2
http://www.w3.org/TR/sparql11-update/
http://www.w3.org/TR/sparql11-update/
Slide 32
Summary
Slide 33
Group questions
https://open-data.europa.eu/en/linked-data
Slide 34
Thank you!
...and now YOUR
questions?
Slide 35
References
•Resource Description Framework. W3C. http://www.w3.org/RDF/ •SPARQL 1.1 Update. W3C.. http://www.w3.org/TR/sparql11-update/
Slide 36
Further reading
Slide 37
Related projects and initiatives
Joinup, https://joinup.ec.europa.eu/
EUCLID, http://euclid-project.eu/
TopBraid Composer
Slide 38
Be part of our team...
Find us on Join us on
Open Data Support
http://www.slideshare.net/OpenDataSupport
Follow us Contact us
@OpenDataSupport contact@opendatasupport.eu
Slide 39