# Adding tables

> As your processes may have a data model that requires more tables than the tables available for the default app templates, you can add new tables using **Data transformations**. You can use these additional tables in your process app, and enrich your dashboards with filters and KPIs created on these tables to add extra value to your processes.

As your processes may have a data model that requires more tables than the tables available for the default app templates, you can add new tables using **Data transformations**. You can use these additional tables in your process app, and enrich your dashboards with filters and KPIs created on these tables to add extra value to your processes.

:::important
Always make sure your data model adheres the requirements. Check out [Data model requirements](https://docs.uipath.com/process-mining/automation-cloud/latest/user-guide/data-models#data-model-requirements).
:::

Only models that are materialized as table can be added to the data model. If you create a new process app, all models will be materialized as table. For existing process apps, the models in the **1_input** folder are materialized as view.

## Adding a new table

Follow these steps to create a new output table using **Data transformations**.

:::note
Make sure the data needed for your new table is available in your app. Check out [Loading data](https://docs.uipath.com/process-mining/automation-cloud/latest/user-guide/loading-data).
:::

1. Go to the **Data transformations** editor.
2. Locate the **models** section and add a new `.sql` file for the table in the transformations that you want to expose to your process app.

   ![Adding a table](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-adding-a-table-368547-94d4d198-43629006.webp)
3. **Run** the query for the new file. You can check the data for the new table in the **Preview** panel.
4. Select **Data model** to view the data model for your process app.
5. Select **+ Add table**. The **Add table** dialog is displayed.
6. Select the table that you added in step 2 from the **Select table** list.
7. Select the **Primary key** for the new table, and select **Done**.

   ![Add table dialog](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-add-table-dialog-368558-ace8b5e1-3906909f.webp)

The **Edit table** panel is displayed.

A notification is displayed that your data model does not meet the requirements.

![Edit table panel](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-edit-table-panel-368568-67a816bf-d3436545.webp)

## Connecting the table

Follow these steps to create a relation to connect the new table to the data model.

:::note
Make sure to adhere the **Data model requirements** when adding a relation.
:::

1. In the **Edit table** panel, select **+ Add new** to create a new relation.
2. Select the field that is used a the **Primary key** to join the tables.
3. Select the **Foreign key** and select **Apply**.

## Composite keys

Currently, relations in the data model are made from one field to the other. However, your data model might require composite keys, i.e. keys that are comprised from multiple fields. In this case, do the following:

1. Go to the **Data transformations** editor.
2. Locate the table that requires a composite key.
3. Add a field combining all composite fields in the select statement. The following code block contains an example.
   ```
   Select
     {{ pm_utils.concat('"Field_A"', '"Field_B"') }} as CompositeKey,
        table1.*
   from table1
   ```
4. Select **Run file** to populate the table.
5. Repeat steps 3. and 4. for each table that requires a composite key.
6. Go to the **Data model**.
7. Add a relation between the tables for which you defined a composite key and select the field you defined as `CompositeKey` from the **Key** list for each table.

## Making the new table available for use in dashboards

1. Select **Save** in the **Data model** editor to save the changes to the data model.
2. Select **Apply to dashboards** to run the transformations and make new the table available for use in dashboards.
   :::note
   This may take several minutes. Only if the run finishes successfully, the new table will show up in the **Data Manager.**
   :::
3. Select **Edit dashboards** and open the **Data Manager.** A message is displayed indicating that the new table is added.

   ![New data model conformation message](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-new-data-model-conformation-message-368592-59a6acc6-bd2b7c72.webp)
4. Select **Confirm** to continue.
5. Open **Data Manager**.

The new table is available in the list of tables.

![New table in Data Manager](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-new-table-in-data-manager-368648-c00f52a1-02d5ebee.webp)
