Skip to content

Step 5: Slots

9 min · step 5 of 8

Introduction#

List the facts you can state about each class.

A slot is a fact you can state about a class, such as pullVolumeMl for an espresso drink. A slot comes in two kinds. A property holds a value, such as 30. A relationship links to another thing, such as the ingredients in a drink. okb stores a relationship as an edge in the graph. You can read the full guide to this step in Method.

What you’ll make#

Nine slots: six properties and three relationships. Each sits on the highest class where it makes sense, so every subclass inherits it.

Add properties#

Run the okb property add command. Put each slot where it’s true of everything below it: texture is about milk, so it goes on MilkDrink, not Drink.

okb property add pullVolumeMl --on EspressoDrink --type Integer --card single --desc "Milliliters of espresso pulled for one drink."
okb property add espressoToMilkRatio --on MilkDrink --type Float --card single --desc "Parts espresso per part milk, so 1 means equal parts."
okb property add texture --on MilkDrink --type Enumerated --values silky,foamy,thick --card single --desc "How the milk feels."
okb property add pourOrder --on Drink --type String --card single --desc "What goes in the cup first, and what goes on top."
okb property add fatPercent --on Milk --type Integer --card single --desc "Percent fat."
okb property add origin --on Drink --type String --card single --desc "Where the drink was first made."
Added property pullVolumeMl on EspressoDrink (Integer).

Added property espressoToMilkRatio on MilkDrink (Float).

Added property texture on MilkDrink (Enumerated).

Added property pourOrder on Drink (String).

Added property fatPercent on Milk (Integer).

Added property origin on Drink (String).

Add relationships#

Run okb relationship add for the links between things. A drink contains ingredients, and a drink can be a variation of another drink. usedIn is the same link as contains, read from the ingredient’s side. You’ll join them in step 6.

okb relationship add contains --from Drink --to Ingredient --card multiple --min 1 --desc "What goes into the drink."
okb relationship add variationOf --from Drink --to Drink --card multiple --desc "A drink this one is a twist on."
okb relationship add usedIn --from Ingredient --to Drink --card multiple --desc "Drinks the ingredient goes into."
okb show MilkDrink
Added relationship contains: (Drink)-[:CONTAINS]->(Ingredient).

Added relationship variationOf: (Drink)-[:VARIATION_OF]->(Drink).

Added relationship usedIn: (Ingredient)-[:USED_IN]->(Drink).

MilkDrink  Class · c.milk-drink
  An espresso drink with milk.
  parents        EspressoDrink
  subclasses     Macchiato, Cortado, FlatWhite, Cappuccino, Latte
  flags          abstract
  disjoint with  SweetenedDrink, PureEspresso

  Slots  (properties hold values; relationships → link to other things)
    espressoToMilkRatio Float, single
    texture            Enumerated, {silky, foamy, thick}, single
    pullVolumeMl       Integer, single (from EspressoDrink)
    pourOrder          String, single (from Drink)
    origin             String, single (from Drink)
    contains           Instance, → Ingredient (:CONTAINS), multiple, min 1 (from Drink)
    variationOf        Instance, → Drink (:VARIATION_OF), multiple (from Drink)

Sort the terms#

Go back to the list from step 3 and say what two of the terms turned out to be. “Pull volume” became a slot. “Tip jar” is out of scope:

okb term set "pull volume" --as slot --node pullVolumeMl
okb term set "tip jar" --as out-of-scope
'pull volume' → slot.
Linked to Slot 'pullVolumeMl'.

'tip jar' → out-of-scope.

Read the output#

  • Inherited slots. okb show MilkDrink lists slots from EspressoDrink and Drink as well as its own.
  • Properties versus relationships. contains shows an arrow and a type like :CONTAINS, the name of the edge okb will store. texture has no arrow, because it holds a plain value.

Check your work#

okb status
Espresso drinks  · 31 classes · 9 slots · 0 instances · 6 questions

✓ 1. Determine the domain and scope
✓ 2. Consider reusing existing ontologies
✓ 3. Enumerate important terms
✓ 4. Define the classes and the class hierarchy
✓ 5. Define the properties of classes (slots) ◀ you are here
     ✓ At least one slot
     ✓ Every slot is attached to at least one class
✓ 6. Define the facets of the slots
○ 7. Create instances
○ 8. Review against your questions, and iterate

Validator (steps 1–5): ✗ 0  ! 0  i 7   okb validate for details

Step 5 looks done. When you're happy with it: okb step next
okb step next
Now on step 6. (To read a step's guide without moving: okb explain 6)

Step 6 of 8: Define the facets of the slots

  Goal: For every slot, decide its value type, allowed values or range, cardinality, and any
  defaults, fixed values or inverse.
  Why it matters: Facets turn a list of fields into rules a machine can check. This is where
  most data-quality errors get caught later.

Questions to answer
  • Is the value text, a number, yes/no, one of a fixed list, or another thing (Instance)?
  • If it's a fixed list, what are all the allowed values?
  • If it's another thing, what is the most general class of things it can be (the range)? Not
  too general, not too narrow.
  • One value or many? Is it required (minimum 1)?
  • Is there a value most instances share (default), or one every instance of a class must have
  (fixed value)?
  • Is this relationship the reverse of another slot (maker ↔ produces)?
  • Does each link need extra information of its own, like a condition or a strength? (Edge
  properties; see decision.edge-or-class.)

You're done when
  ○ Every slot has a value type and cardinality
  ○ The slots have no known mistakes

Tips
  • When in doubt about range, pick the most general class that still only contains valid
  fillers.
  • Defaults are suggestions; fixed values are facts. Don't confuse them.

In Ontology 101's wine example
  • body: one of light, medium or full, and only one value
  • produces (on Winery): points to Wine, can have many values, and is the inverse of maker
  • grape: at least one value
  • Dessert Wine: sugar is fixed at sweet

Decision guides for this step  (okb explain <id>)
  decision.range               What should this slot's range be?
  decision.edge-or-class       Edge property, or make the relationship its own class?

Commands
  okb slot set   okb relationship inverse   okb relationship property   okb class fix   okb class default   okb class restrict

Common mistakes

  • Putting a slot too high. texture on Drink would claim an espresso has a milk texture.
  • Storing a link as text. The ingredients are things in the ontology, so use a relationship, not a string.

Next step#

You added nine slots. Next, you’ll set their rules: what values they can take, which are fixed and which are only defaults.

View page source