RDF Explained

RDF Introduction

RDF stands for 'Resource Description Framework. The Web provides a simple and universal infrastructure to exchange various kinds of information. In order to share, interpret, and manipulate information worldwide, the role of metadata is widely recognized. Indeed, metadata allow us to easily locate information available in the Web, by providing descriptions about the structure and the content of the various Web resources (e.g. data, documents, images, etc.) and for different purposes. The emergence of the Resource Description Framework (RDF) is expected to enable metadata interoperability across different communities or applications by supporting common conventions about metadata syntax, structure, and semantics. More precisely, it provides a) a Standard Representation Language for Web metadata; and b) a Schema Definition Language (RDFS) to interpret (meta)data using specific class and property hierarchies (i.e. vocabularies). Moreover, RDF/RDFS offer a syntax for representing metadata and schemas in XML, enabling the creation and exchange of RDF descriptions in a both human readable and machine understandable form. Many information providers like ABC News, CNN and Time Inc., Web portals like Open Directory as well as Web browsers like Netscape, and search engines like Altavista, Yahoo and Webcrawler already support the RDF proposal. RDF is based on a directed graph model that alludes to the semantics of resource description.

 The basic idea is that a Resource (identified by a URI) can be described through a collection of Statements forming a so-called RDF Description. A specific resource together with a named property and its value is an RDF statement. RDFS schemas are then used to declare vocabularies, i.e. collections of classes and properties, that can be used in resource descriptions for a specific purpose or domain. How to represent RDF RDF describes the interrelationships among resources in terms of named properties and values. These named properties may be thought of as attributes of resources and in this sense correspond to traditional attribute-value pairs. One main difference is that properties defined in RDF only identified by their name (URI) and not like in other object models, where attributes are identified by their name plus the domain class they can describe. So, properties have a URI and therefore are also resources. The value of a property can be another resource or a literal. A literal is simple string or other primitive data type as defined by [XML]. RDF provides three representations of the RDF data model namely: ·

 RDF Graph – a syntax-neutral graphical description of the data ·

RDF 3-tuples – the set of statements described in triples ·

RDF Syntax – provides some standard ways for describing data using XML The RDF constructs and further nomenclature will be explained within the section 0. For the other two models I just explain the way of thinking and their underlying notion. .

What is RDF?

  • RDF stands for Resource Description Framework
  • RDF is a framework for describing resources on the web
  • RDF is designed to be read and understood by computers
  • RDF is not designed for being displayed to people
  • RDF is written in XML
  • RDF is a part of the W3C's Semantic Web Activity
  • RDF is a W3C Recommendation

RDF - Examples of Use

  • Describing properties for shopping items, such as price and availability
  • Describing time schedules for web events
  • Describing information about web pages (content, author, created and modified date)
  • Describing content and rating for web pictures
  • Describing content for search engines
  • Describing electronic libraries

RDF is Designed to be Read by Computers

RDF was designed to provide a common way to describe information so it can be read and understood by computer applications.

RDF descriptions are not designed to be displayed on the web.


RDF is Written in XML

RDF documents are written in XML. The XML language used by RDF is called RDF/XML.

By using XML, RDF information can easily be exchanged between different types of computers using different types of operating systems and application languages.

SRDF and "The Semantic Web"

The RDF language is a part of the W3C's Semantic Web Activity. W3C's "Semantic Web Vision" is a future where:

  • Web information has exact meaning
  • Web information can be understood and processed by computers
  • Computers can integrate information from the web

RDF uses Web identifiers (URIs) to identify resources.

RDF describes resources with properties and property values.

RDF Resource, Property, and Property Value

RDF identifies things using Web identifiers (URIs), and describes resources with properties and property values.

Explanation of Resource, Property, and Property value:

  • A Resource is anything that can have a URI, such as "http://www.w3schools.com/rdf"
  • A Property is a Resource that has a name, such as "author" or "homepage"
  • A Property value is the value of a Property, such as "Jan Egil Refsnes" or "http://www.w3schools.com" (note that a property value can be another resource)

The following RDF document could describe the resource "http://www.w3schools.com/rdf":

<?xml version="1.0"?>

<RDF>
  <Description about="http://www.w3schools.com/rdf">
    <author>Jan Egil Refsnes</author>
    <homepage>http://www.w3schools.com</homepage>
  </Description>
</RDF>

RDF Statements

The combination of a Resource, a Property, and a Property value forms a Statement (known as the subject, predicate and object of a Statement).

Let's look at some example statements to get a better understanding:

Statement: "The author of http://www.w3schools.com/rdf is Jan Egil Refsnes".

  • The subject of the statement above is: http://www.w3schools.com/rdf
  • The predicate is: author
  • The object is: Jan Egil Refsnes

Statement: "The homepage of http://www.w3schools.com/rdf is http://www.w3schools.com".

  • The subject of the statement above is: http://www.w3schools.com/rdf
  • The predicate is: homepage
  • The object is: http://www.w3schools.com

RDF Example

Here are two records from a CD-list:

Title Artist Country Company Price Year
Empire Burlesque Bob Dylan USA Columbia 10.90 1985
Hide your heart Bonnie Tyler UK CBS Records 9.90 1988

Below is a few lines from an RDF document:

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Empire Burlesque">
  <cd:artist>Bob Dylan</cd:artist>
  <cd:country>USA</cd:country>
  <cd:company>Columbia</cd:company>
  <cd:price>10.90</cd:price>
  <cd:year>1985</cd:year>
</rdf:Description>

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Hide your heart">
  <cd:artist>Bonnie Tyler</cd:artist>
  <cd:country>UK</cd:country>
  <cd:company>CBS Records</cd:company>
  <cd:price>9.90</cd:price>
  <cd:year>1988</cd:year>
</rdf:Description>
.
.
.
</rdf:RDF>

The first line of the RDF document is the XML declaration. The XML declaration is followed by the root element of RDF documents: <rdf:RDF>.

The xmlns:rdf namespace, specifies that elements with the rdf prefix are from the namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#".

The xmlns:cd namespace, specifies that elements with the cd prefix are from the namespace "http://www.recshop.fake/cd#".

The <rdf:Description> element contains the description of the resource identified by the rdf:about attribute.

The elements: <cd:artist>, <cd:country>, <cd:company>, etc. are properties of the resource.


RDF Main Elements

The main elements of RDF are the root element, <RDF>, and the <Description> element, which identifies a resource.


The <rdf:RDF> Element

<rdf:RDF> is the root element of an RDF document. It defines the XML document to be an RDF document. It also contains a reference to the RDF namespace:

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  ...Description goes here...
</rdf:RDF>


The <rdf:Description> Element

The <rdf:Description> element identifies a resource with the about attribute.

The <rdf:Description> element contains elements that describe the resource:

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Empire Burlesque">
  <cd:artist>Bob Dylan</cd:artist>
  <cd:country>USA</cd:country>
  <cd:company>Columbia</cd:company>
  <cd:price>10.90</cd:price>
  <cd:year>1985</cd:year>
</rdf:Description>

</rdf:RDF>

The elements, artist, country, company, price, and year, are defined in the http://www.recshop.fake/cd# namespace. This namespace is outside RDF (and not a part of RDF). RDF defines only the framework. The elements, artist, country, company, price, and year, must be defined by someone else (company, organization, person, etc).


Properties as Attributes

The property elements can also be defined as attributes (instead of elements):

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Empire Burlesque"
cd:artist="Bob Dylan" cd:country="USA"
cd:company="Columbia" cd:price="10.90"
cd:year="1985" />

</rdf:RDF>


Properties as Resources

The property elements can also be defined as resources:

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Empire Burlesque">
  <cd:artist rdf:resource="http://www.recshop.fake/cd/dylan" />
  ...
  ...
</rdf:Description>

</rdf:RDF>

In the example above, the property artist does not have a value, but a reference to a resource containing information about the artist.

RDF Container Elements

RDF containers are used to describe group of things.

The following RDF elements are used to describe groups: <Bag>, <Seq>, and <Alt>.


The <rdf:Bag> Element

The <rdf:Bag> element is used to describe a list of values that do not have to be in a specific order.

The <rdf:Bag> element may contain duplicate values.

Example

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Beatles">
  <cd:artist>
    <rdf:Bag>
      <rdf:li>John</rdf:li>
      <rdf:li>Paul</rdf:li>
      <rdf:li>George</rdf:li>
      <rdf:li>Ringo</rdf:li>
    </rdf:Bag>
  </cd:artist>
</rdf:Description>

</rdf:RDF>


The <rdf:Seq> Element

The <rdf:Seq> element is used to describe an ordered list of values (For example, in alphabetical order).

The <rdf:Seq> element may contain duplicate values.

Example

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Beatles">
  <cd:artist>
    <rdf:Seq>
      <rdf:li>George</rdf:li>
      <rdf:li>John</rdf:li>
      <rdf:li>Paul</rdf:li>
      <rdf:li>Ringo</rdf:li>
    </rdf:Seq>
  </cd:artist>
</rdf:Description>

</rdf:RDF>


The <rdf:Alt> Element

The <rdf:Alt> element is used to describe a list of alternative values (the user can select only one of the values).

Example

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Beatles">
  <cd:format>
    <rdf:Alt>
      <rdf:li>CD</rdf:li>
      <rdf:li>Record</rdf:li>
      <rdf:li>Tape</rdf:li>
    </rdf:Alt>
  </cd:format>
</rdf:Description>

</rdf:RDF>

RDF Terms

In the examples above we have talked about "list of values" when describing the container elements. In RDF these "list of values" are called members.

So, we have the following:

  • A container is a resource that contains things
  • The contained things are called members (not list of values)

 

RDF/XML

RDF consists of a model, which is a graph representation of data. RDF/XML is an XML language which can be used to represent RDF data. It contains a fairly simple set of elements. The sample below shows a simple RDF template.

<?xml version="1.0"?>
<RDF:RDF
  xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  ...
</RDF:RDF>

                      

This has some similarities to the XUL header. Instead of the window element, the RDF element is used. You can see the namespace for RDF was declared so that the RDF elements are recognized properly. Inside, the RDF element, you will place the data. To see some example RDF/XML files, look at those provided with Mozilla. They have the extension rdf.

RDF database

Let's take the example of a bookmarks list generated from RDF. A bookmarks list contains a set of records, each with a set of data associated with it, such as a URL, a bookmark title and a visited date.

Think of the bookmarks as a database, which is stored as a large table with numerous fields. In the case of RDF however, the lists may be hierarchical as well. This is necessary so that we can have folders or categories of bookmarks. Each of the fields in an RDF database is a resource, each with a name associated with it. The name is described by a URI.

For example, a selection of the fields in the Mozilla bookmark list is described by the URIs below:

Name http://home.netscape.com/NC-rdf#Name Bookmark name
URL http://home.netscape.com/NC-rdf#URL URL to link to
Description http://home.netscape.com/NC-rdf#Description Bookmark description
Last Visited http://home.netscape.com/WEB-rdf#LastVisitDate Date of last visit

I’ll summarize the points from the post:

1) Don’t use RDF for every job.
2) RDF is good for data models.
3) RDF isn’t good for value-intensive operations.
4) Schemalessness is good, whether this is derived from a graph or a KV/whatever approach (cf. http://martinfowler.com/articles/schemaless/)
5) People have issues using RDF because they are used to value-oriented, schema-driven technologies.
6) RDF is difficult to work with because it is unfamiliar and logically complex.
7) Most people don’t want a data tool, they want a database/KV-store.
8) Using an RDF model is smart for an application developer.
9) RDF needs to be used in conjunction with other technologies to usefully do value-oriented things.

RDF Collections

RDF collections describe groups that can ONLY contain the specified members.


The rdf:parseType="Collection" Attribute

As seen in the previous chapter, a container says that the containing resources are members - it does not say that other members are not allowed.

RDF collections are used to describe groups that can ONLY contain the specified members.

A collection is described by the attribute rdf:parseType="Collection".

Example

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://recshop.fake/cd#">

<rdf:Description
rdf:about="http://recshop.fake/cd/Beatles">
  <cd:artist rdf:parseType="Collection">
    <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/George"/>
    <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/John"/>
    <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Paul"/>
    <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Ringo"/>
  </cd:artist>
</rdf:Description>

</rdf:RDF>

RDF Schema (RDFS)

RDF Schema (RDFS) is an extension to RDF.


RDF Schema and Application Classes

RDF describes resources with classes, properties, and values.

In addition, RDF also needs a way to define application-specific classes and properties. Application-specific classes and properties must be defined using extensions to RDF.

One such extension is RDF Schema.


RDF Schema (RDFS)

RDF Schema does not provide actual application-specific classes and properties.

Instead RDF Schema provides the framework to describe application-specific classes and properties.

Classes in RDF Schema are much like classes in object oriented programming languages. This allows resources to be defined as instances of classes, and subclasses of classes.


RDFS Example

The following example demonstrates some of the RDFS facilities:

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base="http://www.animals.fake/animals#">

<rdf:Description rdf:ID="animal">
  <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
</rdf:Description>

<rdf:Description rdf:ID="horse">
  <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
  <rdfs:subClassOf rdf:resource="#animal"/>
</rdf:Description>

</rdf:RDF>

In the example above, the resource "horse" is a subclass of the class "animal".


Example Abbreviated

Since an RDFS class is an RDF resource we can abbreviate the example above by using rdfs:Class instead of rdf:Description, and drop the rdf:type information:

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base="http://www.animals.fake/animals#">

<rdfs:Class rdf:ID="animal" />

<rdfs:Class rdf:ID="horse">
  <rdfs:subClassOf rdf:resource="#animal"/>
</rdfs:Class>

</rdf:RDF>