Introduction to RDF
What is RDF?
Linked Data is based around describing real world things using RDF. A lot of articles about Linked Data assume you already know what RDF is all about: if you are coming to it for the first time, this article explains the basics.
RDF stands for Resource Description Framework. It’s a W3C standard for modeling information.
RDF allows you to define statements about things (or resources), in the form of subject-predicate-object expressions (known as RDF-triples due to the 3 constituent parts).
This might sound very technical, but the meanings of subject, predicate, and object are essentially the same as in English grammar. i.e.
subject: The thing we’re talking about. In RDF, this is the resource in question.
predicate: A term used to describe or modify some aspect of the subject. In RDF, the predicate is used to denote relationships between the subject and the object.
object: In English the object of a sentence is the thing that the verb is acting upon. In RDF, it’s the “target” or “value” of the triple. It can be another resource, or just a literal value such as a number or word.
That was all a bit hand-wavey, so let’s use an example to make it a bit clearer. Take the sentence:
Ric’s blog can be found at ricroberts.com
In this sentence, “Ric” is the subject, “blog” is the predicate and “ricroberts.com” is the object. (I know that this is probably not exactly grammatically correct, but bear with me…).
Our first RDF triple
Let’s deconstruct this a bit, and express it as RDF…
The resource in question is a person (me). In RDF, we use URIs to uniquely identify resources. Let’s use http://swirrl.com/ric.rdf#me as the URI to identify me. I’m fairly confident that no-one else will use that URI to identify themselves as I control the swirrl.com domain, so I can control what is returned when it’s dereferenced (looked up).
Aside: You may well have clicked on that link above. If you did, it will, depending on your browser, render or download an RDF graph (a collection of rdf triples) that describe some facts about me. Don’t worry about the contents of that for now: the point here is that looking up a URI can sometimes return useful information about the resource. For more about dereferencing URIs, see What is Linked Data?
We need to find a term which we can use to mean “blog”. For this example I’m going to use a term from the FOAF (Friend-of-a-Friend) vocabulary. Predicates are also identified by URIs: FOAF’s URI for the weblog predicate is http://xmlns.com/foaf/0.1/weblog.
The object of this triple is just a URL which identifies the home page of my blog http://ricroberts.com.
Putting it all together, we have:
Serializing our triple
There are various ways to express our RDF triple:
Blob and Line
One of the simplest ways to express RDF is via what I call blob and line diagrams (someone correct me if there’s an official term for them). URIs are expressed as blobs, and predicates are lines. Literal values (numbers, words etc.) would be in rectangles, but we don’t have any in our triple.
Blob and line diagrams are easy for humans to understand at a glance, at least where you only have a small number of triples, but aren’t (easily) machine readable.
Machine readable formats
There are various ways of expressing RDF triples in more machine-friendly ways, including RDF/XML, Turtle and N-triples, which we’ll discuss in a future article.
What have we learnt here?
To summarise, we’ve learnt that you can use RDF to express facts as triples, where URIs are used to identify resources (things) and concepts. Dereferencing (looking up) resources by their URIs can yield more information about them.
We'd love it if you shared this article.