Skip to content

Step 6: Facets

21 min · step 6 of 8

Introduction#

Narrow each slot: which values it allows, which are fixed, and which links are the same link read both ways.

A facet is a rule about a slot, such as how many values it takes. Facets make the ontology checkable. A fixed value is a value every member of a class has, such as “every lungo is 60 ml”. You can read the full guide to this step in Method.

What you’ll make#

A link with a property of its own, an inverse pair, and fixed values on the drinks and the milks.

Some facts belong to the link, not to either end. How much foam goes in a drink isn’t a fact about Foam or about the drink. It’s a fact about the pairing. Add an edge property to contains for that. Then join contains and usedIn so one stored edge reads both ways:

okb relationship property contains amount --type Enumerated --values splash,equal,topUp --desc "How much of the ingredient goes in."
okb relationship inverse contains usedIn
contains edges can now carry amount (Enumerated): (…)-[:CONTAINS {amount: …}]->(…)

contains and usedIn are now inverses: one relationship read from both ends.
Stored as (Drink)-[:CONTAINS]->(Ingredient); usedIn follows CONTAINS backwards, so nothing is stored twice.

Fix the facts#

Say each fact once, on the class. Every lungo is a 60 ml pull, and every cortado has equal parts espresso and milk. Run okb class fix:

okb class fix Espresso pullVolumeMl=30
okb class fix Ristretto pullVolumeMl=20
okb class fix Lungo pullVolumeMl=60
okb class fix Americano pullVolumeMl=30
okb class fix LongBlack pullVolumeMl=30
okb class fix Cortado espressoToMilkRatio=1
okb class fix FlatWhite espressoToMilkRatio=0.5
okb class fix WholeMilk fatPercent=3
okb class fix HalfAndHalf fatPercent=12
okb class fix CondensedMilk fatPercent=8
okb class fix Macchiato origin=Italy
okb class fix Mocha origin=USA
okb class fix ConPanna origin=Italy
okb class fix CafeBombon origin=Spain
okb class fix Cortado origin=Spain
okb class fix FlatWhite origin=Australia
okb class fix Affogato origin=Italy
Espresso.pullVolumeMl fixed to 30
Fixed values apply to every subclass and instance and can't be changed below. For an overridable starting value use `okb class default`.

Ristretto.pullVolumeMl fixed to 20

Lungo.pullVolumeMl fixed to 60

Americano.pullVolumeMl fixed to 30

LongBlack.pullVolumeMl fixed to 30

Cortado.espressoToMilkRatio fixed to 1

FlatWhite.espressoToMilkRatio fixed to 0.5

WholeMilk.fatPercent fixed to 3

HalfAndHalf.fatPercent fixed to 12

CondensedMilk.fatPercent fixed to 8

Macchiato.origin fixed to "Italy"

Mocha.origin fixed to "USA"

ConPanna.origin fixed to "Italy"

CafeBombon.origin fixed to "Spain"

Cortado.origin fixed to "Spain"

FlatWhite.origin fixed to "Australia"

Affogato.origin fixed to "Italy"

Set defaults and variations#

Not every fact is fixed. Most milk drinks are silky, so make that a default that a cappuccino can override. A latte and a cappuccino also get defaults for the ratio, because a breve is both and can’t carry two fixed values. Then record which drinks are variations of others:

okb class fix FlatWhite texture=silky
okb class default MilkDrink texture=silky
okb class default Cappuccino texture=foamy
okb class default Cappuccino espressoToMilkRatio=0.33
okb class default Cappuccino origin=Italy
okb class default Latte espressoToMilkRatio=0.2
okb class default Breve origin=USA
okb class fix Breve variationOf=Latte,Cappuccino
okb class fix Ristretto variationOf=Espresso
okb class fix Lungo variationOf=Espresso
okb class fix Americano variationOf=Espresso
okb class fix LongBlack variationOf=Americano
FlatWhite.texture fixed to "silky"

New MilkDrink instances will start with texture = "silky" (can be changed per instance).

New Cappuccino instances will start with texture = "foamy" (can be changed per instance).

New Cappuccino instances will start with espressoToMilkRatio = 0.33 (can be changed per instance).

New Cappuccino instances will start with origin = "Italy" (can be changed per instance).

New Latte instances will start with espressoToMilkRatio = 0.2 (can be changed per instance).

New Breve instances will start with origin = "USA" (can be changed per instance).

Breve.variationOf fixed to Latte, Cappuccino

Ristretto.variationOf fixed to Espresso

Lungo.variationOf fixed to Espresso

Americano.variationOf fixed to Espresso

LongBlack.variationOf fixed to Americano

Last, declare the drinks that can’t overlap:

okb class disjoint Espresso Ristretto Lungo Americano LongBlack
okb class disjoint Mocha ConPanna Affogato CafeBombon
okb class disjoint WholeMilk HalfAndHalf CondensedMilk
Declared disjoint: Espresso, Ristretto, Lungo, Americano, LongBlack. Nothing can be more than one of these now.

Declared disjoint: Mocha, ConPanna, Affogato, CafeBombon. Nothing can be more than one of these now.

Declared disjoint: WholeMilk, HalfAndHalf, CondensedMilk. Nothing can be more than one of these now.

Read the output#

  • Fixed versus default. A fixed value can’t change below the class. A default is a starting guess that a subclass or instance can override.
  • Why defaults for latte and cappuccino. Breve is a kind of both. If each fixed a different ratio, okb couldn’t tell which one a breve gets. A default lets Breve pick its own.
  • No disjoint group for the milk drinks. Breve is a latte and a cappuccino, so those two can’t be disjoint. okb’s hint later is fair, and you’ll leave it.

Check your work#

okb validate
okb status
✗ 0 error(s)   ! 0 warning(s)   i 4 hint(s)   · checks for steps 1–6 (use --all for the rest)

HINTS: worth a look
  i 'Drink' has only one direct subclass ('EspressoDrink'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child]
      Fix: Add the missing sibling(s), or remove the child and fold it into the parent. If
      neither applies, record a design decision.
  i 'Cappuccino' has only one direct subclass ('Breve'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child]
      Fix: Add the missing sibling(s), or remove the child and fold it into the parent. If
      neither applies, record a design decision.
  i 'Latte' has only one direct subclass ('Breve'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child]
      Fix: Add the missing sibling(s), or remove the child and fold it into the parent. If
      neither applies, record a design decision.
  i The subclasses of 'MilkDrink' ('Macchiato', 'Cortado', 'FlatWhite', 'Cappuccino', 'Latte') have no disjointness declared. Can anything be more than one of them? [disjoint-consider-siblings]
      Fix: `okb class disjoint A B C`, or ignore it if the siblings can overlap (Dessert Wine
      and White Wine can).

EXPLAINED by design decisions (3)
  · Subclasses of 'EspressoDrink' are named inconsistently: 'MilkDrink', 'SweetenedDrink' include 'drink' but 'PureEspresso' doesn't. [naming-subclass-names-consistent] → d.2
  · Subclasses of 'PureEspresso' are named inconsistently: 'Espresso' includes 'espresso' but 'Ristretto', 'Lungo', 'Americano', 'LongBlack' don't. [naming-subclass-names-consistent] → d.2
  · Subclasses of 'Milk' are named inconsistently: 'WholeMilk', 'CondensedMilk' include 'milk' but 'HalfAndHalf' doesn't. [naming-subclass-names-consistent] → d.4

Learn about any rule: okb explain <rule-id>   ·   add --why for reasons and sources
(6 warning(s)/hint(s) from later steps are hidden until you get there; okb validate --all shows them. Errors are never hidden.)

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)
✓ 6. Define the facets of the slots ◀ you are here
     ✓ Every slot has a value type and cardinality
     ✓ The slots have no known mistakes
○ 7. Create instances
○ 8. Review against your questions, and iterate

Validator (steps 1–6): ✗ 0  ! 0  i 4   okb validate for details

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

Step 7 of 8: Create instances

  Goal: Add real individuals: choose a class, create the instance, and fill in its slot values.
  Why it matters: Instances are the real test. Filling them in shows up missing slots, wrong
  facets and classes that don't fit.

Questions to answer
  • What are the most specific things that appear in answers to your competency questions? Those
  are your instances.
  • Which class does each belong to? (The most specific one that fits.)
  • Can you fill in every required slot? If not, is the data missing or is the facet wrong?

You're done when
  ○ At least a few instances (enough to answer one competency question end to end)
  ○ The instances have no known mistakes

Tips
  • Start with instances that answer one competency question completely. It's the fastest way to
  find gaps.
  • An instance that won't fit anywhere usually means a class is missing or a facet is too
  strict.

In Ontology 101's wine example
  • Château Morgon Beaujolais is an instance of Beaujolais, with:
  • body light, color red, flavor delicate, tannin low
  • grape Gamay, maker Château Morgon, region Beaujolais, sugar dry

Decision guides for this step  (okb explain <id>)
  decision.instance-or-class   Instance or class?

Commands
  okb instance add   okb instance set

Common mistakes

  • Fixing a value that has exceptions. If some cappuccinos are flat, a fixed texture=foamy is wrong. Use a default.
  • Storing both directions. Joining contains and usedIn with inverse means you only ever write one of them.
  • Declaring Latte and Cappuccino disjoint. A breve is both, so okb would report an error.

Next step#

You fixed the facts that never change and set one default. Next, you’ll add real things: the items on a café menu.

View page source