2. Linked data and RDF Model
Definition
The Web of Data (linked data) is an initiative of the W3C (World Wide Web Consortium) aimed at promoting the publication of structured data on the Web, not in the form of isolated data silos, but by linking them together to form a global network of information.
The aim of the web of data is to put online, in addition to documents, structured data that can be interpreted by computer programmes. Thus, in addition to being a huge media repository, the web is becoming a global database that computer scientists can use to develop applications.
The web of data brings together recommendations describing languages, techniques and models defined by the W3C for publishing structured data on the web. The web of data has two main concepts, which are:
- URIs (Uniform Resource Identifiers) or IRIs (International Resource Identifiers)
- The RDF (Resource Description Framework) model.
A URI extends the URL so that it not only references documents but also any type of entity on the web, called resources. For example:
- https://www.wikidata.org/wiki/Q33977: this URI references Jules Verne, represented as an entity of type «humain» in the Wikidata database.
- https://www.wikidata.org/wiki/Q183565: references Jules Verne’s book «Twenty Thousand Leagues Under the Sea» , represented as an entity of type «literary work» in the Wikidata database.
2.1 Simplifying a URI
To simplify a URI and avoid having to deal with very long links, simply use a prefix followed by :, then the part identifying the entity in question.
For example, the entity https://www.wikidata.org/wiki/Q183565 has the title «Twenty Thousand Leagues Under the Sea».
To simplify, we use, the prefix wd (wd for wikidata) instead of https://www.wikidata.org/wiki/Q183565.
This gives us: wd:Q183565
The information (wd:Q183565, title, Twenty Thousand Leagues Under the Sea) represents an RDF triple, a concept that is defined in the following section.
2.2 Resource Description Framework (RDF)
Definition
Resource Description Framework (RDF) is a graph data model designed to formally describe web resources and their metadata, enabling the automatic processing of such descriptions. Developed by the W3C, RDF is the basic language of the semantic web.
RDF data model is similar to classical conceptual modeling approaches (such as entity–relationship or class diagrams). It is based on the idea of making statements about resources (in particular web resources) in expressions of the form subject–predicate–object, known as triples. The subject denotes the resource; the predicate denotes traits or aspects of the resource, and expresses a relationship between the subject and the object.
The principle of the RDF model is as follows:
- RDF uses properties to link one piece of data to another, or more precisely, to a resource identified by its URI.
- The property is called a predicate.
- The data linked to a resource is called a value or literal value.
- A triple is an RDF statement, written as follows:
(subject, predicate, object) or (URI of a resource, predicate, value)
2.2.1 RDF graphical formalism
RDF has a graphical formalism :
- a node for the subject,
- a directed arc (arrow) from subject to object, representing a predicate (the name of the predicate on the arc),
- a node for the object.
Each of these parts can be identified by a Uniform Resource Identifier (URI). An object can also be a literal value (rectangle). An RDF graph is a set of triples represented according to this formalism.
Example:
The folowing triple (wd:Q183565, title, Twenty Thousand Leagues Under the Sea) can be repsented by this RDF graph :
An RDF graph is a directed graph composed of triple statements. An RDF document is a set of triples. This simple, flexible data model has a lot of expressive power to represent complex situations, relationships, and other things of interest, while also being appropriately abstract.
The nodes in the RDF graph are either URIs or literal values (specified with datatypes). A node can also be a list of URIs sharing the same predicate.
2.2.2 RDF Datatype
The litteral value of an RDF triple can be expressed using datatypes. RDF uses datatypes from the W3C XML Schema (XSD): https://www.w3.org/TR/xmlschema/
For example, to address the int datatype, the URI is: http://www.w3.org/2001/XMLSchema#int or xsd:int
Datatypes include (see figure below) :
- Numbers: xsd:integer, xsd:decimal, xsd:float, xsd:double, xsd:int
- Strings: xsd:string
- Booleans: xsd:boolean
- Dates/Times: xsd:date, xsd:dateTime, xsd:time
- Binary: xsd:hexBinary, xsd:base64Binary
In this specification, built-in datatype can be uniquely addressed via a URI Reference constructed as follows:
- the base URI, is the URI of the XML Schema namespace, simplified using the
xsdprefix - the fragment identifier, is the name of the datatype
Example:
|
|
In this example, the syntax used to represent a literal value is Turtle (it is described later in this course) :
"value"^^xsd:typedesignate the type of value.^^links the literal value to its datatype.
2.3 RDF Schemas (RDFS)
RDF Schemas is a vocabulary extension for the RDF knowledge representation data model, that provides a basic type system and modeling capabilities for describing relationships between resources. While RDF provides the basic structure for making statements (subject-predicate-object triples), RDFS adds the ability to:
- Define classes - Categories of entities, to which resources are associated.
- Define properties - Relationships and attributes (predicates).
- Create hierarchies - Organize classes and properties into parent-child structures (inheritance).
- Add descriptions - Document what entities mean.
Designing an RDF schema involves describing concepts (classes and predicates) and their relationships. Schemas are created from other schemas. This is the role of RDF Schema, designated by the prefix RDFS: https://www.w3.org/2000/01/rdf-schema#
RDFS provides classes and predicates that can be used to describe other classes and predicates. Each class or predicate is identified with a URI.
2.3.1 Defining classes
A class is a category that groups together a set of individuals with the same properties.
A resource is associated with a class using the property rdf:type shorthand by a, and rdfs:subClassOf, meaning that the resource is an instance of a class.
rdf is the prefix of: http://www.w3.org/1999/02/22-rdf-syntax-ns#
Example:
|
|
Thus, in our example from Wikidata:
- The resource https://www.wikidata.org/wiki/Q183565 is an instance of the class
literary work. - The resource https://www.wikidata.org/wiki/Q33977 is an instance of the class
human. - The class
humanis a specialisation of the classperson. It inherits all of its properties.
Observe the page https://www.wikidata.org/wiki/Q33977, which references Jules Verne. The information
instance of humanindicates that this resource is an instance of the classhuman. By clicking onhuman, which is also a resource identified by https://www.wikidata.org/wiki/Q5, we can see that it is asubclass of person. This information is provided by the propertysubclass of.
Example: in Wikidata, the entity human is defined as a specialisation (subclass) of person, and person can be defined as being of type rdfs:class.
2.3.2 Defining predicates
A predicate allows to link a resource to a value. In addition to its name, a predicate has two characteristics:
- The domain: the class of the resource represented, i.e., specifies what class a property applies to.
- The range: the type of value associated with the resource or the class of the resource value (if the value is itself a resource, it is referred to as a resource value), i.e., Specifies what type of value a property can have.
To create a property, we can use rdf:type shorthand by a, and rdfs:subProperty. We must then specify its domain and range.
As with classes, there can be inheritance between predicates.
Example :
|
|
Thus, in the following example :
- The predicate
namehas the classhumanas its domain and the typexsd: stringas its range. - The predicate
writehas the classhumanas its domain and the classliterary workas its range. - The predicate
authoris the specialisation of the propertycreator.
Before creating an RDF schema, we should always check whether there is already a schema that suits the objectives of our application and can be used. Exting vocabularies can be used such as LOV (Linked Open Vocabularies) referencing hundreds of vocabularies, some of which are widely used, such as FOAF, which describes relations between people.
We can see how the properties
rdf:type,rdfs:subClassOfandrdfs:subPropertyare defined repectively in RDF and RDF schemas
2.4 RDF Languages
There are several languages for defining RDF documents or RDF graphs :
- XML language: first language proposed by W3C.
- Advantage: a large number of applications can read or generate files in this format.
- Disadvantage: representation difficult to read and write for non-specialists.
Description of an RDF triple:
- Main tag:
description - URI of the triple:
about - Value of the triple: case of a resource
rdf:resource, case of a literal valuerdf:datatype
- N-triples, Turtle and N3 languages: these languages belong to the same family and are recommended by W3C. The turtle language is the most widely used, as it has the advantage of having a syntax that is easier to write and read.
- Syntax for describing an RDF triple:
Source URI Property URI Value.Case of multiple triples with the same URI as their source:
Source URI Property URI_1 Value_1;
Property URI_2 Value_2;
. . .
Property URI_n Value_n.- JSON language: difficult for humans to read but very well suited to computer processing (format understandable by machines).
2.4.1 Turtle (Terse RDF Triple Language)
Key Turtle syntax elements include :
@prefixdirective used to define namespace prefixes that make URIs shorter and more readableais shorthand forrdf:type" "specifies a value^^specifies a datatype.ends a triple;allows properties to share the same subject,allows objects to share the same subject and predicate( )creates ordered lists[ ]creates blank nodes
Example:
|
|
2.4.2 Comparing the three syntaxes
Here we take the example of the resource (wd:Q33977) referencing Jules Verne in Wikidata, keeping two properties: his first name (wdt:P735) and his occupation (wdt:P106) as a novelist (wd:Q6625963). Novelist is an instance of the class Profession (wd:Q28640).
The turtle syntaxe :
|
|
For more lisibility, we can add labels
|
|
The equivalent XML syntaxe is as follows :
|
|
And in Json :
|
|
By comparing the three syntaxes, we can see that Turtle, although not widely known, is very concise and well-suited to describing RDF triples. XML and JSON are better suited to the automatic processing of data.
2.5. Data inference
Data inference involves the automatic creation of new data from existing data and rules. RDF rules (also called RDF inference rules or entailment rules) are logical rules that allow new facts to be derived from existind data. In the Web of Data, this enables RDF graphs to be completed automatically in order to answer questions, for which answers are not explicit in the initial data. Several rules can be used by search engines on an RDF graph. They are listed in the W3C document.
We have listed some of them below:
| rule | condition | conclusion |
|---|---|---|
| rdfs3 | aaa rdfs:range xxx. AND yyy aaa zzz. |
zzz rdf:type xxx. |
| rdfs7 | aaa rdfs:subPropertyOf bbb. AND xxx aaa yyy. |
xxx bbb yyy. |
| rdfs9 | xxx rdfs:subClassOf yyy. AND zzz rdf:type xxx. |
zzz rdf:type yyy. |
We will discuss the RDF rules and knowledge inference in more detail in the last part of this course: Raisonning and SWRL Language




