# Relationship

**Relationship** trong **Data Model** dùng để liên kết dữ liệu giữa các **Schema** thông qua các **Primary Key**. Nhờ vào Relationship, các dữ liệu rời rạc được kết nối với nhau thành một hệ thống thống nhất, giúp phân tích và trực quan hóa dữ liệu hiệu quả hơn.

#### Các bước tạo Relationship giữa hai Schema

{% stepper %}
{% step %}

#### Chọn Data Model

* Đăng nhập và chọn **Workspace** làm việc của bạn.
* Truy cập **Data Model**.
* Chọn **Data Model** mà bạn muốn thiết lập Relationship.
  {% endstep %}

{% step %}

#### Truy cập tab Relationship

Chuyển đến tab **Relationship** để xem các mối quan hệ hiện có và bắt đầu thiết lập mối quan hệ mới.
{% endstep %}

{% step %}

#### Thêm Relationship mới

Nhấn nút Add Relationship.

<figure><img src="/files/TaGZtEombdpCsSZTGGCd" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Tạo liên kết giữa hai Field

* Trên giao diện, **kéo liên kết giữa hai trường** (field) của hai Schema mà bạn muốn tạo mối quan hệ. Thao tác này sẽ mở ra cửa sổ **Add Relationship**.
* Nhập các thông tin cần thiết trong cửa sổ này (ví dụ: loại mối quan hệ).
* Nhấn **Tạo** để hoàn tất.

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

{% hint style="danger" %}
**Lưu ý**: Đảm bảo các **Field** được chọn để liên kết là phù hợp (thường sử dụng **Primary Key** hoặc các Field có giá trị duy nhất) để đảm bảo tính chính xác của dữ liệu khi phân tích.
{% endhint %}
{% endstep %}
{% endstepper %}

#### Các loại Relationship

FPT Data Suite hỗ trợ ba loại mối quan hệ chính:

* **One-to-one (một-một)**: Một bản ghi (record) ở Schema nguồn (From Node) liên kết chính xác với một bản ghi ở Schema đích (To Node).
* **One-to-many (Một-nhiều)**: Một bản ghi ở Schema nguồn (From Node) có thể liên kết với nhiều bản ghi ở Schema đích (To Node).
* **Many-to-one (Nhiều-một)**: Nhiều bản ghi ở Schema nguồn (From Node) có thể liên kết với một bản ghi ở Schema đích (To Node).


---

# 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://docs.datasuite.vn/cac-tinh-nang/data-modeling/relationship.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.
