# Table Relationships

You can connect separate tables via their shared dimensions using Dimension Relationship on Presight.

For example, in the Invoice table, each invoice line has a Customer ID, showing who is buying the products. Then, you will need to see all information about that customer: name, location, age... for further analysis, and the information belongs to Customer table. You will need **join two Tables via dimension Customer ID**

## 1. Joining tables to make Relationships via Data Relationship

You can create relationship via table view at <mark style="color:blue;">**Data Hub**</mark>**,** tab <mark style="color:purple;">**Data Relationship:**</mark>

<figure><img src="/files/IE6F9VfteDsj4MuibtGN" alt="" width="563"><figcaption></figcaption></figure>

You can just ***click, drag*** and ***drop*** at the column from one table to another column at another table to create relationship, then, a pop-up will appear for you to choose Relationship Type:

<figure><img src="/files/D6hAyjLxq9LkxvyU82TJ" alt="" width="563"><figcaption></figcaption></figure>

Choose the **`Relationship Type`**:

* **Belongs to** (Many to 1): when many records from Table A belong to one single record in Table B.
* **Has Many** (1 to Many): when one single record from Table A has many records in Table B.
* **Has One** (1 to 1): when one single record from Table A has only one record in Table B.

### Editing Relationships at the Data Diagram

You can also edit or delete relationships on the Data Diagram, by clicking on the relationship arrow and choose to <mark style="color:blue;">**View/ Edit Relationship**</mark> or to <mark style="color:red;">**Remove Relationship**</mark>:

<figure><img src="/files/qu1jOYbl1fraFvM4dz6r" alt=""><figcaption></figcaption></figure>

## 2. Creating Relationships by editing a dimension

* Find the **Dimension** you want to add a relationship and click **`Edit`**:

<figure><img src="/files/DfOZhLCUw51OHrRX8boF" alt=""><figcaption></figcaption></figure>

* Move to the tab <mark style="color:blue;">**Relationship**</mark>, and choose **`Edit Relationship`**

<figure><img src="/files/9swuDUpy8HoOM4h3jMSR" alt=""><figcaption></figcaption></figure>

* A box **`Add Another Relationship`** will appear and allows to add relationship.

<figure><img src="/files/VB5y8cT48VSjLmygdOHV" alt=""><figcaption></figcaption></figure>

* Choose the correspondent dimension from another table. In this case, dimension <mark style="color:blue;">**Customer ID**</mark> from Table <mark style="color:purple;">**internetSales**</mark> will match with dimension <mark style="color:blue;">**CustomerKey**</mark> from Table <mark style="color:purple;">**surveyReponse**</mark>.

<figure><img src="/files/fbk8Jb1Cm0q5bdv4M1f1" alt=""><figcaption></figcaption></figure>

* Choose the Relationship Type

<figure><img src="/files/KMXswlZ1Ax79QBrrRKtc" alt=""><figcaption></figcaption></figure>

* Then, click **`Update Relationship`** to finish the process

<figure><img src="/files/mwqjnWGSDVledQKtzDu8" alt=""><figcaption></figcaption></figure>

You can add many relationships once by clicking **`Add Another Relationship`**.

### Editing Relationships via editing Dimensions

You can edit or delete relationships in Dimension details:

<figure><img src="/files/OUpj6gHHFi9EMYIK1lw6" alt=""><figcaption></figcaption></figure>

* To edit, just change the Relationship Type, then then <mark style="color:blue;">**Update Relationship**</mark> to save you changes;
* To delete, click on the Trash icon <img src="/files/ZWvSeR7zpiEWH32jLpWQ" alt="" data-size="original">, then <mark style="color:blue;">**Update Relationship**</mark> to save your deletion.

## 3. View Connected Tables

You can view all table that are connected to the observing table by hover at the related dimension, the number shows how many tables are connected.

<figure><img src="/files/mGWKAAErGecYr70Isxir" alt=""><figcaption></figcaption></figure>

You can click on **Show All Connected Tables** to view all the tables.

<figure><img src="/files/jGooiHwogfs4iG6dUNRZ" alt=""><figcaption></figcaption></figure>

Click on **Show All Connected Tables** if you wish to hide connected tables.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://presight.gitbook.io/presight-v1.0/model/data-relationships/table-relationships.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
