11. Ontologies and knowledge graphs
A taxonomy says what is a kind of what. An ontology adds named relationships (causes, is covered by, is made against), and the facts written with it form a knowledge graph you can query, and that an AI assistant can answer from.
The clip starts from three loss causes of the taxonomy: burst pipe, water damage and storm. Relationships with names are added: a burst pipe causes water damage; water damage is covered by the buildings cover, a storm by the storm and flood cover. The facts join: a customer holds a policy with both covers, and a claim is against it, caused by a burst pipe. Asked whether the claim is covered, the graph follows the links and lights the path. Then the graph grounds an AI assistant, a vector index retrieves only a similar paragraph, and a closing note says when a glossary is enough.
The idea: name the relationships
An ontology says what kinds of things a subject has and how they can relate: a Claim is made against a Policy, a Policy has Covers, a Loss cause can cause another and can be covered by a Cover. Each relationship has a name, a kind of thing it starts from (its domain) and a kind it points to (its range).
The facts written with those names form a knowledge graph: claim CL-2025-00042 is made against policy HM-04-000042; its cause is a burst pipe; a burst pipe causes water damage. Each fact is a triple of subject, relationship and object. Because the relationships are named, you can ask the graph questions no single table answers, such as which claims are covered by their own policy, by following the links.
A worked example: is the claim covered?
Harbour Mutual's claims ontology has 5 classes and 6 relationships, and its graph 17 facts about 8 things. The query below asks which claims are covered by their own policy: it follows each claim's cause, and what that cause causes, to the covers that pay, and keeps the covers the claim's policy has. It returns 1 answer.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX lc: <https://cloud-data-architecture-lab.azurewebsites.net/id/loss-causes/>
PREFIX hm: <https://cloud-data-architecture-lab.azurewebsites.net/id/claims#>
SELECT DISTINCT ?claim ?cover WHERE { ?claim hm:hasCause ?cause ; hm:against ?policy . ?cause hm:causes* ?x . ?x hm:coveredBy ?cover . ?policy hm:hasCover ?cover } ORDER BY ?claim ?cover@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 dct: <http://purl.org/dc/terms/> .
@prefix hm: <https://cloud-data-architecture-lab.azurewebsites.net/id/claims#> .
<https://cloud-data-architecture-lab.azurewebsites.net/id/claims> a owl:Ontology ;
rdfs:label "Harbour Mutual claims ontology"@en .
hm:Party a owl:Class ;
rdfs:label "Party"@en ;
rdfs:comment "Anyone Harbour Mutual deals with, in any role."@en .
hm:Policy a owl:Class ;
rdfs:label "Policy"@en ;
rdfs:comment "One term of cover for one party and one product."@en .
hm:Cover a owl:Class ;
rdfs:label "Cover"@en ;
rdfs:comment "A section of a policy that pays for a kind of loss."@en .
hm:Claim a owl:Class ;
rdfs:label "Claim"@en ;
rdfs:comment "A loss reported against one policy."@en .
hm:LossCause a owl:Class ;
rdfs:label "Loss cause"@en ;
rdfs:comment "What caused a loss, from the loss-cause taxonomy."@en .
hm:holds a owl:ObjectProperty ;
rdfs:label "holds"@en ;
rdfs:domain hm:Party ;
rdfs:range hm:Policy .
hm:hasCover a owl:ObjectProperty ;
rdfs:label "has cover"@en ;
rdfs:domain hm:Policy ;
rdfs:range hm:Cover .
hm:against a owl:ObjectProperty ;
rdfs:label "is made against"@en ;
rdfs:domain hm:Claim ;
rdfs:range hm:Policy .
hm:hasCause a owl:ObjectProperty ;
rdfs:label "has cause"@en ;
rdfs:domain hm:Claim ;
rdfs:range hm:LossCause .
hm:causes a owl:ObjectProperty ;
rdfs:label "causes"@en ;
rdfs:domain hm:LossCause ;
rdfs:range hm:LossCause .
hm:coveredBy a owl:ObjectProperty ;
rdfs:label "is covered by"@en ;
rdfs:domain hm:LossCause ;
rdfs:range hm:Cover .
hm:customer-26 a owl:NamedIndividual, hm:Party ;
rdfs:label "Jan de Vries"@en ;
hm:holds hm:policy-hm-0042 .
hm:policy-hm-0042 a owl:NamedIndividual, hm:Policy ;
rdfs:label "Home Buildings policy HM-04-000042"@en ;
hm:hasCover hm:cover-buildings, hm:cover-storm-flood .
hm:cover-buildings a owl:NamedIndividual, hm:Cover ;
rdfs:label "Buildings cover (section 3)"@en .
hm:cover-storm-flood a owl:NamedIndividual, hm:Cover ;
rdfs:label "Storm and flood cover"@en .
hm:claim-cl-0042 a owl:NamedIndividual, hm:Claim ;
rdfs:label "Claim CL-2025-00042"@en ;
hm:against hm:policy-hm-0042 ;
hm:hasCause hm:burst-pipe .
hm:burst-pipe a owl:NamedIndividual, hm:LossCause ;
rdfs:label "Burst pipe"@en ;
hm:causes hm:water-damage ;
hm:coveredBy hm:cover-buildings .
hm:water-damage a owl:NamedIndividual, hm:LossCause ;
rdfs:label "Water damage"@en ;
hm:coveredBy hm:cover-buildings .
hm:storm a owl:NamedIndividual, hm:LossCause ;
rdfs:label "Storm"@en ;
hm:coveredBy hm:cover-storm-flood .
Why it matters for Alex
Harbour Mutual's AI pilot quoted a withdrawn policy wording (chapter 2). The board now wants an assistant for claims handlers, and Alex will be asked whether it needs a knowledge graph. The honest answer depends on the questions. "Is this claim covered?" needs facts and relationships: the claim, its cause, the policy and its covers. A vector index over the documents finds paragraphs that sound similar; it cannot follow a claim to its policy. Grounding the assistant in the graph (graph-based retrieval) gives exact answers with the path behind them.
But a graph is a model someone must build and keep current. If people mostly ask what words mean, a business glossary (chapter 12) is enough, and far cheaper. And to find a passage of text, a vector index is the right tool.
Where it goes wrong
- A graph of everything. An enterprise ontology modelled for years before it answers one question. Start from the questions, and model only what they need.
- A graph nobody keeps current. Facts copied in once go stale; feed the graph from the systems of record, as any other data product.
- Vectors for questions of fact. "Is it covered?" answered from the most similar paragraph is a guess that sounds sure.
- A graph where a glossary would do. If nobody needs to follow relationships, a list of agreed definitions does the job at a fraction of the cost.
Exercises
The lab checks each one against facts written down in advance, so any answer the brief allows passes. A pass is kept in this browser.
Make the graph answer three questions
The claims assistant must answer three questions from the graph, but three links are missing. 1. Which cover pays for a burst pipe? (Buildings cover, section 3.) 2. Is claim CL-2025-00042 covered by its own policy? (Yes, by the buildings cover.) 3. Which covers pay for a storm, now that the graph should record that a storm causes water damage? (Both covers.)
The lab checks that:
- Question 1: the graph says the buildings cover, and only that, pays for a burst pipe.
- Question 2: claim CL-2025-00042 is covered by its own policy's buildings cover.
- Question 3: a storm causes water damage, so both covers pay for a storm.
Follow the links
Using the claims graph from the clip, choose which covers pay for each cause. Follow "causes" as far as it goes, then "is covered by".
Choose what grounds the assistant
What should the claims assistant answer this kind of question from: the knowledge graph, a vector index of the documents, or the business glossary? Pass all 3 situations to complete it.
Handlers ask the assistant whether a claim is covered by its policy: the claim's cause, what that cause leads to, and which of the policy's covers pays.
On Azure
Azure offers the parts, not a finished knowledge graph:
- Storing the graph: Azure Cosmos DB for Apache Gremlin stores property graphs. Azure has no managed RDF store, so a graph kept in OWL and Turtle, like this chapter's, is stored as files in Git or the lakehouse, or in an RDF database you run yourself.
- Grounding an assistant: an assistant built with Microsoft Foundry (formerly Azure AI Foundry) can call your graph's queries as a tool, beside Azure AI Search for documents. GraphRAG, an open-source project from Microsoft Research, builds a graph from documents to improve retrieval; it is a different thing from a curated ontology like this one.
- The vocabulary in the catalogue: the classes and terms that people need to read belong in the Microsoft Purview Unified Catalog's glossary, linked to the data (chapter 12).
Whatever stores it, keep the ontology small, owned and fed from the systems of record.
Take it to work
Knowledge graph or not?
Decide whether a use case needs a knowledge graph, before anyone builds one.
The questions
- Write down the five questions it must answer.
- Which need relationships followed, which a passage of text, which only a definition?
The model
- The classes and the named relationships the questions need, and nothing more
The facts
- Which systems of record feed each class, and how often?
The decision
- Graph, vector index, glossary, or a combination: and why
Tools in this chapter
- Taxonomy and ontology builder · Build a hierarchy or a small graph, export it as SKOS or Turtle, and query it.
- Retrieval workbench · Chunk and index Harbour Mutual's documents with their access rights, and ask questions as different roles.
Terms taught here: OntologyKnowledge graphTripleOWLSPARQLVector index