Linked Data Basics for Techies

From OpenOrg
Revision as of 13:10, 15 January 2011 by WikiSysop (talk | contribs) (Created page with " INTRO: This needs to be simple list of useful tips. We need to avoid overloading people. == RDF & Triples == RDF is a way of structuring information to be very interoperable a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

INTRO: This needs to be simple list of useful tips. We need to avoid overloading people.

RDF & Triples

RDF is a way of structuring information to be very interoperable and extendable. The most simple unit of information is called a 'triple'. A triple consists of three parts; the ID of a thing, the ID of a property that relates that thing to another thing or a value (text or a date or a number or something).

The first thing is called the Subject. The property is sometimes called a Predicate or Relation, the last bit is the Object. If the last bit is a value rather than the ID of a thing it's called a Literal. ID's may represent absolutely anything, but we use web addresses for them. These are called URIs. It can be confusing at first because refers to a person, not a webpage, but it's a very handy way to ensure that these IDs are globally unique.

The neat thing about this structure is that you can represent almost any other kind of data using it. It's not great at doing ordered lists of values.

A URI represents a single concept or thing, but many URIs can represent the same thing.

If you resolve a URI it's considered good practice to return some useful triples about the concept the URI represents, but don't lose sleep over doing that -- it's an optional bonus feature of RDF.

RDF Documents


There are several ways of writing RDF triples into a file. The most common is called RDF+XML (which people often just called RDF). It usually looks something like this:

 <foaf:Person rdf:about=''>
    <foaf:name>Christopher Gutteridge</foaf:name>

If you want to produce RDF+XML See this Guide. To parse RDF+XML just find and use a library, there's one in most popular langauges!

This wiki uses a simple subset of RDF+XML for examples.

Turtle (aka N3)

N3 is quite complicated so some bright person defined a cut-down version called Turtle which is really easy to read and write, but is sadly not as widely supported as RDF+XML.

Turtle looks something like this:

 <> a foaf:Person ;
    foaf:name "Christopher Gutteridge" .

rdf:type and classes

The most common predicate (property) is 'rdf:type' to relate a thing to a class. For example, relating me to the fact I'm of rdf:type foaf:Person. Things csn have any number of types.

The 'object' of rdf:type is often referred to as a class.


For URIs it's common to define a bunch of relate concepts in the same "namespace". A namespace is bit like a directory on a filesystem; it usually ends with either "/" and "#" and the ID's in the namespace generally don't have "/" or "#" in as that confuses things.

You will probably define your own namespace for your own concepts, such as your organistations members, or the bus stops nearby, but for classes and predicates you'll often use other people's namespaces. in RDF+XML and Turtle it's common to use a namespace prefix to make things more readable. In RDF+XML you must use namespace prefixes for predicates. The following examples mean exactly the same thing: Example 1

<?xml version="1.0" encoding="utf-8"?>
  <rdf:Description rdf:about="">
     <rdf:type rdf:resource="" />
     <foaf:name>Christopher Gutteridge</foaf:name>

Same as Example 2

@prefix foaf: <> .
@prefix wsperson: <> .
wsperson:7 rdf:type foaf:Person .
wsperson:7 foaf:name "Christopher Gutteridge" .

Same as Example 3

<> <> <> .
<> <> "Christopher Gutteridge" .

You can get a list of the standard abbreviations for common namespaces using

If you're really lazy, you can get the stub of an XML document out of it, for example,dcterms,geo.rdf

Common Namespaces

Here's a quick summary of the most common namespaces.

rdf - has the core parts of RDF, but usually you'll only see rdf:type.

rdfs - tools for describing

 <foaf:Person rdf:about=''>
    <foaf:name>Christopher Gutteridge</foaf:name>