> 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

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="/files/88BiNPIzdv1Ua0z0A3Y3" alt="" width="257"><figcaption></figcaption></figure>

**Fields**

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

<figure><img src="/files/pks8sGHk5PmfWe886pmc" 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="/files/AmXhxExp5qlwLyvfg2XS" 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`
