> For the complete documentation index, see [llms.txt](https://docs.getdot.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getdot.ai/train-dot/model.md).

# Model

Train Dot on your data model, semantic layer, documentation, ...

Every good analysis is not just based on writing SQL, but on understanding how your business relates to the data you capture. The Model/Training space is for the data team to configure:

* Which data should Dot have access to?
* What does each table, column and row represent?
* What are existing analyses that can be build upon?

{% hint style="info" %}
**Edit safely with environments.** Every change here — selecting data, writing descriptions, defining relationships — can be made inside an [Environment](/train-dot/environments.md): an isolated copy of the model where you preview changes against real questions, then merge to production when you're ready.
{% endhint %}

## Select Data

**Datasource**\
Click on all the tables or explores that Dot will search through.

<figure><img src="https://3709841693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCeRlmJf2y704TpjpubE1%2Fuploads%2FsB8KAT6ybBDC5l8yZmY4%2Fgrafik.png?alt=media&amp;token=32c82158-4b8c-4106-aa63-bbaf1ef1f9b9" alt="" width="257"><figcaption></figcaption></figure>

**Fields**

Select all fields in a datasource that Dot should know about.

<figure><img src="https://3709841693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCeRlmJf2y704TpjpubE1%2Fuploads%2F11u12QsAL1VRJcM10UYz%2Fgrafik.png?alt=media&amp;token=0c7634d2-0fbb-48c2-8f22-01ee3d386e0a" alt=""><figcaption></figcaption></figure>

## **Describe Data**

You can click suggest to automatically generate documentation and fetch sample values. Make sure to save your changes.

## Define Relationships / Joins

Joining data across different tables is really powerful because it allows us to answer much more broad questions about our business. However, joining data correctly is requires a good understanding of the relationships between your tables.

To ensure Dot avoids join fan-outs or the chasm trap, you can predefine relationships.

For each table, you would specify the foreign key references.

Note:

* a foreign key can be composed key, consisting of multiple columns
* foreign keys should usually refer to primary or natural keys

**Example**

<figure><img src="https://3709841693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCeRlmJf2y704TpjpubE1%2Fuploads%2FafJN9quprakaHclNtKm4%2Fgrafik.png?alt=media&amp;token=3c522085-67c6-4313-bae1-dff30532dbcb" alt=""><figcaption></figcaption></figure>

Given the data model above, you want to define 2 Relationships:

* For Orders
  * Foreign Key: `user_id`
  * Referenced Table: `Users`
  * Referenced Keys: `id`
* For OrderItems
  * Foreign Key: `order_id`
  * Referenced Table: `Orders`
  * Referenced Keys: `id`
