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:

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 :

  1. a node for the subject,
  2. a directed arc (arrow) from subject to object, representing a predicate (the name of the predicate on the arc),
  3. a node for the object.

RDF graph RDF graph

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 :

RDF triple RDF triple

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:

  1. the base URI, is the URI of the XML Schema namespace, simplified using the xsd prefix
  2. the fragment identifier, is the name of the datatype

Example:

1
2
3
4
"42"^^xsd:integer
"2025-11-10"^^xsd:date
"Jules"^^xsd:string
"Verne"^^xsd:string

In this example, the syntax used to represent a literal value is Turtle (it is described later in this course) :

  • "value"^^xsd:type designate the type of value. ^^ links the literal value to its datatype.

RDF data type RDF data type

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:

  1. Define classes - Categories of entities, to which resources are associated.
  2. Define properties - Relationships and attributes (predicates).
  3. Create hierarchies - Organize classes and properties into parent-child structures (inheritance).
  4. 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:

1
2
3
:Person a rdfs:Class .
:Student rdfs:subClassOf :Person .
:Professor rdfs:subClassOf :Person .

Thus, in our example from Wikidata:

Observe the page https://www.wikidata.org/wiki/Q33977, which references Jules Verne. The information instance of human indicates that this resource is an instance of the class human. By clicking on human, which is also a resource identified by https://www.wikidata.org/wiki/Q5, we can see that it is a subclass of person. This information is provided by the property subclass 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.

Wiki  Class Human Wiki  Class Human

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:

  1. The domain: the class of the resource represented, i.e., specifies what class a property applies to.
  2. 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 :

1
2
3
:teaches a rdf:Property ;
    rdfs:domain :Professor ;
    rdfs:range :Course .

Thus, in the following example :

  • The predicate name has the class human as its domain and the type xsd: string as its range.
  • The predicate write has the class human as its domain and the class literary work as its range.
  • The predicate author is the specialisation of the property creator.

rdf graph rdf graph

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:subClassOf and rdfs:subProperty are defined repectively in RDF and RDF schemas

2.4 RDF Languages

There are several languages for defining RDF documents or RDF graphs :

  1. 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 value rdf:datatype
  1. 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.
  1. 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 :

  • @prefix directive used to define namespace prefixes that make URIs shorter and more readable
  • a is shorthand for rdf: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:

1
2
3
4
5
6
7
@prefix ex: <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:Alice a foaf:Person ;
         foaf:name "Alice Johnson" ;
         foaf:age "28"^^xsd:integer.  # Alice is a person, whose name is Alice Johnson, and who is 28 years olde.

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 :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@prefix wd: <https://www.wikidata.org/wiki/> .
@prefix wdt: <https://www.wikidata.org/wiki/Property/> 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

# Jules Verne
wd:Q33977 wdt:P735 wd:Q21448857 ;           # Jules Vern's first name is Jules
          wdt:P106 wd:Q6625963 .         # Jules Vern's occupation is novelist

wd:Q6625963 rdf:type wd:Q28640 .         # novelist is an instance of Profession

For more lisibility, we can add labels

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
wd:Q33977 rdfs:label "Jules Verne"@en ;

# The name Jules
wd:Q21448857 rdfs:label "Jules"@en .

# Novelist
wd:Q6625963 rdfs:label "novelist"@en .        

# Profession
wd:Q28640 rdfs:label "Profession"@en .

The equivalent XML syntaxe is as follows :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:wd="http://www.wikidata.org/wiki/"
    xmlns:wdt="http://www.wikidata.org/property/">

    <!-- Jules Verne -->
    <rdf:Description rdf:about="http://www.wikidata.org/wiki/Q33977">
        <wdt:P735 rdf:resource="http://www.wikidata.org/wiki/Q21448857"/>
        <wdt:P106 rdf:resource="http://www.wikidata.org/wiki/Q6625963"/>
    </rdf:Description>

    <!-- Novelist is an instance of Profession -->
    <rdf:Description rdf:about="http://www.wikidata.org/wiki/Q6625963">
        <rdf:type rdf:resource="http://www.wikidata.org/wiki/Q28640"/>
    </rdf:Description>

</rdf:RDF>

And in Json :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "@context": {
    "wd": "https://www.wikidata.org/wiki/",
    "wdt": "https://www.wikidata.org/wiki/Property/",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  },
  "@graph": [
    {
      "@id": "wd:Q33977",
      "wdt:P735": {
        "@id": "wd:Q21448857"
      },
      "wdt:P106": {
        "@id": "wd:Q6625963"
      }
    },
    {
      "@id": "wd:Q6625963",
      "@type": "wd:Q28640"
    }
  ]
}

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