Take a moment to see that you understand this clearly before continuing.

If you are unclear what triples in RDF are, we suggest you start with our acclaimed semantic web primer tutorial.

Classes then are simply a way of defining meaningful groups into which these resources can be placed - they are classifications.

2. Classes And Individuals

As we've said, a class is simply a way of defining groups into which resources can be meaningfully placed.

For example, we may want to define three meaningful classes into which we could place our three resources above:

A canine class, a class for all members of the canine species, into which we could place our dog Bengie.

A feline class, a class for all members of the feline species, into which we could place our cat Bonnie.

A murinae class, a class for all members of the murinae species (the formal biological classification for mice), into which we could place our mouse, Benjamin.

In semantic web terms, any resource that we've placed into a class is called an individual of that class.

Remember the difference between a class and an individual. An individual is a resource that has been placed into the class (or, the classifying group). Individuals are not classes themselves.

We hope now you see that these are normal, everyday concepts and nothing particularly special or unique to the semantic web.

Before continuing, make sure you now understand the following three important terms:

A resource is anything that is given a unique subject URI.

A class (or, classification) is a meaningful way of grouping resources.

An individual of a class is a resource that has been placed into that class (also sometimes called an instance of the class).

To go further, let's see exactly how we define classes and individuals in RDF.

3. Defining Classes & Individuals In RDF

To define classes and individuals in RDF you need to use something called RDFS - or RDF Schema. There is nothing special or mysterious about RDFS - it simply gives you a standard vocabulary to tell a machine reader what your classes and individuals are in a standard way using RDF (probably why it is called RDF schema).

Because it's a W3C semantic web standard, we need to use it to define our classes and individuals.

Let's demonstrate how to define classes using RDFS, by defining the three classes we outlined above - for canines, felines and murinae (mice):

First off, you can see on the first two lines the standard RDF and RDFS namespaces, with which you should be familiar if you have seen RDF documents before.

There is a very common - and very important - predicate stated here: rdf:type (or, if you want to expand it in full http://www.w3.org/1999/02/22-rdf-syntax-ns#type).

When used as a predicate in an RDF triple (i.e. the subject->predicate->object relationship), this formally states that the resource (with its unique subject URI) is an individual (or, member) of the class with identifier given by the object URI.

To help understand this, see if you can see for yourself the following in the RDF above:

Resource http://www.linkeddatatools.com/tutorial#canine is an individual of the classrdfs:Class.

Resource http://www.linkeddatatools.com/tutorial#feline is an individual of the classrdfs:Class.

Resource http://www.linkeddatatools.com/tutorial#murinae is an individual of the classrdfs:Class.

And that's how we define our classifications using the RDFS vocabulary - by stating that our resourcestutorial:canine, tutorial:feline and tutorial:murinae are individuals of the RDFS class rdfs:Class.

Note we defined a class in RDFS by defining an individual - of the RDFS class rdfs:Class. All classes in RDFS are defined by stating the resources are individuals of rdfs:Class.

Now that we've defined our three classes in RDFS, let's place the three resources we defined at the beginning of this tutorial - our dog Bengie, our cat Bonnie and mouse Benjamin - into these classes appropriately. To do this, we use the same predicate again, rdf:type, to state that they are individuals of the classes we have just defined:

4. Subclasses

Lastly, let's deal with the powerful concept of classes and subclasses in semantic web models.

Often, it is useful to define a hierarchy of classifications, from the most general classifications at the top of the hierarchy to the most specialised classifications at the bottom.

For example, whilst we have separate classes for canines, felines and murinae above, we may wish to define an over-arching general animal class - that includes canine, feline and murinae as subclasses of this (general) animal class.

How do we now define the general animal class and indicate that canine, feline and murinae are subclasses of this class? First, let's define our new general animal class, in a similar way to how we defined our canine, feline and murinae classes:

Congratulations, if you have understood all that we have built up here, you have understood how to create your first ontology, using RDF Schema.

As an exercise, have a second look over the document above and see if you can identify each of its component parts (the resources, classes, individuals and subclass statements).

As an optional further exercise, just to make sure you have understood all the concepts we have discussed, see if you can identify how many resources are included in the above document and their subject URIs (the answer is 7).

4.1 A Quick Note On Reasoning And Inference

You may have heard of reasoning and inference in semantic web models. Although usually something associated with richer ontologies written in OWL, there are some simple ways in which a reasoner can infer characteristics from an RDFS ontology too (a reasoner is a semantic web reader program that understands RDFS and OWL vocabularies and how to infer information from ontologies written in these vocabularies).

There are several minor ways in which most semantic web readers can infer certain things from the RDF we have written so far in this tutorial (these are just but a few examples - they are not exhaustive).

If we omitted all the class definitions from our ontology, the fact that we have defined some individuals of our canine, and feline and murinae classes means that a semantic web reader could still infer that tutorial:canine, tutorial:feline and tutorial:muranae were classes.

If we omitted the tutorial:animal class definition from the ontology we have just created, but left the statement that canine, feline and murinae were all subclasses of the tutorial:animal class, a semantic web reader could still infer that tutorial:animal was a class, despite us not explicitly defining it in our ontology.

These are simple examples of reasoning in semantic web models - something we will see a little more of in our next tutorial, on properties.

5. Enriching Your Semantics With OWL

So far, we have introduced how to define semantic classes, subclasses and individuals using RDFS. These are powerful concepts in themselves and useful for modelling the information we have for others to understand.

However, we could go further than simple classifications and subclassifications and start to describe richer properties of the classes we have defined using OWL (Web Ontology Language).

For example, in OWL we could state that some of the classes we have defined were semantically equivalent to other classes even though they had different class (subject) URIs. Or, if we know that a class we have defined is always the opposite in meaning to another class, we could state this too.

We will not explore the full richness of OWL for the purposes of this tutorial because we need to introduce the concept of properties first, but keep in mind how OWL is in a sense a more sophisticated extension of RDFS.