Skip to content

Ontology vs Knowledge Graph vs Semantic Layer: What Each Gives Your AI

Ontology vs Knowledge Graph vs Semantic Layer

Key Takeaways

  • Ontology vs knowledge graph is the difference between a model and the data it organizes. The ontology defines the types of things in a business, how they relate and the rules that apply, while the knowledge graph holds the actual customers, parts, orders and contracts connected by that model.
  • A semantic layer does a third job: one governed formula for each metric. It serves numbers such as revenue, churn or on-time delivery to BI tools and agents, usually without the entity, permission or policy rules an agent also needs.
  • AI agents answer most reliably when all three agree. Gartner's March 2026 data and analytics predictions say that by 2030, universal semantic layers will be treated as critical infrastructure alongside data platforms and cybersecurity.
  • The standards are converging. W3C's RDF 1.2 reached Candidate Recommendation in April 2026, and Apache Ossie, an open specification for both semantic layers and ontologies with more than 50 organizations behind it, entered the Apache Incubator in June 2026.
  • Start with the question that keeps going wrong. If the numbers disagree, start with the semantic layer, and if answers depend on how records relate and which rules apply, start with the ontology. A first release built on 10 to 20 business questions usually takes 8 to 12 weeks.

QUICK ANSWER

What is the difference between an ontology, a knowledge graph and a semantic layer? An ontology defines meaning: the types of things in your business, how they relate and the rules that apply. A knowledge graph holds your actual records connected according to that model, so a system can follow one customer to every order, part and contract tied to it.

 

A semantic layer serves governed metrics, such as revenue or churn, so every dashboard and agent calculates them the same way. AI agents need all three, and the ontology is what keeps the other two consistent.

The three terms get used interchangeably because each describes business meaning in a form software can read. They hold different things, though, and an AI agent missing any one of them fails in its own way: it picks the wrong meaning, misses a related record or calculates a number nobody in finance recognizes.

Mactores has built data platforms and AI agents on AWS since 2008. This guide draws on our context ontology work: the delivery method and platform choices we publish for context ontology engagements, a knowledge graph built from code during The New York Times' move off Oracle, and how we run the open-source Context Ontology Accelerator. The standards and research it cites were checked on November 17, 2026.

Three Terms, Three Jobs

An ontology defines what things mean, a knowledge graph holds the connected data that follows those meanings, and a semantic layer calculates governed numbers from that data. Each answers a different kind of question, and an agent often asks all three kinds in the same request.

 

Ontology

Knowledge graph

Semantic layer

What it is

A model of the types of things in your business, how they relate and the rules that apply

Your actual records stored as entities and relationships, organized by the ontology

A governed set of metric and dimension definitions

What it holds

Classes, relationships, attributes, rules and permissions

Customers, accounts, parts, orders and the links between them

Formulas, dimensions, joins, filters and time grains

Question it answers

"What counts as an active customer, and who may see one?"

"Which orders depend on this part, and for which customers?"

"What was on-time delivery last quarter, by region?"

Standards and formats

OWL for classes, SHACL for rules, R2RML for mappings

RDF with SPARQL, or a property graph with openCypher

dbt MetricFlow definitions, Apache Ossie YAML

Common choices on AWS

The Context Ontology Accelerator, with experts approving each element

Amazon Neptune or Neo4j, or a virtual knowledge graph over source databases

dbt, Cube, AtScale or Amazon Redshift

Who we'd have own it

A named business steward for each definition

Data engineering, for mappings and data quality

The team that reports each metric, reconciled to the report of record

What breaks without it

Each system's meaning wins in turn, so answers disagree

Agents guess joins and miss related records

Dashboards and agents give different numbers for one metric

The ontology vs knowledge graph line is the one that blurs most, because many teams store both in the same graph database. The ontology changes when the business changes a definition or a rule, while the knowledge graph changes with every new order, customer or shipment. A taxonomy is simpler than either, and the ontology vs taxonomy difference comes down to whether relationships and rules are modeled at all.

Ontology vs knowledge graph vs semantic layer: the ontology defines meaning with classes, relationships and rules in OWL and SHACL; the knowledge graph holds connected records in Amazon Neptune or a virtual graph over source systems; the semantic layer serves governed metrics through dbt, Cube, AtScale or Amazon Redshift; agents and BI tools read all three, and the ontology keeps the other two consistent

The Ontology

The ontology is the agreed description of your business that software can read: the kinds of things that exist, how they relate, what each term means and which rules and permissions apply. It usually holds definitions rather than records, and it tells every system and agent how to interpret the records.

Most of the work is agreement. Data ontology work usually starts with identity, meaning which records in which systems describe the same real thing, before it moves on to definitions and rules. That sequence is the core of ontology in AI, where a customer in the CRM, an account in billing and a tenant in the product become one concept with one owner.

Ontologies are written in open W3C standards. OWL defines classes and relationships, SHACL checks data against rules, and R2RML maps relational tables to graph terms, so the model stays yours rather than belonging to the tool that drafted it.

Drafting has become the quick part. The open-source Context Ontology Accelerator uses AI to draft an ontology from your databases and documents, and domain experts review, edit and approve every element before it's stored in a knowledge graph you own. AWS released it under Apache 2.0 on July 31, 2026. It shortens the drafting, but it doesn't settle ownership disputes or decide which system wins when two disagree, and those calls still need named business owners.

The Knowledge Graph

A knowledge graph is connected data stored as entities and relationships, organized by an ontology so a system can traverse it, from a part to every order that uses it and from each order to its customer and contract. Where the ontology says a customer can hold contracts, the knowledge graph records which customer holds which contract.

A knowledge graph and a graph database are different things. The database is storage, such as Amazon Neptune or Neo4j, and a knowledge graph can live in one or be virtual, querying source databases in place by translating graph queries into SQL instead of copying the data. A virtual knowledge graph is often the faster start, because the data stays in the systems that already govern it.

A graph earns its place when relationships, traversals and impact analysis are central to the questions. We don't force a graph database into every problem, because sometimes a well-governed semantic layer and catalog are enough, and sometimes graph-enhanced retrieval is what separates an AI system that guesses from one that can explain its answer.

Graphs are also how hidden rules come to light. At The New York Times, a knowledge graph built from the code surfaced rules in the PLATO subscription engine that nobody knew existed, which is part of how our legacy modernization with AI approach moved it off Oracle in 12 weeks against a 12 to 15 month manual estimate.

 

Knowledge graphs also carry provenance, which an agent needs to explain an answer. In April 2026, W3C invited implementations of RDF 1.2, whose main addition lets one triple be used as a term inside another, so a graph can record who asserted a relationship, from which source and when, on the relationship itself.

One more distinction keeps graph projects in scope. A knowledge graph holds what is true now, while a context graph holds what was decided and on what basis, and both use the ontology's terms.

The Semantic Layer

A semantic layer is a governed set of metric and dimension definitions that BI tools and agents use to calculate numbers the same way. It fixes what revenue, churn or on-time delivery means as a formula, along with the joins, filters and grain each calculation uses.

It's strong on quantities and thin on relationships and permissions. A semantic layer usually carries no tenant, entitlement or policy rules, and it doesn't describe the entities behind a metric or how they relate. Its metrics layer holds the formulas themselves, such as dbt MetricFlow definitions.

Its role is growing. Gartner's data and analytics predictions for 2026 state that "By 2030, universal semantic layers will be treated as critical infrastructure, alongside data platforms and cybersecurity."

The line between a semantic layer and an ontology is narrowing in the standards too. Open Semantic Interchange, renamed Apache Ossie when it entered the Apache Incubator in June 2026, describes itself as "an open specification for both semantic layer and ontology", and more than 50 organizations have joined its coalition. We map to it wherever a client's tools support it.

"They overlap, and a good semantic layer is often where an ontology starts."
Gautham B, Forward-Deployed Engineer, Data Engineering practice, Mactores
 

That's why we keep the metrics a company already trusts. Our approach to context ontology for software leaves the dbt models and metrics layer where they are, and the ontology reads those definitions instead of duplicating them, then adds what a metrics layer never held, such as which customer owns which tenant, what each plan entitles and which data a given agent may touch.

That combination is what a context layer for AI means in practice, and the semantic layer usually becomes part of it rather than a competitor to it.

How They Work Together for AI Agents

An agent uses the ontology to interpret the question, the knowledge graph to find the records it involves and the semantic layer to calculate any number in the answer, while the ontology's rules decide what it may show. You can see the split on your own stack with one question and the people who own the answer.

Pick a question that crosses systems, such as "Which open orders will miss their promised date because of a late part, and what does that do to this quarter's on-time delivery rate?" Ask your agent, then trace which layer had to supply each part of the answer.

Part of the question

Layer that answers it

What it supplies

What the agent does without it

"a late part"

Ontology

Which part codes in the ERP, the MES and the warehouse system are the same part

Checks one code and misses stock or orders filed under another

"promised date" and "open orders"

Ontology

Which date counts as promised and which order statuses count as open

Uses whichever date column it finds first

"which open orders"

Knowledge graph

The path from part to work order to sales order to customer

Guesses joins across systems and drops orders it can't connect

"on-time delivery rate"

Semantic layer

The governed formula, grain and filters for the metric

Writes its own formula, so its number disagrees with the dashboard

Who may see the answer

Ontology rules, enforced at query time

Which customers and contracts this user is entitled to see

Shows records the user shouldn't see, or refuses everything

The Context Ontology Accelerator is built around the same split. It answers agents in three tiers: governed metrics that need no model call, then structured queries over a virtual knowledge graph generated from the governed formula and checked by a SQL firewall, then document retrieval and synthesis. Tier 1 deliberately declines a question that carries a filter, a time window or a different aggregate it can't apply, so a governed number is never stretched to fit a question it wasn't defined for.

We put the ontology underneath the other two for that reason. The semantic layer's metrics and the graph's relationships both use its terms, so when operations changes which date counts as promised, the change is made once and both layers follow.

One question answered by three layers: for which open orders will miss their promised date because of a late part and what that does to on-time delivery, the ontology resolves part codes, the promised date and access rules, the knowledge graph traverses part to work order to sales order to customer, and the semantic layer applies the governed on-time delivery formula

Which One You Need First

Start with the question your agents or analysts keep getting wrong, then build the layer that question is missing. If the numbers disagree, start with the semantic layer. If the answer depends on which records are the same thing, how they relate or which rules apply, start with the ontology and let a focused knowledge graph follow.

If the recurring problem is

Start with

Why

Add next

Dashboards and agents give different numbers for the same metric

Semantic layer

One governed formula per metric fixes the disagreement where it starts

An ontology, once agents need more than numbers

The same customer, product or part has different IDs in different systems

Ontology

Identity has to be agreed before anything can be connected

A knowledge graph over the resolved entities

Questions cross more than two or three systems through relationships

Ontology and a knowledge graph

Traversals need both the model and the connected data

The semantic layer's metrics inside those answers

Agents act on records instead of only reporting on them

Ontology rules and permissions

Authority and access must be enforced where the agent reads

Graph and metrics as the questions require

A governed semantic layer and catalog already work well

Possibly nothing new

Sometimes they're enough

An ontology when agents start needing rules and relationships

Keep the first release small. A first release built around 10 to 20 business questions on a small set of sources usually takes 8 to 12 weeks from discovery to production, and larger programs ship as further dated releases.

Our context ontology services run in five phases: context and decision discovery, ontology and semantic modeling, knowledge graph and data integration, agent and application integration, then validation and handoff. Each phase ends with a signed exit, and nothing goes live until golden questions pass, access policies are tested and every definition has a named steward.

Ownership decides whether any of it lasts. We'd give each definition a named business steward, the mappings and data quality to data engineering, and each governed metric to the team that reports it, reconciled to the report of record.

If you're unsure which layer is missing, bring one question and three answers your agent gave, and walk through them with a forward-deployed engineer in a single working session. Within a week, you receive a diagnosis, a draft first-release scope and a target production date.

FAQs

Is an ontology the same as a knowledge graph?

No. An ontology defines the types of things, relationships and rules in a domain, and a knowledge graph holds the actual records connected according to that model. The ontology says what a customer and a contract are, and the graph says which customer holds which contract. Many teams store both in the same graph database, which is why the terms blur.

What is the difference between an ontology and a semantic layer?

A semantic layer defines metrics and dimensions so dashboards and agents calculate numbers the same way. An ontology also describes the entities behind those numbers, how they relate, and the rules and permissions that apply. The two overlap, and a good semantic layer is often where an ontology starts.

What is the difference between a semantic layer and a knowledge graph?
A semantic layer calculates governed numbers, such as revenue by region. A knowledge graph connects records, such as which customers depend on which parts. An agent uses the graph to find the records a question involves and the semantic layer to calculate any metric in the answer.
What is the difference between a knowledge graph and a graph database?

A graph database is storage, such as Amazon Neptune or Neo4j. A knowledge graph is connected data organized by an ontology, and it can live in a graph database or be virtual, querying source databases in place without copying the data.

What is the difference between a graph database and an ontology?
A graph database stores nodes and relationships of any kind. An ontology defines which kinds of nodes and relationships are valid in your business and which rules apply to them. You can run an ontology without a graph database, and a graph database without an ontology holds connected data with no agreed meaning.
Do AI agents need an ontology, a knowledge graph and a semantic layer?

Agents that answer questions across systems usually need all three: the ontology to interpret the question, the knowledge graph to find the related records and the semantic layer to calculate the numbers. An agent that only reports governed metrics can work from a semantic layer alone. Agents that act on records need the ontology's rules and permissions.

What is the difference between a semantic layer and a metrics layer?

A metrics layer is the part of a semantic layer that holds metric formulas, such as dbt MetricFlow definitions. The semantic layer adds the dimensions, joins, filters and access paths that BI tools and agents use to query those metrics.

Which standards do ontologies and knowledge graphs use?
Ontologies use the W3C standards OWL for classes and relationships and SHACL for rules, and R2RML maps relational tables into a graph. Knowledge graphs stored as RDF are queried with SPARQL, while property graphs use openCypher or Gremlin. Apache Ossie, in the Apache Incubator since June 2026, defines a YAML-based format for metrics, dimensions and their relationships.
Can we build an ontology without moving our data?
Yes. A virtual knowledge graph queries source databases in place by translating graph queries into SQL, so the ontology can sit over the warehouse, operational databases and SaaS applications you already run. We'd copy data into a graph store only when a question needs traversals the sources can't serve quickly enough.

 

Ammar Nizami, Senior Forward-Deployed Engineer, Data Engineering practice

Written by

Ammar Nizami

Senior Forward-Deployed Engineer, Data Engineering practice

Ammar leads a team of Forward-Deployed Engineers inside Mactores’ Data Engineering practice. Fifteen years in data engineering. Fifty-plus production Apache Iceberg engagements shipped. He owns the architecture calls that a customer’s data team cannot afford to get wrong — table format choice, partition strategy, migration sequencing, cutover under load — and hands the running platform back to the customer’s operations team on customer-signed acceptance. The complex Iceberg problems Mactores takes on are the ones his team solves.

Let's deliver

Bring us the process. We will bring the authority model.

The agent-native AWS modernization firm. Data platforms moved. Legacy retired. AI agents in production. AWS Premier Tier Services Partner since 2026, on AWS since 2008.

  • 01 AWS Premier Tier Services Partner, on AWS since 2008.
  • 02 Forward-deployed engineers own architecture, cutover and the date.
  • 03 Acceptance criteria per phase, with the signer named in the SOW.
  • 04 The golden set and the trace data belong to you.