This is part two of our Directus Basics series. In part one, we set up a Directus instance and created our first collection. Today we're covering one of the most powerful features Directus offers: relationships between collections.
By the end of this article, you'll understand three core relationship types — Many to One (M2O), One to Many (O2M), and Many to Many (M2M). There's a fourth type, Many to Any (M2A), which we'll cover in a future post.
Setting Up the Branding Collection
Continuing from our existing Directus instance, let's create a new collection called branding. Select all the additional default fields Directus offers.
Add two fields:
| Field | Type |
|---|---|
name |
String (basic input) |
description |
Text (textarea) |
Once the collection is set up, add a few entries — I'd recommend at least two different brands so you can see the relationship in action once it's wired up.
Many to One (M2O): Products → Branding
Head over to your products collection. We want to connect a product to a brand.
Logically: many products can belong to one brand. That's a Many to One relationship — many products, to one brand.
Steps:
- Create Field → Relational category → Many to One
- Key:
brand_id - Related Collection:
branding - De-select Enable Create Button — you always want to choose a brand from an existing list, not create one on the fly
- Save
One to Many (O2M): Branding → Products
Since one brand can have many products, we need to set up the reverse relationship explicitly on the branding collection.
Steps:
- Create Field → Relational category → One to Many
- Key:
products - Related Collection:
products - Foreign Key:
brand_id— the field we just created on the products side - De-select Enable Create Button
- Save
Seeing the Relationship in Action
Go back into your products collection and assign a brand to each product. Make sure at least two products share the same brand so the relationship is visible.
You'll notice each product can only belong to one brand — that's the M2O relationship at work.
Now open the branding collection and click into one of your brands. You'll see the products you just assigned show up automatically — you didn't have to add them manually. Directus handled that because of the relationship you configured.
Many to Many (M2M): Products ↔ Tags
M2M relationships work differently — both sides can have many related records.
A common real-world example: tags on products, used to improve SEO. A single product can have multiple tags, and a single tag can apply to many products.
Create the Tags Collection
Create a new collection called tags, with the same two fields as before:
| Field | Type |
|---|---|
name |
String |
description |
Text (textarea) |
Add three or four tags before moving on.
Wire Up the M2M Relationship
Back in the products collection:
- Create Field → Relational category → Many to Many
- Key:
tags - Related Collection:
tags - De-select Enable Create Button
- Do not save yet — scroll down and click "Continue in Advanced Field Creation Mode"
- In the sidebar, click Relationship, then find Corresponding Field
- Check "Create Field" — under Field Name, you should see
productsappear - Save
Why the advanced flow? Under Corresponding Field,
productsappears automatically — that's Directus telling you it's about to create the matching relational field back on the tags collection. Unlike the M2O/O2M setup, you don't have to manually configure both sides — Directus builds the reverse relationship for you.
Now, when you add a tag to a product, Directus automatically links that product under the corresponding tag in the tags collection — no manual syncing required.
Summary
| Relationship | Direction | Example |
|---|---|---|
| M2O | Many records → one related record | Products → Branding |
| O2M | One record → many related records | Branding → Products |
| M2M | Many ↔ many, both directions | Products ↔ Tags |
Relationships are one of those Directus features that make a lot more sense once you've built one yourself than they do reading about them — so I'd recommend replicating this setup in your own instance before moving on.
That wraps up part two. In part three, we'll cover Directus permissions — how to control exactly who can see and edit your data.
Found this useful? Follow for more Directus and TanStack Start tutorials, or check out the video version on YouTube.

