In short#
A facet is a rule about the values a slot (a named field on a kind of thing) may hold, such as the type, the allowed words or how many values it takes.
flowchart LR accTitle: Facets are rules on a slot accDescr: The slot texture belongs to Milk drink. Its facets say the value must be one of silky, foamy or thick, and that it takes a single value. md["Milk drink"] -->|has slot| texture["texture"] texture -->|allowed values| vals["silky, foamy, thick"] texture -->|how many| one["single"]
Say a barista types “crunchy” for the texture of a latte. A slot with no rules accepts it. A slot with an allowed-values rule refuses it, and you find out at once instead of when a report goes wrong. Facets are those rules.
See it#
This slot comes from the espresso tutorial, for the made-up café Vertex Coffee (how to read the graphs). The graph shows slots too, so you can see the slot texture next to the kind it belongs to. Click the slot to read its rules.
The graph shows slots and the rules on them.
textureis attached to Milk drink. Its value type is Enumerated, and the allowed values are silky, foamy and thick. It takes one value.containsis attached to Drink. It links to Ingredient, takes many values and needs at least one.
Notice that the facets are of different kinds. The value type says what the value is: a whole number, text, one of a list, or a link. Cardinality says how many values: single or multiple, with an optional minimum. A facet can also be a fixed value, such as every lungo pulling 60 ml. The espresso ontology sets no numeric range on pullVolumeMl. It only says the value is a whole number and fixes it for Espresso (30), Ristretto (20) and Lungo (60).
In okb#
Try to break a rule. Run okb instance set with a texture that isn’t allowed.
okb instance set "Vertex cortado" texture=crunchy
okb instance set "Vertex cortado" pullVolumeMl=abc
✗ texture must be one of silky, foamy, thick; got 'crunchy'.
✗ pullVolumeMl needs a whole number; got 'abc'.
okb refuses both, so nothing is saved. The first message names the allowed values and the second names the value type.
Common mistakes
- Leaving a slot as free text. “Silky” and “silky ” become two different values, and queries miss them.
- No minimum on a required link. A drink that contains nothing passes, unless
containshas a minimum of 1.- A rule that’s too tight. If you forget “thick”, real drinks can’t be recorded.
Related pages#
- The espresso tutorial, step 6 sets these rules one by one.
- Choosing a range covers what a link may point to.
- What is slot inheritance? explains how a slot, and its rules, reach the classes below.
- Can a drink be two kinds at once? shows why a default is safer than a fixed value when two parents disagree.
- What is an inverse relationship? is the next page: it pairs two slots that read one link from each side.
- Glossary defines every term used here.
Sources#
Ontology Development 101 by Noy and McGuinness (PDF), page 9: “Slots can have different facets describing the value type, allowed values, the number of the values (cardinality), and other features of the values the slot can take.”