# Relationships

**Types of Relationships**:

* **One-to-One**: A relationship where a single record in one entity is associated with a single record in another. For instance, a user and a user profile.
* **One-to-Many**: A common relationship where a record from one entity can be associated with multiple records in another. For example, a single customer having multiple orders.
* **Many-to-Many**: This involves two entities that can have multiple records related to multiple records in the other entity. Many-to-many relationships often require a join table or entity.
* **Defining Relationships**: When defining a relationship, select the type of relationship, specify the related entities, and if necessary, define the join entity for many-to-many relationships.

In API Builder, by March 7, 2024 we have implemented support for creating **"one-to-many"** relationships between entities. This type of relationship allows one entity to be associated with multiple records of another entity, widely used for modeling hierarchical and related data in applications.

#### How to Create a "One-to-Many" Relationship

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

1. Select the Target Entity: In the API Builder interface, select the entity for which you want to create a relationship. (target reference not a source)
2. Go to Relationships tab
3. Click 'Add a Relationship' button&#x20;
4. Fill out the form&#x20;

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

5. Save the Relationship: After configuring the relationship parameters, save the changes. API Builder will automatically update the entity models and generate the corresponding API endpoints for managing the related data.

For example: In the "Source" field, enter "List". For "Source Reference", enter "List", and for "Target Reference", use "Tasks" (plural). This configuration establishes a "one-to-many" relationship between the "List" and "Task" entities, indicating that one "List" can contain multiple "Tasks".

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

**Source primary** and **Source optional** checks&#x20;

**How to update the Relationship**&#x20;


---

# 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://www.apibuilder.com/home/entities/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.
