Defining classes: Tracker SPARQL Library Reference Manual

## Defining classes

Classes are the base of an ontology, all stored resources must define themselves as "being" at least one of these classes. They all derive from the base rdfs:Resource type. To eg. define classes representing animals and plants, you can do:

    ex:Eukaryote a rdfs:Class;
                 rdfs:subclassOf rdfs:Resource;
                 rdfs:comment "An eukaryote".

By convention all classes use CamelCase names, although class names are not restricted. The allowed charset is UTF-8.

Declaring subclasses is possible:

    ex:Animal a rdfs:Class;
              rdfs:subclassOf ex:Eukaryote;
              rdfs:comment "An animal".

    ex:Plant a rdfs:Class;
              rdfs:subclassOf ex:Eukaryote;
              rdfs:comment "A plant".

    ex:Mammal a rdfs:Class;
              rdfs:subclassOf ex:Animal;
              rdfs:comment "A mammal".

With such classes defined, resources may be inserted to the endpoint, eg. with the SPARQL:

    INSERT DATA { <merry> a ex:Mammal }
    INSERT DATA { <treebeard> a ex:Animal, ex:Plant }

Note that multiple inheritance is possible, resources will just inherit all properties from all classes and superclasses.