What Are Properties?

Next: Enriching Semantics With OWL

Properties in RDF allow us to define or describe characteristics of Individuals of a Class. How do we define properties in RDF? We show you by extending our previous tutorial ontology to add some new simple properties of our own.

After this tutorial, you should be able to:

  • Understand what a property is in semantic web terms.
  • Some of the more common properties used to describe the characteristics of classes or individuals.
  • Understand the concept of a property domain.
  • Understand the concept of a property range.

Estimated time: 10 minutes

You should have already understood the following tutorial (and pre-requisites) before you begin:

RDF classes and individuals concept

1. Some Common Properties We Have Used Already

If you have already read through our previous What Are Classes And Individuals? tutorial, you will have learned how we used RDF Schema (RDFS) to define a set of classes, and some individuals. Here's the RDFS ontology document we created again:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix tutorial: <http://www.linkeddatatools.com/tutorial#>
@prefix thing: <http://www.linkeddatatools.com/thing#>

tutorial:animal rdf:type rdfs:Class .
tutorial:animal rdfs:label "A classification of all members of the animal kingdom" .

tutorial:canine rdf:type rdfs:Class .
tutorial:canine rdfs:label "A classification of all members of the canine species" .
tutorial:canine rdfs:subClassOf tutorial:animal .

tutorial:feline rdf:type rdfs:Class .
tutorial:feline rdfs:label "A classification of all members of the feline species" .
tutorial:feline rdfs:subClassOf tutorial:animal .

tutorial:murinae rdf:type rdfs:Class .
tutorial:murinae rdfs:label "A classification of all members of the murinae species" .
tutorial:murinae rdfs:subClassOf tutorial:animal .

thing:bengie rdfs:label "Our dog, called Bengie".
thing:bengie dcterms:description "A friendly member of the canine species".
thing:bengie rdf:type ldt:canine .

thing:bonnie rdfs:label "Our cat, called Bonnie".
thing:bonnie dcterms:description "A friendly member of the feline species".
thing:bonnie rdf:type ldt:feline .

thing:benjamin rdfs:label "Our mouse, called Benjamin".
thing:benjamin dcterms:description "A friendly member of the murinae species".
thing:benjamin rdf:type ldt:murinae.

Without really mentioning it, we used several common predicates such as rdf:type, rdfs:label and rdfs:subClassOf to describe the characteristics of some of the resources in this document.

For example, we gave the animal class the human readable label "A classification of all members of the animal kingdom" and used the rdf:type predicate to indicate it was an individual of the RDFS class rdfs:Class. We learned this is how we defined a new class in RDFS.

These are pre-defined properties we have used - defined in the RDF and RDFS vocabularies, that many semantic web readers understand.

But what if now want to enhance the definition of our animal classes with some further properties of our own? We can do this by defining our own properties in our ontology in addition to the classes we have already defined.

2. Defining A New Property

Let's do this now. We'll define a simple literal property that gives us a 'pet name' for our animal class individuals that we've defined already: thing:bengie, thing:bonnie and thing:benjamin.

In RDFS we can define a new property by stating that our resource is an individual of the class rdf:Property:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix tutorial: <http://www.linkeddatatools.com/tutorial#>
@prefix thing: <http://www.linkeddatatools.com/thing#>

tutorial:petName rdf:type rdf:Property .
tutorial:petName rdfs:label "The pet name for the animal" .

Note the parallel with defining classes that we saw in our previous tutorial; rather like we define a new class by stating an individual of the RDFS class rdfs:Class, we define a new property by stating an individual of the rdf:Property class (yes, rdf:Property is a class - a class of all properties).

Note If others import our ontology and see this property on individuals defined elsewhere, they'll know that this states the pet name of the individual of the class. We could have for example used rdfs:label to give the pet name - but this would have been too general for other consumers of our data to understand.

Now we can start enriching our definition of the property immediately by starting to constrain what things this property can describe - starting with the domain of things that this property is validly applied to.

2.1 Property domain

We start in RDFS by indicating the domain over which this property is valid. The domain tells us what individuals (of a given class) this property is allowed to be applied to. In this case, we know that this new property should only be applied to individuals of the tutorial:animal class, and its subclasses.

We can indicate this by using the rdfs:domain predicate:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix tutorial: <http://www.linkeddatatools.com/tutorial#>
@prefix thing: <http://www.linkeddatatools.com/thing#>

tutorial:petName rdf:type rdf:Property .
tutorial:petName rdfs:label "The pet name for the animal" .
tutorial:petName rdfs:domain ldt:animal .

Now, if any semantic web reader sees this property applied to anything other than an individual of the class tutorial:animal, it can either flag an error or ignore it. But, we've also clearly stated that this property applies to individuals of tutorial:animal and made it granular (specific) enough to know that whatever value given to this property is always going to be a pet name (the text won't mean anything else).

The rdfs:domain property is called 'transitive' in semantic web terms - because by defining a domain of the class tutorial:animal, we encapsulate all its subclasses too.

Semantic Web Primer e-Book

NEW! Semantic Web Primer e-Book (First Edition)

Includes all our primer tutorials. Plus two exclusive new tutorials on RDF syntaxes, and NoSQL databases found only in the e-Book.

2.2 Property range

We also know that our 'pet name' property is always going to be a textual value - or a literal value. We can indicate this using the RDFS range predicate, which indicates the range of valid values this property can hold. We don't have to state this, but we can in this case because we know we have a definite valid range.

We can do this like so:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix tutorial: <http://www.linkeddatatools.com/tutorial#>
@prefix thing: <http://www.linkeddatatools.com/thing#>

tutorial:petName rdf:type rdf:Property .
tutorial:petName rdfs:label "The pet name for the animal" .
tutorial:petName rdfs:domain ldt:animal .
tutorial:petName rdfs:range rdfs:Literal .

Now we've defined the domain and range of our new property, we can apply it to the individuals of the tutorial:animal class we have defined already - Bengie our dog, Bonnie our cat and Benjamin our mouse.

3. Applying The New Property To Our Individuals

We can now use our newly defined property just like any other property (predicate) we have used such as rdfs:label or rdf:type - by using it as a predicate and, in this case, setting the object value to the pet names like so:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix tutorial: <http://www.linkeddatatools.com/tutorial#>
@prefix thing: <http://www.linkeddatatools.com/thing#>

tutorial:animal rdf:type rdfs:Class .
tutorial:animal rdfs:label "A classification of all members of the animal kingdom" .

tutorial:canine rdf:type rdfs:Class .
tutorial:canine rdfs:label "A classification of all members of the canine species" .
tutorial:canine rdfs:subClassOf tutorial:animal .

tutorial:feline rdf:type rdfs:Class .
tutorial:feline rdfs:label "A classification of all members of the feline species" .
tutorial:feline rdfs:subClassOf tutorial:animal .

tutorial:murinae rdf:type rdfs:Class .
tutorial:murinae rdfs:label "A classification of all members of the murinae species" .
tutorial:murinae rdfs:subClassOf tutorial:animal .

tutorial:petName rdf:type rdf:Property .
tutorial:petName rdfs:label "The pet name for the animal" .
tutorial:petName rdfs:domain tutorial:animal .
tutorial:petName rdfs:range rdfs:Literal .

thing:bengie rdfs:label "Our dog, called Bengie".
thing:bengie dcterms:description "A friendly member of the canine species".
thing:bengie rdf:type tutorial:canine .
thing:bengie tutorial:petName "Bengie" .

thing:bonnie rdfs:label "Our cat, called Bonnie".
thing:bonnie dcterms:description "A friendly member of the feline species".
thing:bonnie rdf:type tutorial:feline .
thing:bonnie tutorial:petName "Bonnie" .

thing:benjamin rdfs:label "Our mouse, called Benjamin".
thing:benjamin dcterms:description "A friendly member of the murinae species".
thing:benjamin rdf:type tutorial:murinae.
thing:benjamin tutorial:petName "Benjamin" .

You can see now that we have given Bengie, Bonnie and Benjamin their literal names using our new property.

As an exercise, see now that you can identify all the component parts we have learned of in these tutorials - the resources, classes, subclasses, individuals and properties.

Note Hopefully, you can now see how classes and properties help us define the semantics (or, meaning) behind the data, as well as the data itself. We have defined a simple hierarchy of classifications, some individuals we wish to belong in those classifications, and a simple property we wish to apply to those individuals. We have also then defined some individuals, and given some values for that property.

Semantic Web Primer e-Book

NEW! Semantic Web Primer e-Book (First Edition)

Includes all our primer tutorials. Plus two exclusive new tutorials on RDF syntaxes, and NoSQL databases found only in the e-Book.

3.1 A Quick Note On Reasoning And Inference

As we described in our previous tutorial on classes and individuals, a semantic web reader could infer simple added information from an RDF model, even if some information was missing.

We can do more of the same here now we have added some properties.

For example, the very fact that we have used tutorial:petName as a predicate in the ontology above means that (under RDF Schema), it is implicitly an instance of rdf:Property, because under RDFS all properties are individuals of rdf:Property. So, strictly speaking we can remove the statement from our ontology that states tutorial:petName is an individual of the rdf:Property class, because this is implied already.

In addition, because we have explicitly stated that the domain of valid individuals for our tutorial:petName property was individuals in the tutorial:animal class only, we could have omitted the statement that Bengie, Bonnie or Benjamin were individuals of the tutorial:animal class - because the property itself implicitly states that they are individuals in this class by the fact we have chosen to apply this property to them.

You have completed this lesson. You should now understand the following:

  • What a property is, and the meaning of a property's domain and range.
  • Understand how to define them using RDF Schema.
  • A little of reasoning over RDF Schema properties.

You should now be able to start the following tutorial:

  • Enriching Semantics Using OWL
 

Add comment

Security code
Refresh

Community

Register to download software from our site and interact with other users as you learn semantic web.

NEW! The Semantic Web Primer e-Book (First Edition) includes all our primer tutorials

Semantic Web Primer e-Book

Plus two exclusive new tutorials on RDF syntaxes, and NoSQL databases found only in the e-Book.

Get Your Copy >>