Giovanni Pirrotta

Just a curious person

Semantic Web Ingredients: the RDF Schema Model

January 06, 2014

In the last post I introduced the RDF Model to define assertions as triple statements. But how does a stupid machine understand what a certain property describing a certain resource means?

The RDF Model provides only a mechanism to describe data as statements, but it can say nothing about the content of the assertion and the properties used in triples. It is clear that something is missing, and here is where the RDF Schema (RDFs) comes into play.

The RDF Schema (RDFs) is the way to describe the meaning of classes and properties to help machines process data efficiently. RDFs Vocabulary extends RDF model to provide primitives to write light schemas for RDF triples allowing describing taxonomies of classes and properties to create and define what is called the ontology of the domain of interest. RDFS provides some constructs to organize classes in a hierarchy providing mechanisms to extend them in subclasses and to create new schemas through incremental changes. The meaning of each resource is expressed through the reference to a specific vocabulary.

Using the RDFS Vocabulary, we can define for example the class Person and the class Book to define the http://example.org/mfowler resource as an instance of the class Person, and the http://example.org/umld resource as an instance of the class Book.

So, we can define the http://example.org/hasAuthor resource as a new property stating that it relates an instance of Book to an instance of Person. One of the interesting features of RDF Schema is the simplicity with which it can be extended by the namespace mechanism. Not only can we use different RDF Schema vocabularies, but we can also extend a standard version without the need of redefining all concepts.

The most important RDFS items to define metadata schemas or ontologies are:

  • rdfs:Resource: it is the class of everything. All things described by RDF are resources, instance of rdfs:Resource.
  • rdfs:Class: the Class resource is one of the most important RDFS vocabulary constructs because it allows to create new classes, as a category or a model, of anything concrete or abstract. It is importan to note the reflexive nature of this resource; instancing a new class using the rdf:type property, the rdfs:Class instances obtained are themselves class objects, then again classes to instantiate.
  • rdfs:Property: this resource is used to instantiate a new property or a new property subclass. Again, also this one, is a rdfs:Resource subclass.
  • rdfs:Literal: an rdfs:Literal is an rdfs:Resource subclass and represents a typed primitive value borrow from XML Schema Datatypes (string, date, float, etc.)
  • rdf:type: the property is used to say that a certain resource, instance of rdfs:Resource is an instance of a certain class. If it is present in the statement predicate, the object resource must be an rdfs:Class resource or an rdfs:Class instance. In the first case the subject resource will be a new class type, otherwise it will be a generic typed class instance.
  • rdfs:subClassOf: the property rdfs:subClassOf is an instance of rdf:Property and it is used to state that all the instances of one class are instances of another. A triple of the form:

    C1 rdfs:subClassOf C2

    states that C1 is an instance of rdfs:Class, C2 is an instance of rdfs:Class and C1 is a subclass of C2. The resource specifies the inheritance relationship between classes and can be a subclass of one or more classes (multiple inheritance).

  • rdfs:domain: used to say that a certain resource, instance of rdfs:Property has domain instances of a certain class. For example, the property identified by the http://example.org/hasAuthor URI, instance of rdfs:Property, has to have as subject type the Book class.
  • rdfs:range: used to say that a certain resource, instance of rdfs:Property, has as range instances of a certain class. For example, the property identified by the http://example.org/hasAuthor URI, instance of rdfs:Property, has to have as object type the Person class.

The following figure represents the relationship graph of the most important RDFS classes:

Image

Let us now see how to apply what we have just described in our previous statement. At the beginning we define two new classes: ex:Book and ex:Person instances of the rdfs:Class resource. Then, we can typify the ex:umld and the ex:mfowler resources, through the rdf:type property. As done with classes, we instanciate the property resources (ex:authorOf, ex:firstname, ex:lastname, ex:title, ex:isbn) as rdfs:Property instances, using again the rdf:type property. Also, we can describe some relations between properties, for example, establishing the domain and the range for the authorOf property. For example, we can explicit the authorOf property that must join instances of Book with instances of Person, and so forth.

Let us show now RDFS Schema serialization. For semplicity I will adopt the N3 notation

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ex: <http://example.org/>.
		
ex:Book rdf:type rdfs:Class.
ex:Person rdf:type rdfs:Class.
		
ex:fistname rdf:type rdfs:Property.
ex:lastname rdf:type rdfs:Property.
ex:title rdf:type rdfs:Property.
ex:isbn rdf:type rdfs:Property.
ex:hasAuthor rdf:type rdfs:Property;
		     rdfs:domain ex:Book;
		     rdfs:range ex:Person.
		
ex:umld rdf:type ex:Book;
		ex:hasAuthor ex:mfowler;
		ex:title "UML Distilled";
		ex:isbn "0201325632".
		
ex:mfowler rdf:type ex:Person;
		   ex:firstname "Martin";
		   ex:lastname "Fowler".

Comments