Ruben Verborgh, Ghent University – imec
Except where otherwise noted, the content of these slides is licensed under a Creative Commons Attribution 4.0 International License.
The Semantic Web isn’t just about putting data on the Web. It is about making links, so that a person or machine can explore the Web of Data.
Tim Berners-Lee
With Linked Data, when you have some of it,
you can find other, related, data.
prefix.cc lists several common ones:
rdf
http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs
http://www.w3.org/2000/01/rdf-schema#
owl
http://www.w3.org/2002/07/owl#
foaf
http://xmlns.com/foaf/0.1/
dbr
http://dbpedia.org/resource/
dbo
http://dbpedia.org/ontology/
Additionally, we will use ex
for examples.
NULL
value can signal missing data,Find the one you need at Linked Open Vocabularies.
We define the triple by its components:
dbr:Tim_Berners-Lee
foaf:knows
dbr:Ted_Nelson
Triples consist of RDF terms as follows:
We define the triple by its components:
dbr:Tim_Berners-Lee
foaf:givenName
Tim
with language en
We define the triple by its components:
dbr:Tim_Berners-Lee
dbo:birthDate
1955-06-08
xsd:date
# Every non-empty line represents a triple or comment.
# IRIs are enclosed in angular brackets (< and >).
<http://dbpedia.org/resource/Tim_Berners-Lee> <http://xmlns.com/foaf/0.1/knows> <http://dbpedia.org/resource/Ted_Nelson>.
# Literals are enclosed in double quotation marks (")
# and optionally end with @ and a language tag.
<http://dbpedia.org/resource/Tim_Berners-Lee> <http://xmlns.com/foaf/0.1/givenName> "Tim"@en.
# Alternatively, they end with ^^ and a datatype IRI.
<http://dbpedia.org/resource/Tim_Berners-Lee> <http://dbpedia.org/ontology/birthDate> "1955-06-08"^^<http://www.w3.org/2001/XMLSchema#date>.
# Declare prefixes before use (hint: prefix.cc).
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
# The predicate a abbreviates rdf:type.
# A semi-colon ; reuses the subject.
# A comma , reuses the subject and predicate.
dbr:Tim_Berners-Lee a foaf:Person;
foaf:knows dbr:Ted_Nelson,
dbr:Wendy_Hall.
# There are 3 triples above.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
# The following lines all state something is named Tim.
_:x235 foaf:name "Tim"@en. # blank node label
[] foaf:name "Tim"@en. # empty blank node
[ foaf:name "Tim"@en ]. # blank node with properties
# Something named Tim knows something named Wendy.
[ foaf:name "Tim"@en ] foaf:knows [ foaf:name "Wendy"@en ].
# The label-based syntax allows cross-references within
# the same document, and is also supported in N-Triples.
PREFIX ex: <http://example.org/>
# Note also a shorthand for writing numbers.
ex:MyLottery ex:luckyNumbers (5 14 15).
# This corresponds to:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
ex:MyLottery ex:luckyNumbers _:list1.
_:list1 rdf:first "5"^^xsd:integer
_:list1 rdf:next _:list2.
_:list2 rdf:first "14"^^xsd:integer
_:list2 rdf:next _:list3.
_:list3 rdf:first "15"^^xsd:integer
_:list3 rdf:next rdf:nil.
# Triples in the default graph look like N-Triples.
<urn:ex:s1> <urn:ex:p1> <urn:ex:o1>.
<urn:ex:s1> <urn:ex:p2> "abc".
# Triples in named graphs have a fourth element.
<urn:ex:s2> <urn:ex:p1> <urn:ex:o2> <urn:ex:GraphA>.
<urn:ex:s2> <urn:ex:p2> "xyz" <urn:ex:GraphB>.
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
# Triples in the default graph look like Turtle.
dbr:Tim_Berners-Lee a foaf:Person;
foaf:knows dbr:Ted_Nelson.
# Named graphs are indicated by a graph statement.
<http://example.org/graphs/Fiction> {
dbr:Clark_Kent a foaf:Person;
foaf:nick "Superman"@en.
}
@context
Link
header.
@id
keyword
points to an identifierapplication/json
with HTTP Link
context: JSON-LDapplication/ld+json
with @context
key: JSON-LD{
"@context": "http://schema.org/",
"@id": "http://dbpedia.org/resource/Tim_Berners-Lee",
"givenName": "Tim",
"knows": [{
"@id": "http://dbpedia.org/resource/Ted_Nelson",
"givenName": "Ted"
}]
}
{
"@context": "http://schema.org/",
"@id": "http://dbpedia.org/resource/Tim_Berners-Lee",
"givenName": "Tim",
"knows": [{
"@id": "http://dbpedia.org/resource/Ted_Nelson",
"givenName": "Ted"
}]
}
# These triples are equivalent to the JSON-LD example.
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX schema: <http://schema.org>
dbr:Ted_Nelson schema:givenName "Ted".
dbr:Tim_Berners-Lee schema:givenName "Tim";
schema:knows dbr:Ted_Nelson.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:schema="http://schema.org/">
<rdf:Description rdf:about="http://dbpedia.org/resource/Ted_Nelson">
<schema:givenName>Ted</schema:givenName>
</rdf:Description>
<rdf:Description rdf:about="http://dbpedia.org/resource/Tim_Berners-Lee">
<schema:givenName>Tim</schema:givenName>
<schema:knows rdf:resource="http://dbpedia.org/resource/Ted_Nelson"/>
</rdf:Description>
</rdf:RDF>
<div vocab="http://xmlns.com/foaf/0.1/" typeof="Person">
<p>
<span property="name">Alice Birpemswick</span>,
(<a property="mbox" href="mailto:alice@example.com">alice@example.com</a>)
</p>
<ul>
<li property="knows" typeof="Person">
<a property="homepage" href="https://example.com/bob/">Bob</a>
</li>
<li property="knows" typeof="Person" resource="https://example.com/people/#eve">
<span property="name">Eve</span>
</li>
</ul>
</div>
[] a foaf:Person;
foaf:name "Alice Birpemswick".
foaf:mbox <mailto:alice@example.com>;
foaf:knows [ a foaf:Person;
foaf:homepage <https://example.com/bob/> ],
<https://example.com/people/#eve>;
<https://example.com/people/#eve> a foaf:Person;
foaf:name "Eve".
rdfs:label
is a property that givesrdfs:label
is not a functional property.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/>
foaf:knows rdfs:label "knows"@en, "kent"@nl, "connaît"@fr.
rdfs:label rdfs:label "label"@en.
rdfs:comment
is a property that clarifiesrdfs:comment
is not a functional property.# rdf, rdfs, and foaf prefixes omitted for brevity
foaf:knows rdfs:label "knows"@en;
rfds:comment "A person known by this person (indicating some level of reciprocated interaction between the parties)."@en.
rdfs:comment rdfs:label "comment"@en;
rdfs:comment "A description of the subject resource."
rdfs:seeAlso
is a property to expressrdfs:seeAlso
.# rdf, rdfs, and foaf prefixes omitted for brevity
foaf:givenName rdfs:seeAlso foaf:familyName.
rdf:type
is a property stating that# rdf, rdfs, and foaf prefixes omitted for brevity
<#me> rdf:type foaf:Person.
rdf:type rdf:type rdf:Property.
# Turtle and TriG allow a in predicate position.
<#me> a foaf:Person.
rdf:type a rdf:Property.
rdfs:Resource
is a class_:x a rdfs:Resource
” holds for all _:x
.# rdf, rdfs, and foaf prefixes omitted for brevity
<#me> a rdfs:Resource.
foaf:Person a rdfs:Resource.
rdfs:Resource a rdfs:Resource.
rdf:type a rdfs:Resource.
# Even literals are resources (Turtle cannot express this).
# "Tim"@en a rdfs:Resource.
rdfs:Class
is a class for resources# rdf, rdfs, and foaf prefixes omitted for brevity
foaf:Person a rdfs:Class.
rdfs:Resource a rdfs:Class.
rdfs:Class a rdfs:Class.
# Classes can serve as objects of rdf:type triples.
<#me> a foaf:Person.
# The following triples are semantically incorrect.
# rdf:seeAlso a rdfs:Class.
# <#me> a rdfs:Class.
rdf:Property
is a class for resources# rdf, rdfs, and foaf prefixes omitted for brevity
foaf:knows a rdf:Property.
rdf:type a rdf:Property.
rdf:Property a rdfs:Class.
# Properties can serve as predicates of triples.
<#Tim> foaf:knows <#Ted>.
# The following triples are semantically incorrect.
# rdfs:Class a rdf:Property.
# rdf:Property a rdf:Property.
rdfs:Literal
is a class for resources# rdf, rdfs, and foaf prefixes omitted for brevity
# Unfortunately, we cannot express this in Turtle.
# "Tim"@en a rdfs:Literal.
# 5 a rdfs:Literal.
# 2.7 a rdfs:Literal.
# The following triples are semantically incorrect.
# foaf:Person a rdfs:Literal.
# rdfs:Literal a rdfs:Literal.
rdfs:subClassOf
is a property stating# rdf, rdfs, and foaf prefixes omitted for brevity
<#ComputerScientist> a rdfs:Class.
foaf:Person a rdfs:Class.
rdfs:Resource a rdfs:Class.
rdfs:Class a rdfs:Class.
<#ComputerScientist> rdfs:subClassOf foaf:Person.
foaf:Person rdfs:subClassOf foaf:Agent.
foaf:Person rdfs:subClassOf rdfs:Resource.
rdfs:Class rdfs:subClassOf rdfs:Resource.
rdfs:domain
is a property that states# rdf, rdfs, and foaf prefixes omitted for brevity
foaf:img rdfs:domain foaf:Person.
foaf:img rdfs:domain rdfs:Resource.
rdf:type rdfs:domain rdfs:Resource.
rdfs:domain rdfs:domain rdf:Property.
rdfs:range
is a property that states# rdf, rdfs, and foaf prefixes omitted for brevity
foaf:img rdfs:range foaf:Image.
foaf:img rdfs:range rdfs:Resource.
rdf:type rdfs:range rdfs:Class.
rdf:type rdfs:range rdfs:Resource.
rdfs:range rdfs:range rdfs:Class.
rdfs:subPropertyOf
is a property stating# rdf, rdfs, and foaf prefixes omitted for brevity
<#hasFriend> rdfs:subPropertyOf foaf:knows.
rdfs:range rdfs:subPropertyOf rdfs:seeAlso.
rdfs:domain rdfs:subPropertyOf rdfs:seeAlso.
In particular, read the following vocabularies:
owl:Thing
.
rdfs:Resource
owl:Class
.
rdfs:Class
ex:Tom a ex:Cat.
ex:Jerry a ex:Mouse.
ex:Tom
and ex:Jerry
are different.owl:sameAs
indicates two resources are the same.
owl:differentFrom
indicates two resources differ.
ex:Tom owl:differentFrom ex:Jerry.
owl:DataTypeProperty
.
foaf:givenName a owl:DataTypeProperty.
foaf:givenName rdfs:range rdfs:Literal.
owl:ObjectProperty
.
foaf:knows a owl:ObjectProperty.
foaf:knows rdfs:range _:NonLiterals.
_:NonLiterals owl:complementOf rdfs:Literal.
owl:inverseOf
anotherex:TimBL foaf:made dbr:World_Wide_Web.
dbr:World_Wide_Web foaf:maker ex:TimBL.
foaf:made owl:inverseOf foaf:maker.
owl:inverseOf
allows connecting such properties.owl:FunctionalProperty
.
ex:Julia ex:hasSpouse ex:Cathy.
ex:hasSpouse a owl:FunctionalProperty.
owl:InverseFunctionalProperty
.
ex:Elisabeth ex:successorOf ex:Philippe.
ex:successorOf a owl:InverseFunctionalProperty.
What is the logical consequence of the following?
ex:Julia ex:hasSpouse ex:Cathy.
ex:Julia ex:hasSpouse ex:John.
ex:hasSpouse a owl:FunctionalProperty.
It might be counterintuitive, but the conclusion is:
ex:Cathy owl:sameAs ex:John.
To arrive at a contradiction, explicitly define inequality:
ex:Cathy owl:differentFrom ex:John.
owl:SymmetricProperty
ex:hasSpouse a owl:SymmetricProperty.
owl:AsymmetricProperty
owl:ReflexiveProperty
owl:IrreflexiveProperty
ex:isMotherOf a owl:IrreflexiveProperty.
owl:TransitiveProperty
owl:isFamilyMemberOf a owl:TransitiveProperty.
ex:Single owl:equivalentClass [ a owl:Class;
owl:intersectionOf (foaf:Person, [
a owl:Class, owl:Restriction;
owl:onProperty ex:hasPartner;
owl:maxCardinality 0
])
].
There are currently 4 read-only query forms:
?name
).PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?name ?person WHERE {
?person a dbo:Artist.
?person foaf:name ?name.
?person dbo:influencedBy dbr:Pablo_Picasso.
}
When the mappings are substituted in the BGP,
the dataset should contain triples as follows:
?person a dbo:Artist.
?person foaf:name ?name.
?person dbo:influencedBy dbr:Pablo_Picasso.
CONSTRUCT
queryASK
query returns a boolean statingDESCRIBE
query returns (non-specified)/sparql?query={query}
withGET
or POST
.
For example, the presence of
<#Tim> foaf:knows <#Wendy>.
foaf:knows rdfs:domain foaf:Person.
will result in an extra triple
<#Tim> a foaf:Person.
For example, the presence of
<#me> ex:hasSpouse <#SignificantOther>.
together with the class restrictions we saw earlier
ensures that the following triple cannot be true:
<#me> a ex:Single.
?name
{ ?x a foaf:Person. }
{ … } => { … }.
I don’t need to fight
to prove I’m right.I don’t need to be forgiven.
The Who – Baba O'Riley