Classes
Classes are the foundation of an OWL ontology. They define categories of things in your domain.
Declaring Classes
Section titled “Declaring Classes”:Animal a owl:Class .:Person a owl:Class .:Organization a owl:Class .Class Hierarchies (subClassOf)
Section titled “Class Hierarchies (subClassOf)”rdfs:subClassOf creates parent-child relationships. This is what drives subsumption queries.
:Mammal a owl:Class ; rdfs:subClassOf :Animal .:Dog a owl:Class ; rdfs:subClassOf :Mammal .:Cat a owl:Class ; rdfs:subClassOf :Mammal .:GoldenRetriever a owl:Class ; rdfs:subClassOf :Dog .The hierarchy is transitive: GoldenRetriever is a subclass of Dog, Mammal, and Animal. When data is inserted as GoldenRetriever, the materializer adds all ancestor types automatically.
Disjoint Classes
Section titled “Disjoint Classes”Disjoint classes cannot share instances. If you declare Dog disjoint with Cat, a node cannot be both.
:Dog owl:disjointWith :Cat .The materializer checks disjointness after all inference rules are applied. If a mutation would result in a node having two disjoint types, the entire mutation is rejected.
Equivalent Classes
Section titled “Equivalent Classes”Equivalent classes are treated as synonyms. Asserting one implies the other.
:Canine owl:equivalentClass :Dog .Class Expressions
Section titled “Class Expressions”OWLGraph supports class expressions for more complex definitions:
Intersection (AND)
Section titled “Intersection (AND)”:WorkingDog a owl:Class ; owl:equivalentClass [ a owl:Class ; owl:intersectionOf ( :Dog :ServiceAnimal ) ] .Union (OR)
Section titled “Union (OR)”:Pet a owl:Class ; owl:equivalentClass [ a owl:Class ; owl:unionOf ( :Dog :Cat :Bird ) ] .Complement (NOT)
Section titled “Complement (NOT)”:NonMammal a owl:Class ; owl:equivalentClass [ a owl:Class ; owl:complementOf :Mammal ] .Property Restrictions
Section titled “Property Restrictions”# Anything that has at least one hasOwner relationship:OwnedAnimal a owl:Class ; owl:equivalentClass [ a owl:Restriction ; owl:onProperty :hasOwner ; owl:someValuesFrom :Person ] .Best Practices
Section titled “Best Practices”- Keep hierarchies shallow — deep hierarchies (10+ levels) increase materialization cost per write
- Use disjointness — it catches data quality issues at write time instead of query time
- Name classes clearly — class names become Dgraph types and GraphQL types
- Avoid cycles — OWLGraph rejects circular subclass declarations