Theory · Page 10 of 34 · Meaning and metadata

10. Taxonomies, ontologies and knowledge graphs

A controlled vocabulary agrees the words; a taxonomy arranges them in a hierarchy; an ontology says what kinds of things exist and how they relate; a knowledge graph holds the facts in that shape, ready to be queried and reasoned over.

A list becoming a hierarchy, triples, classes and a query
Playback speed

The clip starts from a flat list of loss causes. They are arranged into a hierarchy: water above escape of water and flood, weather above storm and hail. The hierarchy is written as triples, each a subject, a predicate and an object. Then the ontology adds classes, Policy, Claim and Peril, and the properties between them. Facts about two policies and four claims join the graph. Last, a SPARQL query asks which claims have a cause under water and whether their policy covers it, and the answer lights up.

The intuition: from agreed words to connected facts

Harbour Mutual's claims system codes a burst pipe as escape of water, Kestrel's as WTR, and the claims portal lets customers type anything. Asking "how much did water damage cost us?" starts with agreeing the words: a controlled vocabulary, one list of loss causes with one preferred term each and the synonyms people actually use.

Some causes are kinds of others: escape of water and flood are both water damage. Arranging the terms in that hierarchy is a taxonomy, and now "water damage" can include everything beneath it, even causes added next year.

Then the questions get richer. Which policies cover escape of water? Which claims were caused by a peril their policy does not cover? These are about relationships between different kinds of thing: policies cover perils, claims are made against policies, claims are caused by perils. An ontology names those kinds of thing and their relationships; a knowledge graph holds the actual facts in that shape, and a query language walks it.

Remember Agree the words, arrange them, then say how kinds of things relate: vocabulary, taxonomy, ontology, and a graph of facts that follows the ontology.

The theory: SKOS, RDF, OWL and SPARQL

Each step adds structure. A controlled vocabulary is a list of agreed terms. A synonym ring groups terms that mean the same. A taxonomy arranges terms in a hierarchy of broader and narrower. A thesaurus adds associative links (related terms) and notes, as described in the standard ISO 25964. An ontology defines classes of things, the properties that relate them and rules about both, precisely enough for a machine to reason with.

RDF, the W3C's Resource Description Framework, is the data model under all of the W3C standards that follow. Every fact is a triple: a subject, a predicate and an object, such as Claim1, causedBy, EscapeOfWater. Subjects and predicates are IRIs, global identifiers that look like web addresses; objects are IRIs or literals, values such as a label in a language. A set of triples is a graph. Turtle is a compact text format for writing RDF.

SKOS, the Simple Knowledge Organization System, is the W3C's vocabulary for writing taxonomies and thesauri in RDF. A term is a skos:Concept in a skos:ConceptScheme; it has one skos:prefLabel per language, any number of skos:altLabel synonyms, and links with skos:broader, skos:narrower and skos:related. SKOS also has mapping links, such as skos:exactMatch, to connect concepts in two schemes: Harbour Mutual's loss causes to Kestrel's. Here is the loss-cause scheme, which passes rdflib and the SKOS integrity checks in CI:

The loss-cause taxonomy in SKOS, in English and Dutch (Turtle, checked with rdflib in CI)
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix hm: <https://cloud-data-architecture-lab.azurewebsites.net/id/theory#> .

hm:LossCauses a skos:ConceptScheme ;
    skos:prefLabel "Loss causes"@en, "Schadeoorzaken"@nl .

hm:Water a skos:Concept ;
    skos:inScheme hm:LossCauses ;
    skos:prefLabel "water"@en, "water"@nl ;
    skos:topConceptOf hm:LossCauses ;
    skos:narrower hm:EscapeOfWater ;
    skos:narrower hm:Flood .

hm:EscapeOfWater a skos:Concept ;
    skos:inScheme hm:LossCauses ;
    skos:prefLabel "escape of water"@en, "waterschade door leidingwater"@nl ;
    skos:altLabel "burst pipe"@en ;
    skos:broader hm:Water .

hm:Flood a skos:Concept ;
    skos:inScheme hm:LossCauses ;
    skos:prefLabel "flood"@en, "overstroming"@nl ;
    skos:broader hm:Water ;
    skos:related hm:Storm .

hm:Weather a skos:Concept ;
    skos:inScheme hm:LossCauses ;
    skos:prefLabel "weather"@en, "weer"@nl ;
    skos:topConceptOf hm:LossCauses ;
    skos:narrower hm:Storm ;
    skos:narrower hm:Hail .

hm:Storm a skos:Concept ;
    skos:inScheme hm:LossCauses ;
    skos:prefLabel "storm"@en, "storm"@nl ;
    skos:broader hm:Weather ;
    skos:related hm:Flood .

hm:Hail a skos:Concept ;
    skos:inScheme hm:LossCauses ;
    skos:prefLabel "hail"@en, "hagel"@nl ;
    skos:broader hm:Weather .

RDFS (RDF Schema) adds classes and the simplest rules: rdfs:subClassOf, and a property's rdfs:domain and rdfs:range, the classes of its subjects and objects. OWL 2, the Web Ontology Language, adds much more: classes that are disjoint, properties that are inverse, transitive or functional, and class definitions by restriction (a covered claim is a claim whose peril its policy covers). A reasoner uses these rules to infer facts nobody wrote down: if hasClaim is the inverse of againstPolicy, every claim against PolicyA makes PolicyA have that claim.

The ontology and its facts in OWL: classes, properties, an inverse, and two policies and four claims (Turtle, checked with rdflib in CI)
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix hm: <https://cloud-data-architecture-lab.azurewebsites.net/id/theory#> .

hm:ClaimsOntology a owl:Ontology .

hm:Policy a owl:Class ; rdfs:label "Policy"@en .
hm:MotorPolicy a owl:Class ; rdfs:subClassOf hm:Policy ; rdfs:label "Motor policy"@en .
hm:Claim a owl:Class ; rdfs:label "Claim"@en .
hm:Peril a owl:Class ; rdfs:label "Peril"@en .
hm:Policy owl:disjointWith hm:Claim .

hm:againstPolicy a owl:ObjectProperty ; rdfs:domain hm:Claim ; rdfs:range hm:Policy .
hm:hasClaim a owl:ObjectProperty ; owl:inverseOf hm:againstPolicy ; rdfs:domain hm:Policy ; rdfs:range hm:Claim .
hm:causedBy a owl:ObjectProperty ; rdfs:domain hm:Claim ; rdfs:range hm:Peril .
hm:covers a owl:ObjectProperty ; rdfs:domain hm:Policy ; rdfs:range hm:Peril .

hm:EscapeOfWater a owl:NamedIndividual, hm:Peril .
hm:Flood a owl:NamedIndividual, hm:Peril .
hm:Hail a owl:NamedIndividual, hm:Peril .
hm:Storm a owl:NamedIndividual, hm:Peril .
hm:PolicyA a owl:NamedIndividual, hm:Policy ;
    hm:covers hm:EscapeOfWater, hm:Storm .
hm:PolicyB a owl:NamedIndividual, hm:Policy ;
    hm:covers hm:Storm, hm:Hail .
hm:Claim1 a owl:NamedIndividual, hm:Claim ;
    hm:againstPolicy hm:PolicyA ;
    hm:causedBy hm:EscapeOfWater .
hm:Claim2 a owl:NamedIndividual, hm:Claim ;
    hm:againstPolicy hm:PolicyA ;
    hm:causedBy hm:Flood .
hm:Claim3 a owl:NamedIndividual, hm:Claim ;
    hm:againstPolicy hm:PolicyB ;
    hm:causedBy hm:Hail .
hm:Claim4 a owl:NamedIndividual, hm:Claim ;
    hm:againstPolicy hm:PolicyB ;
    hm:causedBy hm:EscapeOfWater .
Open world, closed world A database assumes a closed world: if a fact is not in the table, it is false. RDF and OWL assume an open world: a missing fact is unknown, because someone else may state it. OWL also does not assume that two names mean two different things. So OWL alone cannot say "this claim has no cause"; validating data against required shapes is the job of SHACL, the W3C's shapes language, which checks a graph under a closed world.

SPARQL is the query language for RDF. A query is a pattern of triples with variables; the answer is every way the graph can fill the variables. Property paths follow links any number of times: skos:broader* reaches every concept above a given one. This query runs on the taxonomy and the ontology together, because the perils in one are the same IRIs as the concepts in the other:

Which claims have a cause under water, and does their policy cover it? (SPARQL, run with rdflib on both graphs together in CI)
PREFIX hm: <https://cloud-data-architecture-lab.azurewebsites.net/id/theory#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?claim ?cause ?covered
WHERE {
  ?claim hm:causedBy ?cause ;
         hm:againstPolicy ?policy .
  ?cause skos:broader* hm:Water .
  BIND (EXISTS { ?policy hm:covers ?cause } AS ?covered)
}
ORDER BY ?claim

It finds 3 claims whose cause falls under water, and 2 of them were caused by a peril their own policy does not cover: a question no single table holds, answered by walking the hierarchy and the relationships at once.

Knowledge graphs come in two families. RDF graphs, described above, follow W3C standards with global identifiers and are strong at integrating data from many sources and reasoning over it. Labelled property graphs, as in Neo4j, put properties on both nodes and edges and are queried with Cypher or GQL, the ISO graph query language published in 2024; they are strong at traversal and analytics inside one application. Both can follow an ontology; only RDF makes the ontology itself data in the same graph.

Why it matters

Merging two insurers is mostly merging meaning. A SKOS mapping from Kestrel's loss causes to Harbour Mutual's lets reports regroup without rewriting either system. An ontology of policies, perils and claims lets the AI assistant of chapter 34 answer "is this covered?" from facts it can cite, instead of guessing from text.

Most organisations need a taxonomy long before an ontology. The judgement is knowing when a hierarchy of words is enough, and when the questions are really about relationships.

Where it goes wrong

  • An ontology where a list would do. Classes, properties and a reasoner for a dozen codes that only need grouping is cost without return.
  • A hierarchy that mixes relations. "Is a kind of" (flood is water damage) and "is part of" (a roof is part of a house) in one tree breaks every query that rolls up.
  • Expecting OWL to validate. Under the open world a missing fact is not an error; use SHACL, or database constraints, for required data.
  • Labels as identifiers. Linking by the label "storm" breaks when the label is translated or corrected; link by IRI.
  • No owner. A vocabulary nobody maintains drifts from the codes systems actually use, and people stop trusting it.

Check yourself

Choose an answer to each question, then press Check.

1. What is a triple in RDF?
2. Which SKOS property links a concept to a more general one?
3. Why can OWL alone not report that a claim has no cause recorded?
Answer every question first.

Sources

The works this page draws on, summarised in its own words rather than quoted. Read them for the full argument.

  • W3C, RDF 1.1 Concepts and Abstract Syntax, and RDF 1.1 Turtle (Recommendations, 2014)Triples, IRIs, literals and graphs, and the Turtle syntax used on this page.
  • W3C, SKOS Simple Knowledge Organization System Reference (Recommendation, 2009)Concepts, schemes, preferred and alternative labels, broader, narrower and related, mapping properties and the integrity conditions.
  • W3C, OWL 2 Web Ontology Language Document Overview, 2nd edition (Recommendation, 2012), and RDF Schema 1.1 (2014)Classes, subclasses, domains and ranges, inverse and disjoint declarations, and reasoning under the open world assumption.
  • W3C, SPARQL 1.1 Query Language (Recommendation, 2013)Graph patterns, property paths, BIND and EXISTS.
  • W3C, Shapes Constraint Language (SHACL) (Recommendation, 2017)Validating an RDF graph against shapes, under a closed world.
  • ISO 25964-1:2011, Thesauri for information retrievalControlled vocabularies, thesauri and their relationships.

Practise it

The chapters that put this theory to work on Harbour Mutual and Kestrel:

The tools to try it in:

Terms taught here: TaxonomyControlled vocabularySKOSOntologyKnowledge graphTripleOWLSPARQL

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Cloud Data Architecture Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.