Primer on Semantic Web Ontologies

A short description for RDF,RDFS, and OWL and their serialisation formats

Introduction

The basic ontology for recording anything (and everything) is RDF, which is just a way of expressing knowledge in the form of triples or (subject, object, predicate) form. RDFS and OWL which build a relationship-constraint model on top of RDF. To summarise, RDF allows expressing knowledge, pure and simple; RDFS and OWL add additional relationships such as hierarchy, inheritance, and restrictions (or in the case of OWL, axioms) that enrich the knowledge through the use of 'structure'. This is not a guide to learn about semantic web ontologies, but if you're looking for that sort of a resource, you may as well start with a StackOverflow answer and then move on to Wikipedia - OWL.

Usage

RDF is used to represent knowledge, but not its validity or truth. So, statements like <harsh> <is> <awesome> are perfectly valid RDF, but there is no way to check their 'validity' or 'correctness'. To express some constraints over the use of resources, one uses RDFS and OWL to structure how the knowledge may be represented. The ontologies also additionally allow inheritance and axioms, which can help create new knowledge through inference and reasoning. For example,

<class:Man> <rdf:type> <subclass:Human>
<class:Woman> <rdf:type> <subclass:Human>
<property:isMother>
    <rdf:type> <owl:Property>
    <rdf:domain> <class:Woman>
    <rdf:range> <class:Human>
<property:isSon>
    <rdf:type> <owl:Property>
    <rdf:domain> <class:Man>
    <rdf:range> <class:Human>

<node:Harsh> <rdf:type> <class:Man>
    <property:isSon> <node:HarshMom>
<node:HarshMom> <property:isMother> <node:Harsh>

defines classes Man and Woman as subclasses of Human, with the properties isMother and isSon with domains and ranges. It then defines that Harsh is a Man, and is the son of HarshMom. At this point, the only inference possible is that HarshMom is of type Human. The next sentence specifies that HarshMom is the mother of Harsh, and therefore, it is possible to infer that HarshMom is a Woman. Although this is a simple example, it amply shows how the structuring of knowledge can be shaped using relationships. Simpler constraints help represent complex knowledge.

Formats

RDFS and OWL are serialised down into RDF, so they are essentially represented as RDF in most cases. There are possibilities of having OWL only formats, which do not cater to RDF, but OWL, as an ontology is based on RDF.

  • RDF/XML: This is (sort-of) the default format for serialising RDF. Files usually end in .rdf though .xml extension would also be valid, but is not recommended. The content-type is text/rdf+xml.
  • Turtle: This is the easiest format to read and write in, and is quite concise. It's extenion is .ttl and the content-type is text/turtle.
  • N-Triples: This is a similar format to Turtle, though is arguably less concise. The extension is .nt and the content-type is application/n_triples.
  • Notation 3: Another concise format, it's extension is .n3 and the content-type is text/n3.
  • JSON-LD: To make the propogation of RDF easier on the web, the JSON-LD format was developed. It uses a notation based on the JSON format with annotations catering to RDF keywords. It's extension is .jsonld and content-type is application/ld+json.
  • RDFa: This is a way to embed RDF information in HTML tags, while still allowing traditional page markup to be used and displayed. This is, in theory, the best of both worlds as the resulting document is presentable for human as well as machine consumption.