Presentation about RDF(S) and SPARQL at the Summer School on Linked Data 4 Smart Cities, in Cercedilla (2015): http://smartcity.linkeddata.es/LD4SC/, organised by the Ontology Engineering Group of Universidad Politécnica de Madrid.
BuildingSMART Standards Summit 2015 - Technical Room - Linked Data for Constr...
Summer School LD4SC 2015 - RDF(S) and SPARQL
1. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
LD4SC Summer School
7th - 12th June, Cercedilla, Spain
1st Summer School on
Smart Cities and Linked Open Data (LD4SC-15)
RDF(S) and SPARQL
Pieter Pauwels, Ghent University
2. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The cool and awesome intro movies
https://vimeo.com/36752317
https://www.youtube.com/watch?v=4x_xzT5eF5Q
2
3. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
3
4. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
RDF graphs, what are they
RDF graphs are DIRECTED, LABELLED GRAPHS
4
P. Pauwels, D. Van Deursen, R. Verstraeten, J. De Roo, R. De Meyer, R. Van de Walle, J. Van Campenhout. A semantic
rule checking environment for building performance checking. Automation in Construction 20(5) 2011, 506-518.
LABELLED
DIRECTED
Triple
5. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
RDF graphs, what are they NOT
Hierarchies (cfr. XML)
Relational databases
(cfr. MySQL, SQLServer)
5
RDF graphs are
DIRECTED, LABELLED
GRAPHS
6. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
A triple
6
Triple
SUBJECT OBJECT
PREDICATE
8. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The result: an RDF graph
8
LABELLED
DIRECTED
Triple
That is it: simple directed labelled graphs, always remember
9. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
9
10. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Talking the RDF language
• RDF stands for Resource Description Framework
• RDF is a standard data model for describing web resources
– Note: ‘web resources’ can make statements about anything in the real
world: DBPedia, geography, building information, sensors, … anything
goes
• RDF is designed to be read and understood by computers
• RDF is not designed for being displayed to people
• RDF is written in XML
• RDF is a W3C Recommendation
10
http://www.w3schools.com/webservices/ws_rdf_intro.asp
easily used
usually
-> standardisation
not a file format,
not a syntax, not a
schema, … => a
data model
11. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The Semantic Web stack
11
Tim Berners-Lee. WWW past & future, 2003. http://www.w3.org/2003/Talks/0922-rsoc-tbl/.
13. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Expressiveness of syntaxes
13
http://www.w3.org/DesignIssues/diagrams/n3/venn
We stick to Turtle today
16. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The same thing in RDF/XML
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:b="http://www.R4SC.net/building#"
xmlns:c="http://www.R4SC.net/city#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-
syntax-ns#">
<rdf:Description rdf:about="http://www.R4SC.net/today#building_1">
<c:partOfCity rdf:resource="http://cities.com/#cercedilla"/>
<b:hasName>Our summer school building</b:hasName>
<b:hasRoom rdf:resource="http://www.R4SC.net/today#room_1"/>
</rdf:Description>
<rdf:Description rdf:about="http://cities.com/#cercedilla">
<c:hasName>Cercedilla</c:hasName>
<c:closeToCity rdf:resource="http://cities.com/#madrid"/>
</rdf:Description>
</rdf:RDF>
16
17. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Convert to different syntaxes
Convert to/from syntaxes:
http://rdf-translator.appspot.com/
Or simply build and use your own software tool
17
18. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
18
19. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Uniform Resource Identifiers
URI
URI
URI
URI
URI
URI
URI
URI
URI
URI
URI
20. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
What is a URI?
• URI stands for Uniform Resource Identifier
• Purpose: Obtain globally unique identifiers, so that information
can be exchanged globally.
• Structure:
<http://www.R4SC.net/today#building_1>
• Namespace needed to avoid name conflicts with tags of the
same name: other tags with the name “building_1” can be
defined with other namespace URIs, and an RDF reader would
still be able to tell that they were different properties even
though they had the same tag name.
20
Namespace Name
21. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Full version of the URIs
<http://www.R4SC.net/today#building_1>
<http://www.R4SC.net/today#room_1>
<http://www.R4SC.net/building#hasRoom >
<http://www.R4SC.net/building#hasName >
<http://www.R4SC.net/city#partOfCity>
<http://www.R4SC.net/city#closeToCity>
<http://www.R4SC.net/city#hasName>
<http://cities.com/#cercedilla>
<http://cities.com/#madrid>
21
35. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Similar yet distinct
@prefix b: <http://www.R4SC.net/building#> .
@prefix c: <http://www.R4SC.net/city#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema>.
<http://www.R4SC.net/today#building_1>
b:hasName “Our summer school building” ,
“Our summer school building”@en ,
“Our summer school building”^^xsd:string
35
Untyped
Typed
Literal with
language setting Referring to type
within specific
namespace
36. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
What is available in xsd
36
http://www.w3.org/TR/xmlschema-2/
37. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
What is available in xsd
37
http://www.xml.dvint.com/docs/SchemaDataTypesQR-2.pdf
38. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
If you do not like xsd...
Simply define your own datatypes…
@prefix b: <http://www.R4SC.net/building#> .
@prefix c: <http://www.R4SC.net/city#> .
@prefix dt: < http://www.R4SC.net/todaysdts#> .
<http://www.R4SC.net/today#building_1>
b:hasName “Our summer school building”^^dt:myTypeOfString
39. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
39
40. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Repeating properties
• I have a property that can have multiple values,
now what?
– Solution 1: Simply repeat the property of the
resource multiple times.
– Solution 2: Use a structured value for a literal
– Solution 3: Use an RDF Container (Sequence, Bag,
or Alt) or Collection (RDF List)
http://patterns.dataincubator.org/book/repeated-property.html
42. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Example for solution 2: Use a
structured value for a literal
@prefix b: <http://www.R4SC.net/building#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://www.R4SC.net/today#room_1>
b:hasPeopleInside “IRECOGNIZETHIS:PieterPauwels; IRECOGNIZETHIS:
RaulGarciaCastro; IRECOGNIZETHIS:AsuncionGomezPerez; IRECOGNIZETHIS:
MariaPovedaVillalon; IRECOGNIZETHIS: FilipRadulovic”
=> NOT recommended!!
44. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
So, what are our options for solution 3?
• Apart from resources and literals, it is also
possible to describe ‘containers’ and
‘collections’
• Containers
– Bags
– Sequences
– Alt
• Collections
– Lists
used to describe groups that can
ONLY contain the specified
members
used to describe an open groups
of things (unknown length)
45. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Bags – Seqs – Alts ??
• Bag
– Unordered
– Resources or literals
– Duplicate values are permitted
• Sequence (Seq)
– Ordered
– Resources or literals
– Duplicate values are permitted
• Alternative (Alt)
– Unordered
– Resources or literals
– Alternatives for a single property value (cfr. language alternatives)
These are the conventions / they are ‘just’ conventions
46. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
List
• List
– Ordered
– Resources or literals
– Duplicate values are permitted
– Closed collection – length of list is known
• So, identical to a sequence, except that the
collection is closed: only the listed items are in
the List, nothing else
47. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Back to our example
@prefix b: <http://www.R4SC.net/building#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://www.R4SC.net/today#room_1>
b:hasPeopleInside ( <http://www.R4SC.net/today#PieterPauwels>
<http://www.R4SC.net/today#RaulGarciaCastro>
<http://www.R4SC.net/today#AsuncionGomezPerez>
<http://www.R4SC.net/today#MariaPovedaVillalon>
<http://www.R4SC.net/today#FilipRadulovic> )
49. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Repeating properties
• I have a property that can have multiple values,
now what?
– Solution 1: Simply repeat the property of the
resource multiple times. Repeating properties is the
simplest approach to handling multi-valued
relations. The alternatives all have their downsides.
– Solution 2: Use a structured value for a literal
– Solution 3: Use an RDF Container (Sequence, Bag,
or Alt) or Collection (RDF List)
http://patterns.dataincubator.org/book/repeated-property.html
50. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Wait a second…
Did you say ‘blank nodes’?
51. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
What are blank nodes?
• Blank nodes are nodes that do not have URIs
– No URI -> no semantics really -> unstable and unreliable
• They are usually represented as: _:1, _:city,
_:thiscanbeanythingyouwishfor, _:8936fazGUID, …
• This representation is typically generated on-the-fly so
that it is unique within the scope in which an RDF
graph is opened
– When opening this RDF graph the following day, even in the
same scope, entirely different names might be generated
– Unstable and unreliable
51
52. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
So, why do we use these blank nodes?
• Simply because it is hard to give everything an explicit name, this is not always
wanted / desirable
• For example:
@prefix b: <http://www.R4SC.net/building#> .
@prefix c: <http://www.R4SC.net/city#> .
@prefix region: <http://www.R4SC.net/region#> .
<http://www.R4SC.net/today#building_1>
b:hasRoom <http://www.R4SC.net/today#room_1> ;
b:hasName “Our summer school building";
c:partOfCity <http://cities.com/#cercedilla> ;
c:partOfRegion [ region:location “NorthOfMadrid”; region:regiontype “Forest”]
• Likewise, people do not intend to define names for all kinds of groups of things ->
hence a lot of blank nodes in descriptions of collections and containers
52
Blank node
53. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
53
54. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Data integration now possible
MyBuilding Cities
56. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Linked Open Data Cloud
• http://lod-cloud.net/
• datasets that have been published in Linked Data format, by
contributors to the Linking Open Data community project and
other individuals and organisations
• based on metadata collected and curated by contributors to
the Data Hub as well as on metadata extracted from a crawl of
the Linked Data web conducted in April 2014
• Attribution: Linking Open Data cloud diagram 2014, by Max
Schmachtenberg, Christian Bizer, Anja Jentzsch and Richard
Cyganiak. http://lod-cloud.net/
65. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Circle sizes and arrow fonts
• Depending on the size of the dataset and the
number of triples between datasets, the layout
in the LOD cloud schema is different.
66. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Data integration now possible
MyBuilding Cities
67. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Status and statistics
• Cumulative stats:
http://stats.lod2.eu/
• State of the LOD cloud 2014:
http://linkeddatacatalog.dws.informatik.uni-
mannheim.de/state/
• State of the LOD cloud 2011:
http://lod-cloud.net/state/
69. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Stats - Datasets by topical domain
http://linkeddatacatalog.dws.informatik.uni-mannheim.de/state/
Topic Datasets %
Government 183 18.05%
Publications 96 9.47%
Life sciences 83 8.19%
User-generated content 48 4.73%
Cross-domain 41 4.04%
Media 22 2.17%
Geographic 21 2.07%
Social web 520 51.28%
Total 1014
70. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Stats - Categorization by number of
linked datasets
Number of linked datasets Number of datasets
more than 10 79 (7.79%)
6 to 10 81 (7.99%)
5 31 (3.06%)
4 42 (4.14%)
3 54 (5.33%)
2 106 (10.45%)
1 176 (17.36%)
0 445 (43.89%)
http://linkeddatacatalog.dws.informatik.uni-mannheim.de/state/
71. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Can my dataset be included?
First, make sure that you publish data according to the Linked
Data principles. We interpret this as:
• There must be resolvable http:// (or https://) URIs.
• They must resolve, with or without content negotiation,
to RDF data in one of the popular RDF formats (RDFa,
RDF/XML, Turtle, N-Triples).
• The dataset must contain at least 1000 triples.
• The dataset must be connected via RDF links to a dataset
that is already in the diagram. This means, either your
dataset must use URIs from the other dataset, or vice
versam. We arbitrarily require at least 50 links.
• Access of the entire dataset must be possible via RDF
crawling, via an RDF dump, or via a SPARQL endpoint.
Then, add it to the Data Hub and request to be included
72. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The resolvable URIs
Hold on, what do you mean, ‘resolvable’?
73. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Reminder: What is a URI?
• URI stands for Unique Resource Identifier
• Purpose: Obtain globally unique identifiers, so that information
can be exchanged globally.
• Structure:
<http://www.R4SC.net/today#building_1>
• Namespace needed to avoid name conflicts with tags of the
same name: other tags with the name “building_1" can be
defined with other namespace URIs, and an RDF reader would
still be able to tell that they were different properties even
though they had the same tag name.
73
Namespace Name
74. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
What do you mean… resolvable?
• A resolvable URI is:
“A URI whose resource has one or more representations available via invoking HTTP GET
on the URI”
(source: http://www.w3.org/TR/2010/WD-sparql11-http-rdf-update-20100126/)
74
http://www.w3.org/TR/cooluris/#oldweb
76. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
So, you are now ready to publish here
77. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Note: the O in LOD
• This does NOT mean that RDF is “OPEN” by
default
• Most datasets in the LOD cloud have licence
information attached
• This does NOT mean that RDF is “OPEN” by
default
78. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
78
79. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
What did we do so far?
@prefix b: <http://www.R4SC.net/building#> .
@prefix c: <http://www.R4SC.net/city#> .
<http://www.R4SC.net/today#building_1>
b:hasRoom <http://www.R4SC.net/today#room_1> ;
b:hasName “Our summer school building";
c:partOfCity <http://cities.com/#cercedilla> .
<http://cities.com/#cercedilla>
c:closeToCity <http://cities.com/#madrid> ;
c:hasName “Cercedilla” .
79
80. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The Semantic Web stack
80
Tim Berners-Lee. WWW past & future, 2003. http://www.w3.org/2003/Talks/0922-rsoc-tbl/.
81. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The RDF namespace
@prefix rdf: http://www.w3.org/1999/02/22-
rdf-syntax-ns#
83. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
We have actually already used it
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:b="http://www.R4SC.net/building#"
xmlns:c="http://www.R4SC.net/city#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-
syntax-ns#">
<rdf:Description rdf:about="http://www.R4SC.net/today#building_1">
<c:partOfCity rdf:resource="http://cities.com/#cercedilla"/>
<b:hasName>Our summer school building</b:hasName>
<b:hasRoom rdf:resource="http://www.R4SC.net/today#room_1"/>
</rdf:Description>
<rdf:Description rdf:about="http://cities.com/#cercedilla">
<c:hasName>Cercedilla</c:hasName>
<c:closeToCity rdf:resource="http://cities.com/#madrid"/>
</rdf:Description>
</rdf:RDF>
83
84. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Need for structured vocabularies
• RDF graphs -> could be anything
• Need for semantics / structured vocabularies
RDFSchema (RDFS)
Web Ontology Language (OWL)
85. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The Semantic Web stack
85
Tim Berners-Lee. WWW past & future, 2003. http://www.w3.org/2003/Talks/0922-rsoc-tbl/.
86. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The RDFS namespace
@prefix rdfs: http://www.w3.org/2000/01/rdf-schema#
92. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Example TTL graph
-> unambiguous / meaningful semantics
93. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
93
94. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The Semantic Web stack
94
Tim Berners-Lee. WWW past & future, 2003. http://www.w3.org/2003/Talks/0922-rsoc-tbl/.
95. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
So, it’s also just an RDF graph…
95
http://www.w3.org/DesignIssues/diagrams/n3/venn
We stick to Turtle today
Let’s just quietly extend towards SPARQL
as well
96. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
96
97. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
What is SPARQL
• SPARQL stands for SPARQL Protocol and RDF Query Language
• SPARQL is a Query Language
• Find the W3C Recommendation page:
http://www.w3.org/TR/rdf-sparql-query/
– Used to express queries across diverse data sources, whether the data is
stored natively as RDF or viewed as RDF via middleware.
– SPARQL contains capabilities for querying required and optional graph
patterns along with their conjunctions and disjunctions.
– SPARQL supports extensible value testing and constraining queries by
source RDF graph.
– The results of SPARQL queries can be results sets or RDF graphs.
98. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The inspiration: SQL
select A1, A2, ..., An
from r1, r2, ..., rm
where P
99. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
SPARQL template
prefix a:…
select concepts
from datasources
where { statements }
order by …
100. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Structure of a SPARQL query
• Prefix declarations
Used to abbreviate URIs
• Dataset definition
Used to state what RDF graph(s) are being queried
• A result clause
Used to identify what information to return from the
query
• The query pattern
Used to specify what to query for in the underlying
dataset
• Query modifiers, slicing, ordering, and otherwise
Used to rearrange query results (post-processing)
103. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Processing the WHERE statement
section
• A pattern is matched against the RDF data
• “find a set of bindings such that the substitution
of variables for values creates a triple that is in
the set of triples making up the graph”
• Source:
http://www.w3.org/2004/Talks/17Dec-
sparql/QueryLang1/all.html
105. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The Query Result
city2
<http://cities.com/#madrid>
106. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
106
107. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Example SPARQL endpoint on DBPedia
The HTTP Address of the
endpoint
The software used in the
server to store the triples
(cfr. DBMS)
Diverse options to set
108. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Try it
Try it out on the DBPedia dataset:
http://dbpedia.org/sparql
Or even better: host one yourself and make it available
108
109. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– More details
• Concluding Overview
109
118. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
ORDER BY
RDF data:
@prefix b: <http://www.R4SC.net/building#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://www.R4SC.net/today#room_1>
b:hasPersonInside “PieterPauwels" , “RaulGarciaCastro" , “AsuncionGomezPerez" ,
“MariaPovedaVillalon", “FilipRadulovic" .
Query
PREFIX b: <http://www.R4SC.net/building#>
SELECT ?name
WHERE { ?x b:hasPersonInside ?name }
LIMIT 2 ORDER BY DESC(?name)
Result
name
“RaulGarciaCastro"
“PieterPauwels"
119. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
DISTINCT Keyword
RDF data:
@prefix b: <http://www.R4SC.net/building#> .
@prefix : <http://www.R4SC.net/today#> .
:room_1 b:hasPresentation [ b:hasPresentationTitle “RDF(S) and SPARQL" ] .
:room_1 b:hasPresentation [ b:hasPresentationTitle “Handson session Generate your RDF”; b:startsAt
“14:30:00”^^xsd:time ] .
:room_1 b:hasPresentation [ b:hasPresentationTitle “Handson session Generate your RDF”; b:startsAt
“17:00:00”^^xsd:time ] .
Query
PREFIX b: < http://www.R4SC.net/building# >
SELECT DISTINCT ?title
WHERE { ?x b:hasPresentationTitle ?title}
Result
title
“RDF(S) and
SPARQL"
“Handson session
Generate your RDF"
120. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
UNION Keyword
RDF data:
@prefix b: <http://www.R4SC.net/building#> .
@prefix : <http://www.R4SC.net/today#> .
:room_1 b:hasPresentation [ b:hasPresentationTitle “RDF(S) and SPARQL" ] .
:room_1 b:hasPresentation [ b:hasPresentationTitle “Handson session Generate your RDF”; b:startsAt
“14:30:00”^^xsd:time ] .
:room_1 b:hasPresentation [ b:hasPresentationTitle “Handson session Generate your RDF”; b:startsAt
“17:00:00”^^xsd:time ] .
_:x1 b:presentation “Linking Data” .
Query
@prefix b: <http://www.R4SC.net/building#> .
@prefix : <http://www.R4SC.net/today#> .
SELECT DISTINCT ?title_1 ?title_2
WHERE {
{ ?p b:hasPresentationTitle ?title_1 }
UNION
{ ?p1 b:presentation ?title_2 }
}
title
“RDF(S) and
SPARQL"
“Handson session
Generate your RDF"
“Linking Data”
Result
121. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
But well, the only way to learn it…
Try it out, for example, on the DBPedia dataset:
http://dbpedia.org/sparql
Or even better: host one yourself and make it available
121
122. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
Index
• RDF graphs: the simple basis
• Syntax: talking the talk
– URIs
– RDF Statements
– Literals
– Collections and containers
• Linked (Open) Data Cloud
• Adding basic structure : RDFS
• Querying: SPARQL
– The basis
– The SPARQL endpoint
– Some more complex examples
• Concluding Overview
122
123. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
The Semantic Web stack
123
Tim Berners-Lee. WWW past & future, 2003. http://www.w3.org/2003/Talks/0922-rsoc-tbl/.
124. LD4SC Summer School
7th - 12th June, Cercedilla, Spain
LD4SC Summer School
7th - 12th June, Cercedilla, Spain
1st Summer School on
Smart Cities and Linked Open Data (LD4SC-15)
Thank you for your attention!
pipauwel.pauwels@ugent.be