An Introduction to RDF

Ian Davis, <ian.davis@talis.com>

Technical Lead, Research Group

Talis Information Ltd.

(Note: click background or use left/right cursors to navigate this presentation. Home and End keys take you to the start/end)

What is RDF?

Layer Cake?

Layer Cake

Some History

Motivations

Goal

To allow anyone to say anything about anything

The Relational Model

A typical relational database table for books

The Relational Model

The rows represent the things you are storing information about

The Relational Model

The columns represent the properties or attributes of those things

The Relational Model

The intersection gives the value of that property for that thing

The Relational Model

the book has a title with value "Javascript"

The Relational Model

the book has a title with value "Javascript"

The Relational Model

subject has a property with value "value" (s,p,v)

Triples

This is the essence of RDF: the (s,p,v) triple

More Properties

What about showing more properties

More Properties

Equivilent to...

Relations Between Entities

Publishers table: publisherID is primary key and exists as foreign key in Books table

Relations Between Entities

RDF Is A Graph

Global Naming

Enough Names?

Graph Components

Graphs can have named things - resources...

Graph Components

...and text values (literals)

Graph Components

...and numeric values (also literals)

Graph Components

...and named relations

Graph Components

...and unnamed things

Graph Components

...that can also be related to other things

Merging

Merging Example

Merging Example

Merging Example

Merging Is Safe By Design

Scaling The Web

Partial Understanding

URLs For Lookup

RDF Schemas

RDF Schemas

Schema Uses

Subclass Example

Suppose you have a simple piece of information

Subclass Example

Fetching the URL of the class returns RDF

Subclass Example

If every thing that is a book is an artistic work then...

Which Means...?

Domains And Ranges

Domain/Range Example

Another tiny piece of information

Domain/Range Example

Fetching the URL of the property returns RDF

Domain/Range Example

So we can infer the types of the subject and object

Which Means...?

Popular Schemas

RSS 1.0

FOAF

FRBR

Creative Commons

SKOS

Geo

Standardise To Scale

Remember Containerisation?

Decouple Through Standards

Decentralise To Scale

Reduce Coordination Costs

What Else?

What Else?

Issues

End of Part 1

This is the end of the high level stuff...

Graph Rules

Writing Down Graphs

Turtle - Basic Syntax

Turtle - Prefixes

Turtle - Triples About Same Subject

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "Some Text" .
ex:thing ex:otherrelation ex:otherthing .

can be written as:

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "Some Text" ;
         ex:otherrelation ex:otherthing .

Semicolon separates statements that differ in property and value

Turtle - Same Properties

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "Some Text" .
ex:thing ex:relation ex:otherthing .

can be written as:

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "Some Text" ,
                     ex:otherthing .

Comma separates statements that differ in value only

Turtle - Eliminate Redundant Triples

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "Some Text" .
ex:thing ex:relation "Some Text" .

has same meaning as:

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "Some Text" .

Turtle - Blank Nodes

@PREFIX ex: <http://example.com/> .
_:a ex:relation "Some Text" .

'a' is the label - valid only within a single document

if above triple appeared in another document it would refer to different node

Turtle - Unlabelled Blank Nodes

@PREFIX ex: <http://example.com/> .
  ex:thing ex:relation _:a .
  _:a ex:property "foo" .
  _:a ex:property "bar"

is same as

ex:thing ex:relation [
    ex:property "foo" ;
    ex:property "bar" 
  ] .

Turtle - Literals With Language

In RDF, literals can have a language

Written in Turtle as:

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "Hello"@en .
ex:thing ex:relation "Bonjour"@fr .

Turtle - Literals With Datatypes

In RDF, literals can have a datatype

Written in Turtle as:

@PREFIX ex: <http://example.com/> .
ex:thing ex:relation "49"^^<http://example.com/datatype> .

Can't have both a datatype and a language

Turtle - Longer Example

@PREFIX dc: <http://purl.org/dc/elements/1.1/> .
@PREFIX foaf: <http://xmlns.com/foaf/0.1/ .
<http://www.talis.com/> 
  dc:title "Talis Information Ltd." ;
  dc:description "The home page of Talis" ;
  dc:publisher [
    foaf:name "Talis"
  ] ;
  dc:date "2005-08-01" .

Interpreted as... the resource denoted by the URI http://www.talis.com/ has a title ..., a description ..., was published by ...

Turtle - Longer Example

Turtle - Types

'a' keyword is shorthand for the URI http://www.w3.org/1999/02/22-rdf-syntax-ns#type

@PREFIX dct: <http://purl.org/dc/terms/> .
_:x
  a dct:Collection .

Same as

@PREFIX dct: <http://purl.org/dc/terms/> .
@PREFIX rdf:  .
_:x
  rdf:type dct:Collection .

More On Schemas

Schema Example

Suppose we have this RDF schema:

@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.com/schema#> .

ex:Person a rdfs:Class .
ex:spouse a rdfs:Property .

Schema Example

We could use it like this:

@PREFIX ex: <http://example.com/schema#> .

_:fred
  a ex:Person ;
  ex:spouse _:wilma .

A query for all things with type ex:Person would return fred

Adding A Range

ex:Person a rdfs:Class .
ex:spouse a rdfs:Property ;
          rdfs:range ex:Person .

Now whenever we use the property ex:spouse we can infer that the value is a ex:Person

A query against the data will now return wilma as well.

Adding A Domain

We can simplify by adding a domain for the property

ex:Person a rdfs:Class .
ex:spouse a rdfs:Property ;
          rdfs:range ex:Person .
          rdfs:domain ex:Person .

Which lets us omit the type from our data - we can infer it instead

@PREFIX ex: <http://example.com/schema#> .
_:fred
  ex:spouse _:wilma .

More On Domains and Ranges

OWL

OWL

Primary Keys

IFP Example

IFP Example

Smushing

I Am Not A Number

Smushing

Cardinality

The Open World Assumption

The Open World Assumption

The Open World Assumption

The Open World Assumption

A Riddle

RDF/XML

RDF/XML Example

This Turtle...

@PREFIX ex: <http://example.com/schema#> .

<http://example.com/house>
  ex:title "a house" ;
  ex:owner _:owner .

_:owner 
  a ex:Person ;
  ex:name "Fred" .

RDF/XML Example

Corresponds to this RDF/XML...

<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:ex="http://example.com/schema#" >

  <rdf:Description rdf:about="http://example.com/house">
   <ex:title>a house</ex:title>
   <ex:owner rdf:nodeID="owner"/>
  </rdf:Description>

  <rdf:Description rdf:nodeID="owner">
   <rdf:type rdf:resource="http://example.com/schema#Person"/>
   <ex:name>Fred</ex:name>
  </rdf:Description>
</rdf:RDF>

RDF/XML Example

Class names can be used explicitly as xml elements.

<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:ex="http://example.com/schema#" >

  <rdf:Description rdf:about="http://example.com/house">
   <ex:title>a house</ex:title>
   <ex:owner rdf:nodeID="owner"/>
  </rdf:Description>

  <ex:Person rdf:nodeID="owner">
   <ex:name>Fred</ex:name>
  </ex:Person>
</rdf:RDF>

RDF/XML Example

Without blank node labels:

<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:ex="http://example.com/schema#" >

  <rdf:Description rdf:about="http://example.com/house">
   <ex:title>a house</ex:title>
   <ex:owner>
     <ex:Person>
       <ex:name>Fred</ex:name>
     </ex:Person>
   </ex:owner>
  </rdf:Description>
</rdf:RDF>

Striping

Datatypes and Languages

languages use xml:lang, datatypes use rdf:datatype

<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:ex="http://example.com/schema#" >

  <rdf:Description rdf:about="http://example.com/house">
   <ex:title xml:lang="en">a house</ex:title>
   <ex:owner>
     <ex:Person>
       <ex:name
        rdf:datatype="http://www.w3.org/2000/10/XMLSchema#string">Fred</ex:name>
     </ex:Person>
   </ex:owner>
  </rdf:Description>
</rdf:RDF>

Complications

There are (too) many ways to write a single graph as RDF/XML - literals as attributes is one variation

<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:ex="http://example.com/schema#" >

  <rdf:Description rdf:about="http://example.com/house" ex:title="a house">
   <ex:owner>
     <ex:Person ex:name="Fred" />
   </ex:owner>
  </rdf:Description>
</rdf:RDF>

Searching

Simple Inferencing

OWL Inferencing 1

First of all a robbery takes place. The robber drops his gun while fleeing. A report is filed by the investigating officers:

<RobberyEvent>
  <date>14th June 2005</date>
  <description>Armed robbery at Kwik-e-Mart</description>
  <evidence>
    <Gun>
      <serial>983GTE-H5TF</serial>
    </Gun>
  </evidence>
  <robber>
    <Person /> <!-- an unknown person -->
  </robber>
</RobberyEvent>

OWL Inferencing 2

Subsequently a car is pulled over for speeding. The traffic officer files a report electronically while issuing a ticket:

<SpeedingOffence>
  <date>26 October 2005</date>
  <description>Car observed driving at speed along M42</description>
  <speeder>
    <Person>
      <name>John Doe</name>
      <driversLicenseNumber>7431224667</driversLicenseNumber>
    </Person>
  </speeder>
</SpeedingOffence>

OWL Inferencing 3

At police HQ, the computer analyses each report as it is filed. The following OWL description tells the computer that a driversLicenseNumber is unique to a Person:

<owl:InverseFunctionalProperty rdf:ID="driversLicenseNumber">
  <rdfs:domain rdf:resource="Person" />
  <rdfs:range  rdf:resource="&rdf;Literal" />
</owl:FunctionalProperty>

OWL Inferencing 4

The computer uses this information to look up any other records it has about that person and finds a gun license:

<GunLicense>
  <registeredGun>
    <Gun>
      <serial>983GTE-H5TF</serial>
    </Gun>
  </registeredGun>
  <holder>
    <Person>
      <name>John Doe</name>
      <driversLicenseNumber>7431224667</driversLicenseNumber>
    </Person>
  </holder>
</GunLicense>

OWL Inferencing 5

The next OWL description tells the computer that the registeredGun property uniquely identifies a GunLicense. i.e. each gun is associated with only a single GunLicense

<owl:InverseFunctionalProperty rdf:ID="registeredGun">
  <rdfs:domain rdf:resource="GunLicense" />
  <rdfs:range  rdf:resource="Gun" />
</owl:FunctionalProperty>

OWL Inferencing 6

The computer now knows that the person stopped for speeding owns a gun. The next description tells the computer that each gun is uniquely identified by its serial.

<owl:InverseFunctionalProperty rdf:ID="serial">
  <rdfs:domain rdf:resource="Gun" />
  <rdfs:range  rdf:resource="&rdf;Literal" />
</owl:FunctionalProperty>

OWL Inferencing 7

The computer uses this to determine that the gun on the license is the same gun used in the robbery. This final description, seals the speeder's fate. It tells the computer that each GunLicense applies to only one gun and one person, so there is no doubt that the speeder is the person who owns the gun:

<owl:Class rdf:ID="GunLicense">
  <owl:intersectionOf rdf:parseType="Collection">
    <owl:Restriction>
      <owl:onProperty rdf:resource="#registeredGun"/>
      <owl:cardinality>1</owl:cardinality>
    </owl:Restriction>
    <owl:Restriction>
      <owl:onProperty rdf:resource="#holder"/>
      <owl:cardinality>1</owl:cardinality>
    </owl:Restriction>
  </owl:intersectionOf>
</owl:Class>

OWL Inferencing 8

The computer reports back to the traffic cop who duly arrests the speeder on suspicion of armed robbery.

The End!