What is a Triple?
See how Linked Data is implemented and works in practice.
URLs used in this video:
Hi, my name is Yulia and I'm a curriculum engineer at Inrupt.
In this video we're going to see how Linked Data is implemented and works in practice.
We'll start by learning what a Triple is and how to represent it in a syntax called Turtle.
At the very basis of Linked Data we have the concept of a piece of data, having some relation, or being linked to another piece of data, which could be located somewhere else. This is also commonly known as a link, hence the name Linked Data. We call each link with these three bits of information a Triple.
A Triple connects a subject to an object—that's two parts of the Triple. The third part of the Triple is the relationship between that subject and an object. You will find different ways that people refer to these three parts of a Triple. Some might say Subject, Predicate, Object, others will use Thing, Property, Value. We'll use the former, but if it gets confusing, leave your feedback in the comments, and we'll change it up.
Let's look at an example of how this works in plain English, and then translate it into machine-readable and interpretable form.
We'll start with myself as an example.
I am a person. The subject is "me", the predicate is "am", and the object is "person", and that's our first Triple.
My first name is Yulia. The subject is “me”, the predicate is "first name", and the object is “Yulia”.
So far, the subject that these statements are about has remained the same, and the predicate has changed. First it was the state of being, and then it was the property of having a first name.
Let's do another example.
I own a car and its name is Otto. The property here is "own", and the object is “myCar”. This is the first Triple within our statement. For the second Triple, “myCar” becomes the subject we're concerned with, and it has the predicate of “name" and the object is the string "Otto".
But there is another Triple in this statement, which is that myCar is a car. The Car in this case is the concept of a car, while myCar is the specific car in question. Just like I am a type of Person, myCar is a type of car. If you are familiar with object-oriented programming, then you will recognize this concept. Car is like a class, and myCar is an instance of that class. We represent this as a Triple, where myCar is the subject, the predicate is type, and the object is Car.
Now we have two subjects with their own set of property value pairs. This is starting to look like a web, of connected nodes, or a graph. Let's add another piece of data to it.
I am friends with Sonali who is also a person with a first name Sonali, and we both work together at Company A.
We can see how this is growing into a visual web of data. This is how links can express elementary facts, and how using multiple such Triples we are able to build complex knowledge graphs. Now let's put Linked Data Principles to practice with the same data.
To start building the data graph from our example we're going to create an RDF file. RDF stands for Resource Description Framework and is what allows us to bring Linked Data to life. As the acronym says, it is a framework for describing resources.
Since we used me in the example, then we need a resource that represents me digitally. We'll call this RDF file Digital Me, and place it on a server, so that it has this URL.
To write data to this RDF file we'll use Turtle, which is yet another acronym that stands for Terse RDF Triple Language. It allows us to follow the Linked Data Principles, which means using URLs as the core way of identifying, describing, and linking data together.
The first Triple in our example states that I am a person. Which in Turtle can look like this:
<https://id.inrupt.com/yulia>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://schema.org/Person> .
The grammar rules in Turtle are that
- every URL should be enclosed in angle brackets,
- each part of the Triple is separated by a white space, and
- a Triple end is denoted with a period.
Here, the subject in this Triple is a URL that brings us to a resource on the web that is me, digitally. Following this link, should lead me to this same RDF file, making this file self-describing.
The predicate and object URLs are giving us a clue that the predicate leads to a definition of "type", and the object is a definition of "person". Now if something or someone looking at this document doesn't know what type or person means, they can follow these links to look this information up. Which is what we'll do now.
The predicate leads us to w3.org, which is an international community that develops open standards to ensure the long-term growth of the web.
Following the link brings us to an RDF file that is written in Turtle syntax. We'll learn about reading and writing this form of Turtle syntax in the next video, but for now we'll skip it. However, you can always check it out for yourself ahead of watching the next video, and see if you can make sense of it.
Let's follow the object URL which is schema.org/person.
This we can read more easily than the resource at W3C we just looked at. The data behind this friendly user interface is still in Turtle but with the help of this friendlier UI we can easily find the definition of a person: "A person (alive, dead, undead, or fictional)”.
Now we have the first Triple in my Digital Me document, written in Turtle syntax. We can see that the Triple ends here because of the period at the end of the line.
The next statement is "my name is Yulia". The subject is me, which is the Digital Me RDF file that we're creating at this URL <https://id.inrupt.com/yulia>. The predicate is "first name", let's see if Schema.org has a definition for that.
Using the search bar on their homepage yields a bunch of different results. We can click through them until we find the best option for me, or we can look at their definition of a person, and see if there is a first name definition related to that instead, because we know what type of thing we're trying to describe here.
Looking for "first name" on the page we find the vocabulary entry for "given name", confirm that it works for us by reading the definition, and grab its URL https://schema.org/givenName.
Yay! We have a predicate. The object in this case is the string literal "Yulia". It's not a URL so it's expressed as a string, and then the Triple is concluded with a period.
<https://id.inrupt.com/yulia> <https://schema.org/givenName> "Yulia" .
In the next video, where we'll learn about how to make this RDF file more readable by humans using Turtle syntax, and continue to add things to our little web of data, starting with me owning a car.
For now, let's recap what we discussed about RDF and Turtle so far.
RDF stands for Resource Description Framework, which is a way of describing data on the web in accordance with Linked Data standards, allowing resources on the web to be:
- Self-describing
- Linkable
- And machine-readable
The basic unit of RDF is a Triple, which is an ordered statement with three parts, <subject> <predicate>, and <object>, where predicate defines how the subject is related to the object.
The subject is a URL and a key part in naming the data resource that contains this Triple. The predicate is a URL leading to a common vocabulary definition, in our example we used Schema.org, which is a common RDF vocabulary. The object could be a URL of a subject, a string, or a variety of other data types that we will not be covering in this video series.
- RDF by W3C
- Semantic Web by Ruben Verborgh