2.2 The RDF Triple

Three is a magical number. For instance, three legs are all you need to create a stable stool, and a transmitter and two receivers are all you need to triangulate a specific transmission point. You can create a perfect sphere with infinitely small triangles. (Triangles are a very useful geometric shape, also used to find the heights of mountains and the distances between stars.)

RDF is likewise based on the principle that three is a magic number?in this case, that three pieces of information are all that's needed in order to fully define a single bit of knowledge. Within the RDF specification, an RDF triple documents these three pieces of information in a consistent manner that ideally allows both human and machine consumption of the same data. The RDF triple is what allows human understanding and meaning to be interpreted consistently and mechanically.

Of the three pieces of information, the first is the subject. A property such as name can belong to a dog, cat, book, plant, person, car, nation, or insect. To make finite such an infinite universe, you must set boundaries, and that's what subject does for RDF. The second piece of information is the property type or just plain property. There are many facts about any individual subject; for instance, I have a gender, a height, a hair color, an eye color, a college degree, relationships, and so on. To define which aspect of me we're interested in, we need to specifically focus on one property.

If you look at the intersection of subject and property, you'll find the final bit of information quietly waiting to be discovered?the value associated with the property. X marks the spot. I (subject) have a name (property), which is Shelley Powers (property value). I (subject) have a height (property), which is five feet eleven inches (property value). I (subject) also have a location (property), which is St. Louis (property value). Each of these assertions adds to a picture that is me; the more statements defined, the better the picture. Stripping away the linguistic filler, each of these statements can be written as an RDF triple.

With consideration of the differing linguistics based on different languages, simple facts can almost always be defined given three specific pieces of information: the subject of the fact, the property of the subject that is currently being defined, and its associated value. This correlates to what we understand to be a complete thought, regardless of differing syntaxes based on language.

A basic rule of English grammar is that a complete sentence (or statement) contains both a subject and a predicate: the subject is the who or what of the sentence and the predicate provides information about the subject. A sentence about the giant squid article mentioned in the last section could be:

The title of the article is "Architeuthis Dux."

This is a complete statement about the article. The subject is the article, and the predicate is title, with a matching value of "Architeuthis Dux." Combined, the three separate pieces of information triangulate a specific, completely unique piece of knowledge.

In RDF, this English statement translates to an RDF triple. In RDF, the subject is the thing being described?in RDF terms, a resource identified by a URI (more fully explained in a later section with the same title)?and the predicate is a property type of the resource, such as an attribute, a relationship, or a characteristic. In addition to the subject and predicate, the specification also introduces a third component, the object. Within RDF, the object is equivalent to the value of the resource property type for the specific subject.

Working with the example sentence earlier, "The title of the article is `Architeuthis Dux,'" the generic reference to article is replaced by the article's URI, forming a new and more precise sentence:

The title of the article at http://burningbird.net/articles/monsters3.htm is 
"Architeuthis Dux."

With this change, there is no confusion about which article titled "Architeuthis Dux" we're discussing?we're talking about the one with the URI at http://burningbird.net/articles/monsters3.htm. Providing a URI is equivalent to giving a person a unique identifier within a personnel system. The individual components of the statement we're interested in can be further highlighted, with each of the three components specifically broken out into the following format:

<subject> HAS <predicate> <object>

Don't let the angle brackets fool you within this syntax?this isn't XML; this is a representation of a statement whereby three components of the statement can be replaced by instances of the components to generate a specific statement. The example statement is converted to this format as follows:

http://burningbird.net/articles/monsters3.htm has a title of 
"Architeuthis Dux."

In RDF, this new statement, redefined as an RDF triple, can be considered a complete RDF graph because it consists of a complete fact that can be recorded using RDF methodology, and that can then be documented using several different techniques. For instance, one shorthand technique is to use the following to represent a triple:

{subject, predicate, object}

If you're familiar with set theory, you might recognize this shorthand as a 3-tuple representation. The giant squid example then becomes:

{http://burningbird.net/articles/monsters3.htm,  title, "Architeuthis Dux"}

This representation of the RDF triple is just one of many ways of serializing RDF data. The formal way is the directed graph, discussed in the next section. Popular choices to serialize the data are N-Triples, a subset of N3 notation (both of which are briefly discussed in this chapter), and RDF/XML, which forms the basis of the remainder of this book.

Regardless of the manner in which an RDF triple is documented, four facts are immutable about each:

  • Each RDF triple is made up of subject, predicate, and object.

  • Each RDF triple is a complete and unique fact.

  • An (RDF) triple is a 3-tuple, which is made up of a subject, predicate and object ? which are respectively a uriref or bnode; a uriref; and a uriref, bnode or literal (This is from a comment made by Pat Hayes in http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2003Feb/0152.html)

  • Each RDF triple can be joined with other RDF triples, but it still retains its own unique meaning, regardless of the complexity of the model in which it is included.

That last item is particularly important to realize about RDF triples?regardless of how complex an RDF graph, it still consists of only a grouping of unique, simple RDF triples, and each is made up of a subject, predicate, and object.

N3 notation does have some major fans as an approach to serializing RDF graphs, including Tim Berners-Lee. However, the W3C has officially sanctioned RDF/XML as the method to use for serializing RDF. One overwhelming advantage of RDF/XML is the wide acceptance of and technical support for XML. Though N3 notation is not covered in detail in this book, you can read a primer on N3 and RDF at http://www.w3.org/2000/10/swap/Primer.