In short#
When you attach a slot to a kind of thing, every kind below it gets that slot too, so you only write it once.
flowchart LR accTitle: Slots flow down the drink hierarchy accDescr: Drink has the slot pourOrder. Espresso drink is a kind of Drink and adds pullVolumeMl. Milk drink is a kind of Espresso drink and adds texture. Cortado is a kind of Milk drink, so it has all three. drink["Drink: pourOrder"] --> ed["Espresso drink: + pullVolumeMl"] ed --> md["Milk drink: + texture"] md --> cortado["Cortado: has all three"]
Say every drink on the Vertex Coffee menu needs a pour order. You could add the slot to Cortado, Latte, Mocha and 20 more. Or you add it once to Drink. Every kind below Drink then has it, and a new kind you add next week has it too.
See it#
This is part of the espresso tutorial ontology. Vertex Coffee is the made-up café behind it (how to read the graphs). The arrows between rings read “is a kind of”, which stacks them into a class hierarchy. Slots are switched on, so you can see which ring each one hangs from.
The graph shows the chain of kinds from Drink down to Cortado.
- Cortado is a kind of Milk drink. Milk drink is a kind of Espresso drink. Espresso drink is a kind of Drink.
- Drink has the slots
pourOrder,origin,containsandvariationOf. - Espresso drink adds
pullVolumeMl. Milk drink addstextureandespressoToMilkRatio. - Cortado has no slots of its own. It gets every slot above it.
Notice where each slot sits. Each one is attached at the highest kind that can have it. A pull volume only makes sense for a drink with espresso in it, so it hangs from Espresso drink and not from Drink. A milk-only texture hangs from Milk drink. That is the rule of thumb: attach a slot as high as it’s true for every kind below, and no higher. The word for what Cortado does is inheritance.
In okb#
Run okb show on Cortado, from the espresso folder.
okb show Cortado
Cortado Class · c.cortado
Espresso cut with an equal amount of warm milk.
parents MilkDrink
subclasses —
Slots (properties hold values; relationships → link to other things)
espressoToMilkRatio Float, single (from MilkDrink)
fixed = 1
texture Enumerated, {silky, foamy, thick}, single (from MilkDrink)
pullVolumeMl Integer, single (from EspressoDrink)
pourOrder String, single (from Drink)
origin String, single (from Drink)
fixed = Spain
contains Instance, → Ingredient (:CONTAINS), multiple, min 1, inverse of usedIn (from Drink)
variationOf Instance, → Drink (:VARIATION_OF), multiple (from Drink)
instances Vertex cortado
Design decisions
d.5: Cortado is a class. Every drink type, Cortado included, is a class. Items on the menu
are instances.
Cortado has no slots attached directly. Every line says where it came from: from MilkDrink, from EspressoDrink or from Drink. The fixed lines are values that Cortado sets for the whole kind.
Common mistakes
- Repeating a slot on every kind. If you attach
pourOrderto each drink, one rename means 20 edits.- Attaching too high. A
textureslot on Drink would also show up for a plain Espresso, which has no milk.- Attaching too low. A slot on Cortado alone is invisible to Latte, which needs it too.
Related pages#
- The espresso tutorial, step 5 attaches these slots to the hierarchy.
- Where to attach a slot walks through the choice.
- What does “is a kind of” mean? explains the “is a” links that carry slots down.
- What are facets? is the next page: it sets rules on a slot, such as a default value.
- Glossary defines every term used here.
Sources#
Ontology Development 101 by Noy and McGuinness (PDF), page 9: “All subclasses of a class inherit the slot of that class.”