# Subcategories in database

**URL:** <https://forum.adalo.com/t/subcategories-in-database/1059>\
**Category:** Get Help\
**Created:** [May 1, 2020, 11:49am UTC](https://forum.adalo.com/t/subcategories-in-database/1059 "2020-05-01T11:49:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![banjaxed](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/banjaxed/32/369_2.png) [@banjaxed](https://forum.adalo.com/u/banjaxed)\
**Post date:** [May 1, 2020, 11:49am UTC](https://forum.adalo.com/t/subcategories-in-database/1059/1 "2020-05-01T11:49:23Z")

</div>

Im going to setup a quite big database for my project and want to make it right.

Home

```
 Lamps (subcategory of Home)
      Shades (subcategory of Lamps)
 Textiles (subcategory of Home)
      Mats (subcategory of Textiles)
      Accesories (subcategory of Textiles)

```

How would do this?

Home as collection - others as properties?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![dosandco](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dosandco/32/39_2.png) [@dosandco](https://forum.adalo.com/u/dosandco)\
**Post date:** [May 1, 2020, 2:30pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/2 "2020-05-01T14:30:20Z")

</div>

I’d consider looking at something like:

- Products - each item you’re listing, and linked many-to-many with:

- Level 1 Categories: Home

- Level 2 Categories (or ‘Sub-Categories’): Lamps / Textiles

- Level 3 Categories (or ‘Sub-Sub-Categories’): Shades / Mats / Accessories

You can go as deep as you like with your nesting.

You then need to create links between the categories and sub-categories (and sub-sub-, sub-sub-sub- etc). All of these are a one-to-many relationship:

Each Level 1 Category has many Level 2 Categories  
Each Level 2 Category has many Level 3 Categories  
Each Level 3 Category has many Level 4 Categories etc

You can then do a hero image for each category, a description, etc etc.

---

<div class="post-metadata">

**Author:** ![banjaxed](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/banjaxed/32/369_2.png) [@banjaxed](https://forum.adalo.com/u/banjaxed)\
**Post date:** [May 1, 2020, 5:56pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/3 "2020-05-01T17:56:17Z")

</div>

Ill try that. Thanks!

---

<div class="post-metadata">

**Author:** ![banjaxed](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/banjaxed/32/369_2.png) [@banjaxed](https://forum.adalo.com/u/banjaxed)\
**Post date:** [May 2, 2020, 2:31pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/4 "2020-05-02T14:31:14Z")

</div>

Seem to work perfectly. Thanks, Dosandco

---

<div class="post-metadata">

**Author:** ![skief-labs](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@skief-labs](https://forum.adalo.com/u/skief-labs)\
**Post date:** [May 4, 2020, 12:23pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/5 "2020-05-04T12:23:13Z")

</div>

Question:  
Do you need to create a separate table / collection for each level or do you store it in the same base?  
Also, if you could a screenshot of the database structure that would help a lot, thank you!

---

<div class="post-metadata">

**Author:** ![dosandco](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dosandco/32/39_2.png) [@dosandco](https://forum.adalo.com/u/dosandco)\
**Post date:** [May 5, 2020, 11:12am UTC](https://forum.adalo.com/t/subcategories-in-database/1059/7 "2020-05-05T11:12:15Z")

</div>

A separate table for each level works best. This way you can plan your navigation and styling consistently.

---

<div class="post-metadata">

**Author:** ![banjaxed](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/banjaxed/32/369_2.png) [@banjaxed](https://forum.adalo.com/u/banjaxed)\
**Post date:** [May 5, 2020, 3:40pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/8 "2020-05-05T15:40:50Z")

</div>

Each level its a Collection , right? Properties for subcategories in that collection then?

---

<div class="post-metadata">

**Author:** ![skief-labs](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@skief-labs](https://forum.adalo.com/u/skief-labs)\
**Post date:** [May 5, 2020, 5:08pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/9 "2020-05-05T17:08:21Z")

</div>

Ok thank you. In my case each sub-category can be linked only to one of the items in the previous levels. I presume I should settle this in the relationship type (one category can have several subcategories, one subcategory can have only one category).

---

<div class="post-metadata">

**Author:** ![dosandco](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/dosandco/32/39_2.png) [@dosandco](https://forum.adalo.com/u/dosandco)\
**Post date:** [May 5, 2020, 5:23pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/10 "2020-05-05T17:23:17Z")

</div>

> [@banjaxed](#):
>
> Each level its a Collection , right? Properties for subcategories in that collection then?

Yes, each level is a Collection. That collection can contain the hero image, sub-category name, intro text, etc etc for the **category**.

The product properties would go in the product Collection.

> [@skief-labs](#):
>
> In my case each sub-category can be linked only to one of the items in the previous levels. I presume I should settle this in the relationship type (one category can have several subcategories, one subcategory can have only one category).

I think so. A Sub-Category is just that. A category that belongs to another category. It should only have one parent. If you start doing many-to-many relationships (allowing sub-categories to belong to more than one category), you won’t be able to filter lists the way you are probably hoping to.

---

<div class="post-metadata">

**Author:** ![banjaxed](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/banjaxed/32/369_2.png) [@banjaxed](https://forum.adalo.com/u/banjaxed)\
**Post date:** [May 5, 2020, 5:51pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/11 "2020-05-05T17:51:05Z")

</div>

Let say i have same categories for both Male and Female users. Do i make a collection for both of them?

---

<div class="post-metadata">

**Author:** ![JohnNope](https://avatars.discourse-cdn.com/v4/letter/j/f07891/32.png) [@JohnNope](https://forum.adalo.com/u/JohnNope)\
**Post date:** [August 19, 2021, 5:55pm UTC](https://forum.adalo.com/t/subcategories-in-database/1059/12 "2021-08-19T17:55:09Z")

</div>

Is it possible to set this up so there are unlimited subcategories instead of a set number of collections? I am building an app where the user (Contractor) will build a list of services that they provide. I want them to be able to set their service catalog up as they see fit.

Thanks in advance!
