# Create a domain (/core/build/semantic-layer/how-to/create-a-domain)

:::info
**Target audience**: makers and admins. Explorers can't open the Domains page.
:::

### TL;DR [#tldr]

There are three ways to create a domain. They produce the same thing, so you can start with one and finish with another.

| Way | Best when |
| --- | --- |
| [**AI domain suggestions**](#let-the-ai-suggest-domains) | You are starting from a database and want a first draft to review. |
| [**By hand**](#build-a-domain-by-hand) | You know exactly which tables, fields and metrics you want. |
| [**With your AI agent**](#build-a-domain-with-your-ai-agent) | You already work in Claude, Cursor or VS Code and want to describe the domain in plain language. |

***

### Before you start [#before-you-start]

* **Connect the data source** and review its [AI analysis](../../analyze-your-database-with-ai/ai-analysis-overview.mdx). Descriptions, types and approved relationships are what both you and the AI build on.
* **Check column types.** A field's kind comes from its column's type: a number becomes a **measure**, a date a **datetime dimension**, anything else a **category dimension**. A numeric code that you group by, such as a store number, should be typed as text first.
* **Approve the relationships** you need. A table can only join a domain through an approved relationship.

***

### Let the AI suggest domains [#let-the-ai-suggest-domains]

AI domain suggestions read your data and build a domain with you, step by step. Nothing is created until you confirm. This option is only shown when an AI model is configured for your organization.

1. Open **Data**, go to **Domains**, and select **Suggest domains**.
2. Pick the **Data source** and the **Tables to read**. Past 30 tables, picking them is required: only those are read.
3. Optionally, answer **What should readers be able to ask?**, for example *"We want to compare sales performance between stores."* It helps the AI focus on what matters to your readers.
4. The AI proposes **domains**, each with a description, the likely tables, questions readers could ask, and a confidence score. Pick the one to build first.
5. Review the domain in three steps. In each, accept or reject every proposal, or use **Accept all** and **Reject all**, then confirm:
   * **Tables**: the main table, and each other table with how it joins and *what it brings*.
   * **Metrics**: each with its expression. The measures a metric uses come with it: accepting the metric accepts them too.
   * **Dimensions**: the columns readers will group and filter by.
6. Toucan AI creates the domain with what you accepted. Pick the next proposed domain to build, or select **End suggestions**.

:::info
A domain is one **business domain**, and the bigger it is, the less precisely the AI works with it. Thirty tables for a single subject is already a lot: if you need that many, you may be building a catch-all. Prefer several focused domains.
:::

Your organization runs one AI domain suggestion at a time. You can leave and **Resume** it later from the Domains page, or cancel it to start over.

:::info
Confidence and rationale help you decide during the review. They are not saved with the domain.
:::

***

### Build a domain by hand [#build-a-domain-by-hand]

#### 1. Create the domain [#1-create-the-domain]

On **Data** › **Domains**, select **New domain**. Give it a **Name** (for example *Subscriptions*) and a **Description** that says what it covers and who it's for: the AI assistant reads it to decide when to use this domain.

#### 2. Add its tables [#2-add-its-tables]

In **Tables & relationships**, select **Import the first table**: it becomes the **main table**, the one every join starts from. Pick the table your metrics are mostly about, such as `subscriptions` for a *Subscriptions* domain.

Then **Add table** for each other table. Toucan AI only offers tables that an approved relationship joins to a table already in the domain, and shows which relationship it uses. Turn on **Show the ones that can't be added** to see the others and what is missing. Review the changes, then **Save changes**.

#### 3. Add fields [#3-add-fields]

In **Fields**, select **Add field**, pick a table and a column, then fill in:

* **Name**: lowercase, with underscores, for example `order_amount`;
* **Label**: the displayed name, for example *Order amount*;
* **Description**: what the column holds;
* for a **measure**, its **Unit**;
* for a **datetime dimension**, the **Granularities** a chart may use (day, month and year are preselected);
* optionally, **Transforms**, such as converting a text column into a date.

#### 4. Add metrics [#4-add-metrics]

In **Metrics**, select **New metric** and fill in a **Name**, **Label**, **Description**, **Unit**, and the **Expression**, for example `SUM(order_amount)`. The **Available names** list shows the measures, dimensions and metrics you can use; click one to copy it. Add a **Filter** to keep only some rows before aggregating, for example paid orders only.

The editor checks the expression as you type and names what is wrong: an unknown name, a dimension outside `COUNT`, a loop between metrics. See [the expression rules](../metrics-dimensions-and-relationships.mdx#expressions).

***

### Build a domain with your AI agent [#build-a-domain-with-your-ai-agent]

With the **Maker MCP**, an AI agent such as Claude, Cursor or Codex reads your databases and creates domains, measures, dimensions and metrics for you. Describe the business meaning first:

> *"Create a Subscriptions domain over subscriptions, customers and plans. MRR is the sum of the monthly price of active subscriptions. Add total customers, cancelled customers and the churn rate, by plan and by month."*

You can also start from the result you want. Describe the data app, and ask the agent to *create the underlying domain* it needs to be built. Keep in mind that one domain is one business domain: ask for one focused domain per subject, not a single domain for the whole app.

The agent asks for your approval before each change, and it can't delete anything. See [Build with an AI agent](../../build-with-an-agent.mdx#model-your-data) to connect it.

***

### Change or delete a domain [#change-or-delete-a-domain]

Edit fields and metrics from their row in the domain. Delete a field, a metric or the whole domain from its **⋯** menu.

:::warning
A domain has no draft. Saving a change applies it right away to everything that uses the domain. Renaming or deleting a field or metric affects the charts and data apps that use it: see [The semantic layer in charts, dashboards and data apps](../semantic-layer-in-charts-and-data-apps.mdx).
:::

***

### Checklist for a good domain [#checklist-for-a-good-domain]

* The domain is **one business domain**, kept focused. Split catch-all domains by subject.
* The **description** of the domain, and of each metric, says what it is *and* what it excludes (refunds, test accounts, cancelled orders).
* Each metric has a **label** and a **unit**, so charts read well without extra work.
* Datetime dimensions only offer **granularities** that make sense for the data.
* No two metrics mean the same thing. If two teams compute *revenue* differently, name both explicitly (`gross_revenue`, `net_revenue`).
* Ask the AI assistant a few real questions and check it picks your metrics. See [The semantic layer for explorers](../semantic-layer-for-explorers.mdx).
