# Relate objects (/docs/contacts/relations)

A relation connects two objects, such as orders and the contacts who place them, or orders and the products in them. It adds a field on both objects, so a link you make from either side shows on the other. Agents follow these links too: an agent working a conversation can see a contact's orders and what's in them.

- **Who can use it:** Owners and admins add, change and remove relations. Linking and unlinking records takes the Edit records permission, which owners, admins and members have by default. Viewers see every link, but **Link** is greyed out with the reason and there's no **Unlink**. See [Roles and permissions](/docs/settings/roles).
- **Before you start:** Both objects must exist. To relate a new object, you can add the relation while you [create it](/docs/contacts/create-object).

## Kinds of relation [#kinds-of-relation]

Under **How they link**, pick how many records can be on each side. The sentence under each choice spells it out for the objects you picked.

| How they link | What it means (orders and contacts) | Label on the canvas |
| --- | --- | --- |
| **Many to one** | Each order belongs to one contact; each contact has many orders. | 1 — N |
| **One to many** | Each order has many contacts; each contact belongs to one order. | 1 — N |
| **Many to many** | Orders and contacts link freely. | N — N |
| **One to one** | Each order has one contact, and each contact one order. | 1 — 1 |

**Many to one** and **One to many** are the same relation seen from opposite ends. On the [data model canvas](/docs/contacts/data-model-canvas) both show as **1 — N**.

## Add a relation [#add-a-relation]

<Steps>
<Step>

### Open the object sheet [#open-the-object-sheet]

On **Setup → Objects**, open the object's **⋯** menu and click **Edit object** (or start a [new object](/docs/contacts/create-object)). Under **Relations**, click **Add relation**. You can also draw a line between two cards on the [data model canvas](/docs/contacts/data-model-canvas).

</Step>
<Step>

### Choose the other object [#choose-the-other-object]

Under **Relate to**, pick the object to link to. Every object is listed, Contacts included. The object you're editing is listed as **(itself)**, for relations such as a product's related products.

![A new relation row with the Relate to list open, showing Contacts, Orders and Products (itself)](/screenshots/relations/01-relate-to.webp)

</Step>
<Step>

### Choose how they link [#choose-how-they-link]

Under **How they link**, pick **Many to one**, **One to many**, **Many to many** or **One to one**.

![A relation from Products to Contacts set to Many to many, with Contacts as the field on Products and Products as the field on Contacts](/screenshots/relations/02-how-they-link.webp)

</Step>
<Step>

### Name the field on each side [#name-the-field-on-each-side]

**Field on** each object names the field the relation adds there. Mokanata names each side after what it holds, singular when it holds one record: an order's link to its one contact is called `Contact`, a contact's link to many orders `Orders`. The names follow the objects and the kind you pick until you type your own, and each must differ from the other fields on its object.

</Step>
<Step>

### Save [#save]

Click **Save changes** (or **Create object** for a new object). Both objects now have the new field, and the objects list shows them under each other's **Related to**.

</Step>
</Steps>

## Change or remove a relation [#change-or-remove-a-relation]

Open the object sheet and click the arrow on the relation to open it. On the canvas, clicking a relation's label opens it directly.

![A saved relation from Orders to Products: Relate to is greyed out with a note, and How they link offers One to many, Many to many and One to one](/screenshots/relations/03-saved-relation.webp)

- **The objects are fixed once related.** To relate something else, remove the relation and add a new one.
- **The direction is fixed too**, so a saved relation offers three of the four choices under **How they link**.
- **Links that wouldn't fit stop the change.** Making a side hold only one record fails while records on that side link to more than one, for example “2 Orders link to more than one Product. Unlink them first…”. Unlink the extra records first, or keep the current kind.
- **You can rename either field** at any time.

To remove a relation, open its **⋯** menu and click **Remove relation**, then **Save changes**. Mokanata asks first (**Save and delete what you removed?**) and counts the links that go with it. Both objects lose their field, and every link between their records is deleted. This can't be undone.

## Link records [#link-records]

Each relation shows as a panel on the record page, titled with the relation's field name and the number of linked records. Contacts show the same panels on the [contact record](/docs/contacts/contact-record).

<Steps>
<Step>

### Open a record [#open-a-record]

Open the object's table and click a record's name. The panels sit next to the record's details, or under them in a narrower window.

![The Customer and Products panels of order ORD-1042, listing Nadia Prasad and two products, each with a Link button](/screenshots/relations/04-related-panels.webp)

</Step>
<Step>

### Click Link [#click-link]

On the panel, click **Link**. The dialog lists the records you can link: type to narrow them and pick one or more. The link shows on both records.

![The Link products to ORD-1042 dialog with Mokanata Pro seat picked](/screenshots/relations/05-link-dialog.webp)

When a side can hold only one record, the dialog says what happens:

- “… can have one …, so this replaces …”: the record already has a link, and the button reads **Replace**.
- “Each … has one …, so one linked elsewhere moves here.”: picking a record that's linked elsewhere moves its link to this record.

</Step>
<Step>

### Confirm [#confirm]

Click **Link** (or **Replace**). The record joins the panel and a notice confirms it, with **Undo**.

![The Products panel of ORD-1042 now listing three products](/screenshots/relations/06-linked.webp)

</Step>
</Steps>

To create a record that starts linked, open the panel's **⋯** menu and click **New** followed by the record type, for example **New product**. It's there when you can both create and edit records, and never for Contacts (add contacts from the [Contacts](/docs/contacts/import-contacts) page).

## Unlink records [#unlink-records]

On the record's panel, open the **⋯** menu of the linked record and click **Unlink**. Mokanata asks first; both records stay. Click **Unlink** to confirm. **Undo** in the notice that follows brings the link back.

![The Unlink Onboarding package from ORD-1042? confirmation, saying both records stay and the unlink can be undone](/screenshots/relations/07-unlink.webp)

## Where links show [#where-links-show]

- On both records' pages, in the relation's panel.
- In the object's table, as a column of linked records: the first two as badges, then **+** the number of others, or **None**.
- On the contact record and in the contact panel beside an inbox conversation, for relations to Contacts. See [Custom fields on contacts](/docs/contacts/contact-fields) and [Contact details beside the thread](/docs/inbox/contact-panel).

## Next steps [#next-steps]

<Cards>
<Card title="The data model canvas" href="/docs/contacts/data-model-canvas" description="See every relation as a line and draw new ones." />
<Card title="Work with records" href="/docs/contacts/records" description="Add, edit and delete the records you link." />
<Card title="Custom fields on contacts" href="/docs/contacts/contact-fields" description="Relate your objects to Contacts." />
</Cards>
