What is a semantic layer?
Definition
A semantic layer describes the business meaning of records used for analysis. It can define metrics, dimensions and relationships, such as what counts as an active customer or how orders relate to customers. Some implementations enforce reusable calculations; others provide context that guides people and AI.
For example, “active customer” could mean an account with a completed order in the last 90 days, excluding test accounts. A useful definition records those choices so a second analyst can understand what the measure includes.
Why it matters
A shared definition can prevent two teams from using the same label for different calculations. Finance might include refunds in revenue while sales reports gross order value; both charts can look reasonable until someone tries to reconcile them. Recording the definitions and relationships makes those differences visible.
The detail to examine is how a tool uses that context. Descriptions can guide people and AI, while reusable calculation rules can apply a definition automatically. Those are different mechanisms, and understanding the distinction helps set expectations.
- Give important metrics an explicit calculation and time basis.
- Describe relationships, including whether one record can match several others.
- Record exceptions such as test accounts, cancellations or currency conversion.
Keep those definitions reviewed as the underlying business and data change.
Example: defining an active customer
A sales team asks, “How many active customers do we have?” The answer changes depending on whether “active” means signed in recently, has an open contract or placed an order.
A shared definition could record:
-
Entity: one customer account, identified by
customer_id. - Qualifying activity: at least one completed order in the previous 90 days.
- Exclusions: test accounts and cancelled orders.
- Time basis: the order’s completion date, using the business’s agreed time zone.
- Calculation: count distinct qualifying customer identifiers, not order rows.
Two completed orders from the same customer still count as one active customer. A cancelled order does not make a customer active under this definition. Linking the rule to the relevant fields makes it possible to review a query against the intended meaning.
In DataMaus, Data Context gives the AI business definitions and relationship information to use when generating queries. That guidance still needs to be reflected in the SQL: a definition alone does not force every independently written query to apply it.
Semantic layer vs data model
A data model describes the entities, attributes and relationships in a dataset. A semantic layer adds the business meaning used to interpret them, including agreed measures and categories. Some tools combine both responsibilities.
A model might show that orders belong to customers through customer_id. The semantic layer can then explain which orders count towards “active customers” or “net order value”. Knowing how tables connect helps construct a query; knowing what the business means helps choose the right calculation and filters.