# One-to-Many vs. Many-to-One

## Learn About One-to-Many vs. Many-to-One Relationships

{% embed url="<https://youtu.be/fGvEHvibIoY>" %}

### **One-to-Many Relationship**

A one-to-many relationship exists when one record in the parent collection can be connected to multiple records in the child collection, but each child record can only connect to one parent.

**Example: Users and Workouts**

* One user can have ***many*** workouts
* Each workout belongs to only ***one*** user

In the Workouts collection, you'd add a Relationship property called "User" that points to a specific user. This is the simplest relationship type to set up and typically doesn't require junction collections.

### **Many-to-One Relationship**

A many-to-one relationship exists when multiple records in one collection can connect to a single record in another collection.

**Example: Orders and Customers**

* ***Many*** orders belong to one customer
* Each order is connected to only ***one*** customer

In the Orders collection, you'd add a Relationship property called "Customer" that points to a specific customer. This is the same relationship structure as the Users and Workouts example, just described from the opposite perspective.

**The key difference in perspective:**

* **One-to-Many (Users → Workouts):** "One user has many workouts" (viewing from the parent)
* **Many-to-One (Orders → Customer):** "Many orders belong to one customer" (viewing from the child)

{% hint style="danger" %}

* **Relationships can not be set or updated from the parent side of record in the Adalo database.**
* **Relationships can not be set upon Create Action of a parent record.**
  {% endhint %}

They're the same relationship type. The distinction comec from which collection you're looking at when you set up the Relationship. In Adalo, you'd set them up identically by adding a single relationship property to the child collection (Workouts or Orders) that points to the parent collection (Users or Customers).
