Categories and subcategories - How to

Hello,

Im very new to this so i will try to explain the best i can.

I have a list of products that go into different categories, subcategories and 2nd subcategory (sub-sub category?). My problem is that some items do not have the 2nd subcategory and only belong into subcategory.

Example:
I have these products:
Product1
Product2
Product3

CATEGORY > SUBCATEGORY 1 > PRODUCT 1, PRODUCT 2
CATEGORY > SUBCATEGORY 2 > 2ND SUBCATEGORY > PRODUCT 3

So to find Product 1 and 2 ill have to navigate through 2 folders and for product 3 I will have to navigate through 3 folders. I have already done the folders for SUBCATEGORY 1, 2 in my app by watching the Things in Things video, but I have no idea what to do next.

Thank you for help, I hope my explanation makes sense.

How about trying something like this:

Parent Child
CatA CatB
CatB Prod1
CatB Prod2
CatC CatD
CatD Prod3

Basically, you create a tree structure with as many levels as you want (you could add CatE, CatF, …), each edge (branch of the tree) is defined in a single row by who the child and who the parent is.

I tried making these 2 columns, but the problem is that the subcatecory CatB appears 2 times in the main category section

Now create a separate table just with the top level categories. In this table, create a relation to the parent-child tree table.

I still dont really get it, I made a new table with the main categories (catA, catC?) and then make
a column in the new table that relates to the parent or the child column? do you have any guide or templates i could look at? I think ill understand once i see an example.

Would something like this work?

Table 1: Categories

Category ID Category Name
CAT001 CATEGORY 1
CAT002 CATEGORY 2

Table 2: Subcategories

Subcategory ID Category ID Subcategory Name
SUB001 CAT001 Subcategory 1
SUB002 CAT002 Subcategory 2
SUB003 CAT002 Subcategory 3

Table 3: 2nd Subcategories (Sub-Subcategories)

2nd Subcategory ID Subcategory ID 2nd Subcategory Name
SUBSUB001 SUB003 2nd Subcategory 3.1

Table 4: Products

Product ID Product Name Subcategory ID 2nd Subcategory ID (FK)
PROD001 Product 1 SUB001
PROD002 Product 2 SUB001
PROD003 Product 3 SUB003 SUBSUB001
3 Likes

How to create a tree structure

I think Thinh’s recommendation above will work well with a somewhat limited number of subcategories, since each new subcategory requires a new table, and if each table represents different objects with different attributes. For example, Company → Business Units → Departments → Teams → Employees → Projects → Tasks

The attributes of a Company, of a Team, or of an Employee are presumably very different and each object would therefore warrant its own table.

If objects in the hierarchy are the same, or said differently, if the categories are simply a way of categorizing the objects and navigating through a tree hierarchy, then you can set up a tree structure in a single table.

For example, CEO → VPs (CEO’s subordinates) → Directors (subordinates of VPs) → Team leads (subordinate of directors) → Senior managers (subordinates of team leads) → etc. The objects here are the same: an employee, in an Employees table.

Each additional row in the table will add a branch or segment in the tree and it is easy to make the tree as flat or deep or bushy as needed by adding rows.

In the Data Editor:

  • You will need a parent column, a child column, and a Relation column relating child to parent match multiple.
  • Optional: Row ID.

In the Layout Editor:

  • Setup the collection with the table as the data source, display data from the child column, and filter to only display the top nodes (top categories). The top nodes need to be in the child column. The parent of the top nodes can be called root or even left empty. The optional row ID column can come in handy for the filter. Display data from the child column.
  • Set the collection item click to Show Details Screen.
  • On the details screen, add a collection. Set the data source to the Parent→Child relation. Display data from the child column.

That’s it. Now you can navigate through your categories and subcategories.

Note about top level categories
There would be different ways to display the initial top nodes (top categories). In the method above I filtered in the layout editor. It would also be possible to create a separate table for them, or to create a Query column and apply the filter in the data editor rather than in the layout editor.



3 Likes

Thank you! I have been playing with it for a little bit and now I understand it. I will try Thinh’s recommendation too when I get the time for it. But now I have a new sheet with a masterlist of all products. How would I put them in the end folder (category where the products belongs in)?

Copy-paste from Excel or Google Sheets, or a CSV upload.

Yes, i have done that, now how do i put them in categories they belong to?

1 Like

What are the items you are putting into categories and sub-categories? Could you give a few examples of item names, categories and sub-categories?

I made a quick example hope you understand


1 Like

Okay so you are categorizing products. You can use the method I explained above. It’s a little lengthy, but follow the instructions exactly. You could copy column names you see in the screenshots.

So id have to add each product like this manually? That can be a bit lenghty if you have 100s of products. But it will do for now thanks!

In my post above above, I changed the tree diagram for clarity. You now see the numbers to understand what’s going on.

Remember this: all nodes in the tree diagram are a child. The only exception is the root node (0).

So in your case, all categories, subcategories, sub-subcategories and products need to be in the child column. All of them.

Now in the parent column, indicate who the parent is. Only one single node does not have a parent (call that root master or 0 or leave it empty, it doesn’t matter what you call it because it won’t appear anywhere).

On a given row, you will only have one parent and one child. There are no comma-separate lists or arrays.

Then set up your relation. Check the relation is indeed pointing the the correct rows. By looking at your table, you should be able to visualize the tree of main categories, subcategories, sub-subcategories and products.

In my example above, you see the following:

  • Row 1. Child is 1. The relation points to 3 rows. When I inspect these 3 rows (the bubbles with 3 1’s), I see that the children of node 1 are the nodes 5, 6, 7. This is coherent with the tree diagram.
  • Row 2. Child is 2. The relation points to 2 rows. When I inspect these 2 rows (the bubbles with 2 2’s), I see that the children of node 2 are the nodes 8 and 9. This is coherent with the tree diagram.
  • Let’s skip a few rows. Row 5. Child is 5. The parent is 1. The relation points to 1 row. When I inspect this row (the bubbles with a 5), I see that the child of node 5 is node 11. This is coherent with the tree diagram.
  • And so on.

At the end of the day, the setup is quite straightforward:

  1. Two columns: one child that contains all categories and products, one parent that indicates the parent of each category product
  2. A relation, to create the ability to navigate from row to row.
  3. A filter, either in the data editor or layout editor, to display the top categories only
  4. A collection with the relation as a data source on the details page of the top category
1 Like

I tried this today but i dont know how to put the PROD003 into SUBSUB001, because when making the relations PROD003 goes into SUB003

How are you creating the relation?

1 Like

This is how I currently have my sheet setup.





Am I correct in assuming what you want is a list of products on each level, AND a list of child categories on each level?

I explained it above what i am looking for:

CATEGORY > SUBCATEGORY 1 > PRODUCT 1, PRODUCT 2
CATEGORY > SUBCATEGORY 2 > 2ND SUBCATEGORY > PRODUCT 3

So to find Product 1 and 2 ill have to navigate through 2 folders (CATEGORY > SUBCATEGORY) and for product 3 I will have to navigate through 3 folders (CATEGORY > SUBCATEGORY > SUBSUBCATEGORY)

I hope you understand my explanation

Nathanaels suggestion works well. But I want to try your suggestion too.

1 Like