Knowledge Graph Academy · Modules 1 to 5 · the size of the schema

Why the TBox Stays Small

The TBox lists the types of thing. The ABox lists the things. Every adjective in a class name is a value that belongs in the ABox, and the class count shows it.

read six sections, then ten questionsscore 0/10
1 · Two boxes

The TBox says what types of thing exist; the ABox says which things exist

An ontology file has two layers that look alike in Turtle and do different jobs. The TBox (terminology) declares classes and properties: Person is a class, plays instrument is a property from a person to an instrument type. The ABox (assertions) states facts about individuals: Dana K is a person, Dana K plays guitar, Dana K was born on 14 March 1991. Between them sits the CBox (categories), the controlled lists the ABox picks values from: the instrument types, the genres, the occupations.

# one namespace for the whole music graph; the prefix says what the terms are about
@prefix music: <https://jesstalisman-ia.github.io/KGA-Knowledge-Checks/music#> .
@prefix skos:  <http://www.w3.org/2004/02/skos/core#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
# TBox: the types of thing, and the properties that connect them
music:person          a owl:Class ; rdfs:label "Person"@en .
music:plays-instrument a owl:ObjectProperty ; rdfs:domain music:person ; rdfs:range skos:Concept .
music:date-of-birth   a owl:DatatypeProperty ; rdfs:domain music:person ; rdfs:range xsd:date .
# CBox: the values a person may pick
music:guitar a skos:Concept ; skos:inScheme music:instruments ; skos:broader music:strings ; skos:prefLabel "Guitar"@en .
# ABox: one person, three facts
music:dana-k a music:person ; music:name "Dana K" ; music:date-of-birth "1991-03-14"^^xsd:date ; music:plays-instrument music:guitar .

Two questions sort any statement

Could this have many members? If yes, it describes a type. A type with its own properties and rules is a class in the TBox; a type that is one answer among a fixed list is a concept in the CBox. Can you point at it, date it, give it a serial number? If yes, it is one thing, and everything said about it goes in the ABox. "Guitarist" has members. "Dana K" has a birthday.

The three layers change at different speeds

LayerChanges whenHow oftenEdited by
TBoxa new type of thing, or a new type of relationship, enters the domaina few times a yearthe ontologist
CBoxa new allowed value appears: a genre, an instrument, a citymonthlythe vocabulary editor
ABoxa fact is learned: a new musician, a concert, a releasedailywhoever enters data
The prefix on this pageEvery term from the music graph is written music:, for https://jesstalisman-ia.github.io/KGA-Knowledge-Checks/music#. The SPARQL Practice Room binds the same terms to a shorter prefix; the names after the colon are the ones that count.

A fact about one musician must never require an edit to the schema. That sentence is the whole argument of this page. Every rule below is a way of keeping it true.

2 · The explosion

A value in a class name multiplies the TBox

A student wants to record that Dana plays jazz. The quickest way in Protégé is a new class: music:jazz-musician rdfs:subClassOf music:person. Rock, punk, house and the other genres follow, one class each. Dana also plays guitar, so the student adds music:jazz-guitarist, and the genres and instruments multiply: 12 genres and 30 instruments give 360 classes. Dana is based in Portland, so Portland and Seattle double it to 720. Then a new genre is added. Before a single fact about any musician is written, the ontologist has to create one genre class, 30 genre-and-instrument classes and 60 genre-instrument-city classes: 91 edits to the schema, for one word.

Dana plays guitar and electric guitar, in jazz and in rock. Under the subclass scheme Dana needs four types at once, and every one of them is a schema object somebody has to maintain. That is class explosion: the TBox grows as the product of the dimensions, and every fact about an individual turns into a schema edit.

as subclasses720classes: Person, one per genre, one per genre and instrument, one per genre, instrument and city. Adding one genre adds 91 classes.
as values44concepts in three taxonomies, picked through three properties on one class. Adding one genre adds one concept.

One class, three properties, three taxonomies

Before

music:jazz-guitarist-in-portland rdfs:subClassOf music:jazz-guitarist, which is a subclass of music:jazz-musician, which is a subclass of music:person. Dana gets four types. The genre list lives in class names.

After

music:dana-k a music:person ; music:performs-genre music:jazz, music:rock ; music:plays-instrument music:guitar, music:electric-guitar ; music:based-in music:portland . One type. The genre list is a SKOS scheme.

The question the subclasses were meant to answer survives the change. "Which jazz guitarists are based in Portland?" is three triples in a WHERE clause, and the class JazzGuitaristInPortland never has to exist.

PREFIX music: <https://jesstalisman-ia.github.io/KGA-Knowledge-Checks/music#>

SELECT ?name WHERE {
  ?p music:performs-genre music:jazz ;
     music:plays-instrument music:guitar ;
     music:based-in music:portland ;
     music:name ?name .
}
The adjective testRead the class name aloud as "a person whose something is something". JazzMusician is "a person whose genre is jazz". The part after whose is a property; the part after is is a value. Both belong outside the class name: the property in the TBox, the value in the CBox, the fact in the ABox.
If the class is ever neededOWL can define a class from a property: JazzMusician equivalent to Person and performs-genre value jazz. A reasoner then computes the members from the ABox facts, and nobody types the class on a person. The facts stay where they were. That is Module 6 material; this page keeps the values in the ABox.
3 · Subclasses

A subclass earns its place by adding a property or a rule

rdfs:subClassOf is a promise about every member for all time. Stating that Loud Weekend is a festival makes it an event in every query and every inference, because every festival is an event. The promise is cheap to make and expensive to break, so each subclass has to pass three questions.

  1. Is every member of the subclass a member of the parent, always? Every festival is an event. Every pianist is a person. Both pass; question 2 separates them.
  2. Do members need a property or a rule the parent lacks? A festival lasts several days, has a site and a line-up of headliners; a concert has one night and one headliner. Those are new properties and new rules, so Festival and Concert are classes under Event. A pianist has no property a person lacks. Pianist fails, and becomes a value of plays instrument.
  3. Would one individual keep landing in several sibling classes at once? Dana is a guitarist and an electric guitarist; Noor plays piano and synthesizer; Rafa is a musician and a producer. When members keep needing two or more siblings, the siblings are values of one property, and the property takes several values.
CandidateVerdictBecause
Festival under Eventclassnew properties (days, site) and a new rule (several headliners)
Band beside Personclassdifferent properties altogether: members, founding year; a band is never a person
Pianist under Personvalueno new property; Noor would need two sibling classes
JazzMusician under Personvaluean adjective in the name: performs-genre jazz
Composer under Personvaluean occupation; Sam is a musician and a composer, so has-occupation takes two values
StringInstrument under Instrumentconcepta branch of the instrument taxonomy; skos:broader, climbed by a query

The Module 5 music graph describes ten people, five bands, four venues, five events and four albums with twelve classes, fourteen properties and twenty-four concepts in three schemes. Its deepest hierarchy is two levels: Event with Concert and Festival under it. Depth in a TBox is rare; depth in a taxonomy is normal, because a taxonomy is where the types of types go.

4 · Object properties

An object property is a promise about both of its ends

A domain and a range in OWL are not checks. They are inferences. music:held-at has domain Event, so when somebody writes music:dana-k music:held-at music:blue-door, a reasoner concludes that Dana K is an event. No error appears; Dana is now an event in every query that asks for events. A property's domain and range therefore have to be true of every use of the property, for as long as the property exists. Three habits break that promise by multiplying properties.

HabitWhat it producesInstead
one property per pair of classesperforms-at-concert, performs-at-festival, performs-at-venueone music:performs-at with range Event. The event already knows whether it is a concert or a festival.
one property per valueplays-piano, plays-guitar, plays-cello: thirty properties, and a new instrument is a schema editone music:plays-instrument, with the instrument as the object and the list in a SKOS scheme
a relationship and its inverse both typed in by handmember-of and has-member as separate data, which drift apart the first time one is editedassert one. Declare owl:inverseOf if has-member is wanted as well, and let the reasoner or a ^music:member-of path supply it

The first two habits share a tell: a class name or a value name inside the property name. performs-at-festival contains a class; plays-piano contains a value. Fold the class into the range and the value into the object, and the property is general again.

A sub-property is the right tool when the special meaning is real

A headliner performs at an event and also closes it. That is one property with extra meaning, so it is a sub-property: music:headliner rdfs:subPropertyOf music:performs-at. A query for performers then returns the headliners too, and a query for headliners returns only them. A sub-property adds meaning; a property per class or per value only adds names.

Keep the domain as wide as the uses

In the music graph music:name is used on people, bands, venues, events and albums, so it declares no domain. A domain of Person on music:name would turn every named venue into a person by inference. Declare a domain when every subject really is of that class; otherwise leave it open and let the class of the subject come from rdf:type.

5 · Data properties

A data property ends the graph at a literal

A data property's value is a literal: a string, a number, a date. Nothing can link to a literal, nothing can be said about it, and it cannot be picked from a list. That makes the choice between the two property types a question about the value. Measurements, dates, names and codes are literals, and they take a data property with an xsd type. Anything people pick from a list, or that other things need to link to, is a node: a concept in the CBox or an individual in the ABox, reached through an object property.

City as a string

music:blue-door music:city "Portland" and, three rows later, music:riverside-arena music:city "Portand". Two cities now exist, one of them misspelt, and neither has a population, a region or a link to anything.

City as a node

music:blue-door music:located-in music:portland, where music:portland is one concept with one preferred label. A typo in a label is one fix; a query for venues in Portland finds both halls.

The Module 5 graph keeps music:city as a string because it is a small teaching set and the SPARQL lessons use FILTER(?city = "Seattle"). The moment a city needs a second fact, or a second spelling appears, it becomes a node.

Three ways data properties multiply

6 · Three files

Three files, three owners, three speeds

Separation of concerns in a knowledge graph means that each layer is edited by the people who own it, at the speed its content changes, without touching the others. The music graph ships as one file for teaching; a real project keeps three, and the boundary between them is the set of rules on this page.

LayerContainsWhat breaks when it leaks into another layer
TBoxclasses, properties with domain and range, the few subclass and sub-property links that add meaninga class per value: data entry has to edit the schema; a property per class: every query has to list a dozen properties for one relationship
CBoxconcept schemes: one preferred label per language, skos:broader, definitions and scope notesa concept used as a class: rdf:type music:jazz confuses every tool; a class used as a concept: skos:broader between classes is invisible to a reasoner
ABoxindividuals with rdf:type, their links to other individuals and to concepts, their literalsa string where a node should be: nothing can link to it, and spellings multiply; a fact typed in as a class: one-member classes everywhere

Seven mistakes to look for in any Turtle file

  1. A class name with an adjective in it: JazzMusician, PortlandVenue, SoldOutConcert.
  2. A class with one member, or a class whose members all share the parent's properties and nothing else.
  3. A property whose name contains a class or a value: performs-at-festival, plays-piano.
  4. A string where things need to link: a city, a genre, a label used as an identifier.
  5. An individual typed with a concept, or a concept with rdfs:subClassOf.
  6. A relationship and its inverse both typed in by hand.
  7. A literal without a datatype or a language tag.

Each of the seven is a layer boundary being crossed. The fix is the same every time: find which layer the content belongs to, move it there, and connect it back with a property.

7 · Knowledge check

Ten questions, one point each

Pick an answer; the explanation appears at once, with a link back to the section that teaches it.