We use relations extensively in our systems to help us build structured data.
Let's say you have two databases for your theoretical business 😉
- One that tracks customers
- One that tracks items purchased
You want to know both which customers bought which items, as well as which items were purchased by which customers. This is a job for relations!
![Notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F2e9fd5a9-25af-4c6c-b265-013a55bb6885%2Fsave_1.png?table=block&id=31a7226f-d8cd-474f-b627-ba0e6be6136d&cache=v2)
- In the two tables above, the columns labeled
↗ Items Purchased
and↗ Customers
are relation properties, which can be added like any other database property.
- Here, when you add an item bought into the Customers database, the customers who bought them automatically appear in the
↗ Customers
column in the Items database.
Example use cases
- Connect your database of restaurants with your database of neighborhoods so you can see which restaurants are in which neighborhoods at a glance.
- Connect your database of meeting notes with your database of clients to provide quick access to the notes relevant to each client.
- Connect your database of tasks with your database of bigger projects to understand how projects are broken down into tasks, and how tasks contribute to projects.
- Connect your database of candidates with your database of interviewers to keep track of who interviewed whom.
Create a relation
To relate two databases, you need two databases. So let's assume you've made the Customers and Items databases above for the purpose of this walkthrough.
- Add a new column/property to your Customers database.
- In the property menu, give it a name in the box provided, like
Items Purchased
.
- Choose
Relation
from theType
menu.
- You'll be asked to find the database you want to create the relation with. You can use the input at the top to search for this database.
![Notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F628d8c6e-c0e4-45ad-878c-6ee8e09215b0%2Fb1.jpg?table=block&id=cc21f4c3-1886-43e2-a8ee-4bd505a1c02e&cache=v2)
- You'll see a preview of the relation. In this case, we've created a relation from the Customer database to the Items database.
- Click the blue
Add relation
button to finalize the creation of the new relation property.
![Notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fc272757a-0023-49b0-83a6-0118b78dcae3%2Fb8.jpg?table=block&id=3668baa5-14bb-42e4-b578-966ee54d9133&cache=v2)
- Now when you click in a cell in this relation column, you'll bring up a menu where you can search for and choose items from the other database to add.
- For example, this is how you can add which clothes each customer bought.
- To add multiple items at once, click the name of the item. To delete an item, hover over and then click the
–
button on the right.
![Notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F6b9060c5-c364-4bc9-9078-da3314a4d2b9%2Fb6.jpg?table=block&id=26470e3e-05ac-4670-a43d-fe485a565bce&cache=v2)
Relation
as the property type for that particularly property. You'll be prompted to choose a new database.Two-way relations
Relations are created as one-way by default. But you can easily toggle on a corresponding relation in the destination database.
With two-way relations, the edits work both ways! So if you add a customer to the Items database in the relation column, the change pops up in your Customers database.
- Follow the above instructions to create a new relation property.
- Click the toggle that says
Show on [name of related database]
. In our example, this saysShow on Items DB
.
- Give this corresponding relation a name.
- Below, you'll see a preview of the two-way relation. In this case, we've created a relation from the Customer database to the Items database, and a relation from the Items database to the Customer database.
- Click the blue
Add relation
button to finalize the creation of these two new relation properties.
![Notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F4e5860a9-22dd-434c-a70e-650037c5c3c4%2Fb7.jpg?table=block&id=01ad6dfb-0895-4bf7-ae93-b06f0542c588&cache=v2)
View and remove related pages
When you create a relation, you're essentially adding Notion pages stored in one database into the property field of another.
- These pages can be opened and edited like any other! Click on the page in the relation column. Then click on it again in the window that pops up.
- You can also remove any related page by hovering over and clicking the
–
at the right.
📹 Self-uploaded videos are not supported yet. Please use a third party video provider such as Youtube, Wistia or Vimeo.
- You can choose to limit the number of pages that can be included in your relations property – with the option to select
1 page
or to haveNo limit
.
- If you select the option to limit it to
1 page
, people using your database will only be able to select 1 page in the relation. This is especially useful for situations where only one page should be related to one another, for example - if only one order number should be associated with each purchase.
Relate a database to itself
Let's say you want items in the same database to have relationships with each other. For example, you have a tasks database and you want each task to relate to other tasks.
- Start off by creating a new relation.
- Then search for and choose the database you're currently working in.
- You'll now see that the database is related to
This database
.
![Notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F476c6e90-dcba-4c58-8f4b-72a6ca18d737%2F9.jpg?table=block&id=9abdaa1f-50b4-46da-8314-e43e05644e10&cache=v2)
Just as with relations between two databases, you can choose to make this a one-way relation or two-way relation.
- To make it a two-way relation, toggle on
Separate properties
. You'll see a second property show up.