Introduction#
Add the limits that let okb check your data: fixed values, defaults and inverse slots.
You want every wine’s body to be light, medium or full, never “pretty strong”. A facet is how you say that. You already set several in step 5, with --values, --card and --min. This step adds the rest. You can read the full guide to this step in Method.
What you’ll make#
Facts that hold for a whole class, a default value, a link between maker and produces, and one pairing with a strength. The validate command now has more to check.
Run the commands#
First, join the two slots from step 5. They describe one fact from two sides, so make them inverses and okb stores the fact once:
okb relationship inverse maker produces
maker and produces are now inverses: one relationship read from both ends.
Stored as (Wine)-[:MAKER]->(Winery); produces follows MAKER backwards, so nothing is stored twice.
Next, set the fixed values. Every red wine is red, every dessert wine is sweet, and red wine goes with red meat. State each one once, on the class:
okb class fix RedWine color=red
okb class fix WhiteWine color=white
okb class fix RoseWine color=rose
okb class fix DessertWine sugar=sweet
okb class fix RedWine goesWellWith=RedMeat
okb class fix WhiteWine goesWellWith=Seafood
RedWine.color fixed to "red"
Fixed values apply to every subclass and instance and can't be changed below. For an overridable starting value use `okb class default`.
WhiteWine.color fixed to "white"
RoseWine.color fixed to "rose"
DessertWine.sugar fixed to "sweet"
RedWine.goesWellWith fixed to RedMeat
WhiteWine.goesWellWith fixed to Seafood
How good a pairing is belongs to the pairing itself, not to the wine or the food. A property on a link is called an edge property. Add a strength to goesWellWith, then record that red wine with red meat is a classic:
okb relationship property goesWellWith strength --type Enumerated --values classic,good
okb link RedWine goesWellWith RedMeat strength=classic
goesWellWith edges can now carry strength (Enumerated): (…)-[:GOES_WELL_WITH {strength: …}]->(…)
Updated (RedWine)-[:GOES_WELL_WITH {strength: "classic"}]->(RedMeat)
Last, a default. Most wines are medium-bodied, so set that once. A wine can still say something different:
okb class default Wine body=medium
New Wine instances will start with body = "medium" (can be changed per instance).
Read the output#
- Fixed versus default. A fixed value can’t change: no red wine is white. A default is a starting guess that any wine can override.
- Facts about classes.
goesWellWith=RedMeatis on the class, so it covers every red wine, including ones you add later. - Why strength is an edge property. “Classic” isn’t true of red wine or of red meat. It’s true of the pairing. Run
okb explain decision.edge-or-classto see how okb helps you choose.
Check your work#
Run the checks again. Facets are where okb catches most data-quality errors:
okb validate
okb status
✗ 0 error(s) ! 1 warning(s) i 2 hint(s) · checks for steps 1–6 (use --all for the rest)
WARNINGS: fix, or record a design decision explaining why not
! 'Merlot' doesn't add anything to 'RedWine': no own slots, values, restrictions or relationships. [hier-subclass-adds-something]
Fix: Add the slot, value, restriction or relationship that makes it different; or mark it
`terminological`; or merge it into its parent.
HINTS: worth a look
i The subclasses of 'RedWine' ('Bordeaux', 'Beaujolais', 'Merlot', 'Port') 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).
i The subclasses of 'Medoc' ('Pauillac', 'Margaux') 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 (2)
· Class 'Sauternes' looks plural, but the convention is singular. Try 'Sauterne'. [naming-singular-plural-consistent] → d.2
· 'Bordeaux' has only one direct subclass ('Medoc'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child] → d.3
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.)
Wine and Food · 21 classes · 11 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 ! 1 i 2 okb validate for details
Step 6 looks done. When you're happy with it: okb step next
validate shows one warning: Merlot “doesn’t add anything” to RedWine. That’s fair, because it has no slots or values of its own yet. You’ll fix it in step 7, when Merlot gets its grape. The step is done even so, because a warning isn’t an error. When step 6 has a tick, move on:
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 red wines are really pink, a fixed
color=redis wrong. Use a default.- Storing both directions. Joining
makerandproduceswithinversemeans you only ever write one of them.- Putting the strength on the wine. A wine has many pairings, and each one has its own strength.
Next step#
You set fixed values, a default, an inverse and a strength on a pairing. Next, you’ll add real wines and wineries to test the model.