Multiple Subcategories in database / structure

Hello there,

For a grocery platform, we are looking to create multiple subcategories. For this, we need several levels of categories. An example when a customer wants a specific vegetable would be clicking through several subcategories:
First he sees all categories listed and then clicks on

  1. Fruits & Vegetables: Fruits, Vegetables, Potatoes, Herbs & Spices, Smoothies etc.
  2. Vegetables: Onion & Garlic, Cucumber Tomato & Avocado, …
  3. Cucumber Tomato & Avocado: Cucumber, Tomato, Avocado
    Now he sees only cucumbers listed.

To create this I thought to add to the database:

  1. AllDepartmentTypes: contains a list of the major categories like Fruits & Vegetables
  2. AllDepartmentSubs: contains a list of 1st level separate subcategories like Fruits, Vegetables, Herbs, etc.
  3. AllDepartmentSubs2: contains a list of 2nd level separate subcategories like Cucumber Tomato & Avocado, Broccoli Kale & Corn …

Is this the correct way to structure categories and their multiple layers of subcategories? I can make three separate levels and place all the subcategories together or I can create different types for each food. So something like Fruits > FruitsSub1 > FruitsSub2 etc.

Is there a tutorial somewhere on this?
Thanks in advance!

1 Like

Not sure this is there best way since it depends on how you want to display the data in the actual app, and your user flows. but the way I would structure it is the first way:

Name (text)

Name (text)
Department type (department_type)

Name (text)
Department sub (Department_sub)

Name (text)
Department type (department_type)
Department Sub (department_sub)
Department sub2 (department_sub2)
Image etc…