> For the complete documentation index, see [llms.txt](https://docs.reorc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reorc.com/semantic-modeling/cube/relationship.md).

# Relationship

## Overview

A **Relationship** in ReOrc defines how different Cubes are connected, enabling seamless data integration and enhancing analytical capabilities. Establishing relationships between Cubes ensures consistency, improves query performance, and facilitates the creation of meaningful Views.

## Concept of Relationship

A **Relationship** represents the logical connection between two or more Cubes based on common keys. These relationships allow data from multiple Cubes to be combined, enabling cross-referencing and enriched analysis.

#### Types of Relationships:

* **One-to-One (1-1)**: Each record in one Cube corresponds to exactly one record in another Cube.
* **One-to-Many (1-n) or Many to One(n-1)**: A single record in one Cube is associated with multiple records in another Cube.

## Why Setup a Relationship?

#### **For View Creation**

* Relationships allow Views to aggregate and display data from multiple Cubes seamlessly.
* Enables pre-joined datasets that improve performance in BI tools.

#### **For Data Consistency and Integrity**

* Ensures correct data linkage across different datasets.
* Reduces redundancy and improves maintainability.

#### **For Enhanced Query Performance**

* Predefined relationships optimize query execution by reducing the need for complex joins at runtime.
* Improves efficiency by leveraging indexed relationships for faster data retrieval.

## Define Relationships

To define the relationship between cube, follow these steps:

{% hint style="info" %}
Ensure the cube's primary key has been set before proceed to create the custom dimension. Refer [Cube](/semantic-modeling/cube.md#create-cube)
{% endhint %}

1. Click on the **Edit Relationship** button, the relationship modal will be shown

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

2. Click on **Add Relationship** to start add a new row of the relationship between cube.
3. Select the Relationship Type, From and To fields in the list and click on **Add** button.

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

4. Once the relationships have been defined, click on the **Save** button to save all the relationships created.

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