1. Home
  2. Explore
  3. Computer Science
  4. Ontologies vs Semantic Layers

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Ontologies vs Semantic Layers

Study Notes: Ontologies and Semantic Layers in Enterprise Data

The Problem of Shared Meaning

Every enterprise data team faces a fundamental challenge: there are hundreds of thousands of tables, columns, and dashboards, yet the concepts the business actually cares about — customer, revenue, churn, utilization — appear everywhere but mean slightly different things depending on who is using them and where.

This is not a new problem. Previous attempts include:

  • Data dictionaries in the 1990s

  • Enterprise data models in the 2000s

  • Master data management (MDM) initiatives

  • BI semantic layers (old kind: Cognos, Business Objects cubes)

Each made partial progress but left gaps. Two factors make the problem more urgent today:

  1. The modern data stack fragments definitions across more tools than ever: dbt YAML files, Looker ML explorers, Tableau calculated fields, wiki pages, and people's heads.

  2. AI is now a data consumer. When an LLM generates a query against a data warehouse, it needs to know what customer means precisely, not approximately.

Two frameworks have emerged as the most credible approaches to closing this gap: ontologies and semantic layers. They are often discussed as competing approaches, but they operate at different levels of abstraction, serve different audiences, and govern different kinds of change. Understanding this distinction is critical.


What Is an Ontology?

Ontology (data context): A formal specification of what kinds of things exist in a domain and how they relate to one another.

In practice, an ontology is the conceptual model a data architect designs before deciding on table structures or column types. It maps out entities (e.g., Customer, Account, Product, Order, Transaction) and defines relationships:

  • A Customer has one or more Accounts.

  • An Account belongs to one Legal Entity.

  • An Order contains one or more Line Items, each referencing a Product.

The ontology defines the possibility space of a domain — what can exist and how things can relate.

The Spectrum of Ontologies

"Ontology" carries baggage (OWL files, Protégé editors, multi-year projects). In reality, it exists on a spectrum:

  • Flat glossary: A list of terms with definitions (e.g., "Customer: an entity that has purchased at least one product"). Useful but captures no structure.

  • Hierarchical glossary: Terms have parent-child relationships (e.g., Customer is a type of Party; Retail Customer and Wholesale Customer are types of Customer).

  • Concept models / lightweight ontologies: Captures typed relationships beyond hierarchy — association, composition, etc. (e.g., Customer can have a Lifetime Value; Product belongs to a Product Category; Product Category maps to a Revenue Stream).

  • Formal ontology: Expressed in languages like OWL or RDF Schema, machine-readable, supports inference. Examples: SNOMED CT and FHIR in healthcare; FIBO in financial services. Powerful but expensive to build and maintain.

Practical takeaway: Most enterprise data teams don't need a formal ontology. They need something in the middle — structured enough to capture how concepts relate, light enough to maintain. That might be a well-organized business glossary with hierarchical terms and explicit relationships.


What Is a Semantic Layer?

Semantic layer: An abstraction between raw data and the people or systems consuming it, defining metrics and dimensions in a consistent way regardless of which tool or query is asking.

When we say "revenue" in a semantic layer, we are not defining what revenue is as a concept — we are defining how it is calculated:

  • Revenue = sum of completed order amounts, excluding tax, converted into the reporting entity's currency.

That formula, along with its dimensions (Time Period, Product Line, Geographic Region), is what the semantic layer governs.

Key Characteristics of the Modern Semantic Layer

It is declarative, version-controlled, and API-accessible:

  • Declarative: Definitions describe what to compute, not how to execute. The engine handles optimization.

  • Version controlled: Metric changes go through pull requests, code reviews, and deployment pipelines.

  • API accessible: Any consumer (not just the BI tool it was built for) can query the metric and get a consistent answer.

Examples of modern semantic layer tools include dbt's Metric layer (via MetricFlow), Looker's LookML, and AtScale and Cube.

What the Semantic Layer Does Not Cover

The semantic layer does not define what types of revenue exist and how they relate (e.g., recognized revenue vs. booked ARR vs. bill revenue are subtypes of a broader revenue concept with different accounting treatments). That structural knowledge lives in the ontology layer. The semantic layer assumes you already know what you want to measure; the ontology helps you understand the domain well enough to know what's worth measuring.


Comparison: Ontology vs. Semantic Layer

What Each Defines

  • Ontology: Entities, properties, and relationships. The nouns and verbs of the domain — Customer, Account, Product, belongs to, is a type of.

  • Semantic layer: Metrics, dimensions, and calculation logic. The measurements and aggregations — Revenue, Monthly Active Users, Churn Rate, SUM of X WHERE Y GROUP BY Z.

The Questions Each Answers

  • Ontology answers: "What is X? How does it relate to Y? What subtypes exist?" (e.g., What is a Customer? How does Customer relate to Account?)

  • Semantic layer answers: "How do we measure X? What is the formula? What dimensions can we slice it by?" (e.g., How do we calculate Monthly Active Customers? What is the formula for Customer Acquisition Cost?)

Ownership

  • Ontology definitions: Governed by data architects, data governance teams, or domain stewards — people who think about the conceptual structure of the business.

  • Semantic layer definitions: Governed by analytics engineers and BI teams — people who think about how metrics get computed and consumed.

These are often different people with different skills, tools, and change management processes.

How Change Propagates

  • Ontology change: High stakes, broad impact. If the business decides that "Customer" now includes free-tier users (not just paying accounts), every metric that references "Customer" is potentially affected — every dashboard, ML model, report. Needs deliberate governance.

  • Semantic layer change: Specific and traceable. If the revenue calculation is updated to exclude refunds processed within 30 days, you can identify exactly which dashboards and reports consume that metric through lineage. Meaningful but bounded.

Concrete Example: Revenue

A SaaS company has three revenue concepts:

  1. GAAP recognized revenue — has an accounting period and recognition schedule.

  2. Booked ARR — has a contract term and renewal date.

  3. Bill revenue — has an invoice date and payment status.

  • Ontology layer: Defines these as subtypes of Revenue, each with distinct properties. Captures that they are related but distinct concepts.

  • Semantic layer: Provides the calculation for each:

    • Recognized Revenue = SUM of recognized amounts per ASC 606 rules.

    • Booked ARR = annualized contract value of active subscriptions.

    • Bill Revenue = invoiced amounts in that period.

Without the ontology, the semantic layer picks one definition and hides the others (or teams build their own and call them all "revenue"). Without the semantic layer, the ontology tells you there are three types but gives no consistent way to calculate them.


When to Use Which: Scenario Analysis

Ontology-First Problem: Healthcare Network Merger

A healthcare network acquires three regional hospital systems. Each has its own definition of "patient encounter": one counts ER visits, one counts only admitted patients, the third includes telehealth sessions. Before any dashboard can be built, the fundamental question must be answered: What is an encounter in this organization? That is an ontology problem. The team needs to define "encounter" as a concept with subtypes (Emergency Visit, Inpatient Admission, Telehealth Session) and specify properties and boundaries. Mature healthcare ontologies (SNOMED CT, FHIR) provide a starting point. Once the ontology is agreed upon, the semantic layer can define calculations like average duration by encounter type, encounter volume by facility, etc.

Semantic-Layer-First Problem: E-commerce Conversion Rate

An e-commerce company has a clear product model and well-understood entities. The problem is that the marketing team and finance team calculate conversion rate differently: Marketing counts any session that leads to a cart addition; Finance counts only completed purchases divided by unique visitors. The entities are not in dispute — everyone agrees on what a session, visitor, and purchase are. The measurement logic is the conflict. This is a semantic-layer-first problem: define a unified metric with clearly labeled variants.

Both Required: Financial Services Regulation

A financial services firm reports to multiple regulators (Fed, OCC, CFPB), each requiring slightly different definitions of concepts like "exposure," "counterparty," and "collateral." Internally, the analytics team has built a semantic layer for risk dashboards. Regulators don't just want metrics; they want definitions traceable to regulatory ontologies like FIBO (Financial Industry Business Ontology). The semantic layer handles internal metric consistency; the ontology aligns entity definitions with external standards. The critical need is a layer that connects both — when a regulator asks "How do you define counterparty exposure?", the answer must trace from regulatory definition through ontology structure to a specific metric calculation to the data assets that feed it.

AI as a Data Consumer

When an LLM is deployed to answer "What was our customer retention rate in Q3?", it needs more than a metric formula. It needs to understand:

  • What a customer is (ontological knowledge)

  • What retention means in this business's context

  • How customers relate to accounts and subscriptions

  • Which data assets contain the relevant information

The semantic layer provides the calculation once the LLM knows what to calculate. The broader contextual understanding — preventing hallucinated business logic — comes from structured meaning at the ontological level.


The Context Layer: Connecting Ontology and Semantic Layer

The practical question: where does all this live? Ontological definitions in one system, semantic layer formulas in another, actual data assets in a third, with no connection between them. That is the state most organizations are in, and it is why the meaning problem persists.

Context layer: A platform where both ontological definitions and semantic layer metrics become discoverable, linked to the data assets they describe, and governed through consistent policies.

A context layer is not an ontology tool. It is not a semantic layer. It is the platform that does several things simultaneously:

  • Provides a business glossary with enough structural capability to capture not just definitions but relationships between terms (a lightweight ontology layer).

  • Integrates with source tools (dbt, Looker, Tableau), presenting their physical assets and automating linking to the glossary.

  • Maps lineage from raw data through transformations to consumption, showing how meaning flows through the stack — not just what the metric is, but where its inputs come from and what depends on its outputs.

  • Applies governance (classification, access policy, ownership) consistently across both ontological definitions and semantic layer metrics.


Practical Framework for Getting Started

Failure Mode 1: Starting with a Full Formal Ontology

Organizations spend 18 months modeling every entity and relationship in the domain, producing an artifact that is comprehensive, technically correct, and disconnected from any tool anyone actually uses. By the time it is done, the data landscape has shifted.

Solution: Start lighter. A well-structured glossary with hierarchical terms and clear ownership, connected to actual data assets, delivers 80% of the ontological value at 20% of the effort. Formalize further only where regulatory or AI requirements demand it.

Failure Mode 2: Deploying a Semantic Layer Without Ontological Clarity

The team defines 200 metrics in dbt, but without agreement on what the underlying entities mean. Different metrics use different entity definitions implicitly — "customer count" in one metric includes free-tier users, in another only paying accounts. The semantic layer faithfully calculates both, and the numbers disagree.

Solution: Define core entities first — even if it is just 10 terms in a glossary with clear boundaries — before defining the metrics that reference them.

Failure Mode 3: Building in Isolation from Where Practitioners Actually Work

Definitions that live in a wiki die there. Metrics defined in code but invisible to business users only serve the engineering team.

Solution: Use a context layer that makes both investments usable. A data analyst can search for "revenue", find the glossary definition, see the metric formula, trace the lineage, and check who owns it — all without leaving the platform.

Recommended Sequence

  1. Start with a business glossary that captures core entities and their relationships inside the context layer.

  2. Connect semantic layer tools so metric definitions surface alongside those entities.

  3. Let lineage show how meaning flows from definition to data to dashboard.

  4. Govern the whole thing with proportional governance: ontological changes get broader review; metric changes get targeted impact analysis. The context layer makes both kinds of governance possible because it knows what connects to what.


Key Takeaways

  • Ontology defines what things are and how they relate (structure). Semantic layer defines how things are measured and calculated (logic). One gives structure; the other gives numbers. Enterprises need both.

  • Most teams do not need a formal ontology; a well-structured business glossary with hierarchical terms and explicit relationships is often sufficient.

  • The modern semantic layer is declarative, version-controlled, and API-accessible. It ensures metric consistency across tools.

  • Change propagation differs: ontology changes are broad and high-stakes; semantic layer changes are specific and traceable.

  • The context layer is the practical platform that connects ontological definitions and semantic layer metrics to data assets, enabling discoverability, lineage, and proportional governance.

  • Avoid the three failure modes: don't over-model ontologies upfront, don't build metrics without entity clarity, and don't build in isolation from where practitioners work. Start light, connect tools, and let lineage guide governance.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent