Analytics Engineering · October 22, 2026 · 7 min
How do we make your data ready for an AI analyst?
The three layers I build, in order: structure, definitions and context. What each one is, what goes in it, and what my own experiment says it is worth.
By Achmad Nafila Rozie
Pointing an AI tool at a warehouse is easy. Getting answers you can trust from it is not. The model is rarely the weak part: it reads whatever the data gives it, including duplicated logic, two definitions of “active user” and rules nobody wrote down.
This is the order I build things in, so that people and AI tools read the same, correct definitions.
- 01 What the data is
Structure
Move logic out of long queries and dashboards into layered, tested dbt models.
Evidence Project 01 · the biggest single gain: +4 of 22 data questions
- staging
- intermediate joins
- grain
- core facts & dimensions
- dbt tests
- marts for BI
- 02 What the numbers mean
Definitions
One governed definition per number, in a semantic layer that people and AI tools both query.
Evidence Project 01 · the best score, but the least stable
- metric tree
- semantic models
- MetricFlow
- dimensions
- one owner per metric
- consistent naming
- 03 What the data cannot say
Context
Business rules and exceptions that live nowhere in the tables, written where an AI can read them.
Evidence Project 01 · business rules: 0 of 3 without a glossary, 3 of 3 with one
- business glossary
- rules & exceptions
- model & column docs
- metric descriptions
- example questions
- known caveats
Structure makes the data safe to query. Definitions make the numbers consistent. Context makes the answers correct. Each layer depends on the one before it.
01 · Structure: what the data is
Most teams already have the logic. It just lives in long SQL scripts, dashboard filters and spreadsheet steps. The first job is to move it into layered, tested dbt models.
- Staging. One model per source table: rename, cast types, nothing else. Every later model reads from here, not from raw tables.
- Intermediate joins. Clean joins and business logic written once, such as which orders count as completed.
- Grain. Every model states what one row means (one order, one user per day). Most wrong numbers come from a join that silently changed the grain.
- Core facts and dimensions. The shared tables that dashboards, analysts and AI tools all read.
- dbt tests. Uniqueness, not-null, accepted values and relationships, so a broken load fails loudly instead of shifting a number.
- Marts for BI. Pre-aggregated views for speed, built on core, never on raw data.
What the experiment showed. In Project 01, giving gpt-4.1 the intermediate models was the biggest single gain: +4 of 22 data questions. Clean joins removed most of the mistakes the model made on raw tables.
02 · Definitions: what the numbers mean
Once the structure is stable, each important number gets one governed definition, in a semantic layer that dashboards and AI tools both query.
- Metric tree. Start from the few numbers the business runs on and break them into the parts that drive them. This decides which metrics are worth defining first.
- Semantic models. Entities, measures and dimensions declared once, for example in MetricFlow.
- Dimensions. The cuts people actually ask for (country, platform, segment), defined in one place.
- One owner per metric. Someone who decides when the definition changes, and announces it.
- Consistent naming. The same name means the same calculation everywhere.
What the experiment showed. The metrics layer gave gpt-4.1 its best score on data questions, but it also varied most between runs. Definitions help most when the model is told when to use them, which is what the next layer is for.
03 · Context: what the data cannot say
Some rules live nowhere in the tables: which markets count as “standard”, which orders are excluded from revenue, why a metric changed in March. Without them, even perfect data gives a confident, wrong answer.
- Business glossary. Terms, in plain language, with the rule behind each one.
- Rules and exceptions. Exclusions, edge cases and known one-offs.
- Model and column docs. What each table is for and what each column means.
- Metric descriptions. When to use a metric, and when not to.
- Example questions. Real questions with the correct approach, so the AI sees what good looks like.
- Known caveats. Data gaps, late-arriving sources and broken periods.
What the experiment showed. On the three questions that depend on business rules, every arm without a glossary scored 0 of 3. With the glossary, both models scored 3 of 3.
Why this order
- Structure first, because definitions built on duplicated logic only make the wrong number official.
- Definitions second, because context needs a stable set of metrics to describe.
- Context last, but never skipped. It is cheap to write and it is where the final correctness comes from.
What you get
- Tested dbt models with a stated grain for every table.
- Governed metric definitions in a semantic layer, each with an owner.
- A business glossary and docs that both people and AI tools can read.
- A handover, so your team can keep it up without me.
If your dashboards and your AI tools disagree on the same number, this is the work I do. Book a call and bring the two numbers.