# Semantic Layer

**TL;DR:** A shared definition layer that turns raw tables into consistent business concepts, metrics, and relationships that anyone can query.

A semantic layer sits between your raw tables and everyone who wants to ask questions of them. It's where "active customer", "monthly recurring revenue", and "churn" get defined once, in code, with the joins and filters and edge cases written down, so that every dashboard, notebook, and AI assistant computes them identically. Tools like dbt Semantic Layer, Cube, AtScale, and LookML occupy this space.

The failure it prevents is the meeting where finance says revenue was $4.2M, sales says $4.7M, and the product team says $3.9M, and everyone is technically right because each team wrote their own SQL against the same warehouse with different assumptions about refunds, currency conversion dates, and whether trials count. That's not a data quality problem, it's a definition problem, and no amount of cleaning the underlying tables fixes it.

Concretely, the layer holds three things. Entities are the business objects (customer, order, subscription) and their identifying keys. Metrics are the calculations, expressed as an aggregation over a measure with its filters and its allowed dimensions. Relationships are the join paths between entities, defined once so consumers never hand-write a join and never accidentally fan out a sum across a one-to-many relationship.

The distinction from a data catalog is the one people miss. A catalog tells you the orders table exists, who owns it, and what columns it has. A semantic layer tells you what "completed order" means, that it excludes cancellations and test accounts, and how to correctly join it to customers without double-counting. Catalog is discovery; semantic layer is meaning. You need both, and most organizations buy the first and skip the second.

For AI systems this has become considerably more important than it was, because text-to-SQL against raw tables is a reliably disappointing product. The model has to infer business logic from column names, and it will confidently generate a query that joins two tables in a way that inflates every number by the row multiplier. Pointing the model at a semantic layer instead changes the task from "write correct SQL over 3,000 unfamiliar tables" to "pick the right metric and dimensions from a documented list", which is a task models are actually good at. The semantic layer becomes the guardrail: the model can only ask questions the layer knows how to answer correctly.

## Why it matters

Metric inconsistency is the reason executives stop trusting dashboards, and lost trust is much more expensive than the engineering time that would have prevented it. For AI specifically, the semantic layer is the difference between a natural-language analytics feature that works and one that quietly produces wrong numbers. It converts an open-ended generation problem into a constrained selection problem, which is the single highest-leverage move available for text-to-SQL reliability.

## Example

A SaaS company defines monthly recurring revenue in a semantic layer: sum of subscription value, excluding trials, excluding internal accounts, converted to USD at the rate on the invoice date, attributed to the month the subscription was active rather than the month it was billed. Every one of those clauses was previously a decision each analyst made independently. Now the CFO dashboard, the board deck, the sales compensation report, and the AI assistant that answers "what was MRR in Germany last quarter" all resolve to the same definition, and changing the definition changes all of them at once.

## Related terms

- [Data Catalog](https://www.maximem.ai/glossary/data-catalog)
- [Dataset](https://www.maximem.ai/glossary/dataset)
- [Data Product](https://www.maximem.ai/glossary/data-product)
- [Knowledge Graph](https://www.maximem.ai/glossary/knowledge-graph)
- [Structured Output](https://www.maximem.ai/glossary/structured-output)
- [Knowledge Systems](https://www.maximem.ai/glossary/knowledge-systems)

---

Source: [https://www.maximem.ai/glossary/semantic-layer](https://www.maximem.ai/glossary/semantic-layer)
