Subcategories in database

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


 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!


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.

1 Like

Ill try that. Thanks!

Seem to work perfectly. Thanks, Dosandco

1 Like

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!

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

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

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).

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.

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.

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

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!