The Resource Description Framework (RDF)
AI4Industry Summer School, July 2023
Antoine Zimmermann, EMSE
RDF is…
A lingua franca for the Web of Data
RDF basics
Identify things
Internationalized Resource Identifiers
How to choose an IRI for something?
1W3C style guide for hypertext: https://www.w3.org/Provider/Style/URI
2W3C Interest group note: https://www.w3.org/TR/cooluris/
Relate things
(subject, predicate, object)
Example:
(http://example.org/data/Laura, subject� http://social.relations.com/loves, predicate� http://exmple.org/data/Helmut) object
Data values
RDF literals
Examples:
"42"^^xsd:integer� "THX 1138"^^xsd:string� "chat"@fr,"chat"@en� "<p>The <em>beautiful</em> literal!</p>"^^rdf:HTML
Unidentified resources
:inside
:myBag
Typical use of blank nodes: n-ary relations
:St-Étienne
174 082
:population
:value
2020
:year
171 057
:value
2015
:year
:population
RDF Serialisation (concrete syntaxes)
The Turtle syntax (1)
<http://www.example.com/test#this>
<http://www.example.com/test#this>� <http://relations.example.com/in>� <http://www.example.com/test#box> .
# This is a comment�@prefix ex: <http://www.example.com/test#> . # end dot!�PREFIX rel: <http://relations.example.com/> # alternative notation (no dot!)�# spaces, newlines, tabs separate elements of a triple:�ex:this rel:in ex:box . # dot ends statement
The Turtle syntax (2)
ex:this rel:date "2019-09-13"^^xsd:date . # normal literal�ex:this rel:name "this"@en . # language-tagged literal�ex:this rel:code "TX32" . # xsd:string can be omitted�ex:this rel:number 42 . # xsd:integer (no quotes)�ex:this rel:sizeInMeters 3.75 . # xsd:decimal (use a dot)�ex:this rel:isGood true . # xsd:boolean�ex:this rel:isBorring false . # xsd:boolean
[] rel:in ex:box .�_:b1 rel:in ex:box . # a blank node identifier…�ex:me rel:likes _:b1 . # ...allows to reuse the same blank node
The Turtle syntax (3)
ex:box rel:contains ex:this .�ex:box rel:contains ex:that .�# can be written�ex:box rel:contains ex:this, ex:that . # comma
ex:this rel:date "2019-09-13"^^xsd:date;� rel:name "this"@en; # new lines are optional� rel:code "TX32";� rel:nextTo ex:that, ex:thoot, ex:thus .
The Turtle syntax (4)
# assume prefixes are declared�ex:johnDoe rel:worksFor [� a ex:University; # the IRI rdf:type can be replaced by 'a'� rel:name "Berkley";� rel:locatedIn ex:California�] .
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>�# other prefixes must be declared�ex:johnDoe rel:worksFor _:bnode .�_:bnode rdf:type ex:University . # 'a' and 'rdf:type' represents the same IRI�_:bnode rel:name "Berkley" .�_:bnode rel:locatedIn ex:California .
The Turtle syntax (5)
@base <http://example.com/base/> . # ends with dot�BASE <http://example.com/base/> # alternative syntax (no dot!)�# prefixes must be declared�<bob> a vocab:Person; # relative IRI� rel:knows <claire> .�BASE <http://example.org/base2#> # base can be redefined�<bob> rel:knows <http://example.com/base/bob> . # different bobs
<http://example.com/base/bob> a vocab:Person;� rel:knows <http://example.com/base/claire> .�<http://example.org/base2#bob>� rel:knows <http://example.com/base/bob> .
RDF Vocabularies
The RDFS vocabulary (1)
The RDF standard defines a generic vocabulary (the RDFS vocabulary) with, notably:
:St-Étienne rdfs:label "Saint-Étienne"@fr .
:St-Étienne rdfs:comment "A city in France."@en .
:St-Étienne rdf:type :City . # equivalent to :St-Étienne a :City
The RDFS vocabulary (2)
The RDFS vocabulary can also declare vocabularies:
:part-of a rdf:Property . # :part-of rdf:type rdf:Property
:City a rdfs:Class .
Working with multiple RDF graphs
Isomorphism As Equivalence Relation
@prefix : <http://example.org/doc.ttl#> .�:St-Étienne :capital :Loire .�:St-Étienne :label "Saint-Étienne"@fr .
@prefix : <http://example.org/doc.ttl#> .�:St-Étienne :label "Saint-Étienne"@fr .�:St-Étienne :capital :Loire .
:Loire
:St-Étienne
:St-Étienne
:Loire
Saint-Étienne
Saint-Étienne
:capital
:capital
:label
:label
Isomorphism As Equivalence Relation
@prefix : <http://example.org/doc.ttl#> .�:St-Étienne :population _:b1 .�_:b1 :value 174082 .�_:b1 :year 2020 .
@prefix : <http://example.org/doc.ttl#> .�:St-Étienne :population _:node1 .�_:node1 :year 2020 .�_:node1 :value 174082 .
:St-Étienne
:population
174 082
:value
2020
:year
:St-Étienne
:population
174 082
:year
2020
:value
Graph and subgraph isomorphism complexity
Merging RDF graphs
:St-Étienne
:population
174 082
:value
2020
:year
+
=
:St-Étienne
:population
171 057
:value
2015
:year
:St-Étienne
:population
171 057
:value
2015
:year
:population
174 082
:value
2020
:year
Encoding and storing multiple graphs
Formats for encoding RDF datasets
Summary
Licensing and acknowledgements
These slides were prepared by Antoine Zimmermann
Some parts are inspired by the slides by Tobias Käfer, Andreas Harth, and Lars Heling under Creative Commons Attribution 4.0 available at https://ai4industry.sciencesconf.org/data/Distributed_Knowledge_Graphs_Pt._2_RDF.pdf
These slides are themselves provided under the same license: CC-BY 4.0 https://creativecommons.org/licenses/by/4.0/
30