When we link items together with relations, we are in a sense categorizing those items. If we relate all employees to locations, then we could say that our employees belong in different categories of locations.
But what happens when we want to have subcategories? Well we don’t need to do anything different in the data editor, we just need to think clearly about hierarchy and more specifically, 'parents' & 'children'.
When working with multiple categories, it’s important to realize that each level of category will have a parent or child, or both. In the example below we have a list of food types. A parent is the item 1-level-above in the hierarchy and a ‘child’ is an item 1-level-below in the hierarchy.
In a spreadsheet we don’t visually nest items like we do in documents with bulleted lists (above). Instead, we have a column where we indicate the item’s parent.
If we were to look at ‘Red Cardinal’ (row 25) - the parent of this item would be ‘Smooth Leafed’. The parent of ‘Smoothed Leafed’ would be ‘Spinach’ etc… if we follow the hierarchy all the way up we get to ‘Food Types’. The full path to 'Red Cardinal' would therefore be:
Flowers & leaves
When we create a relation column using our
Parent column (in other words a relation that relates items to their parents) and we have a number of ‘levels’ then the result will be that we can tap through deeper and deeper into the hierarchy and give the user a clear experience of this nesting of categories.
We've indicated the parent of each item in our sheet, but we need to set up a relation that uses that column to relate the children of each item.
To do this, we create a new relation column that relates items where the value in
Category matches the value in
Parentand we make sure that it's a multiple relation.
Now we can add an inline list to each of our items and connect the new
Children relation column.
Our first relation allows us to link all our items together in a parent/child relationship. However, our top level screen still shows the whole list of items. We actually only want to see level 2 items (vegetables, fungi etc) initially and then dig into that level and explore the subcategories.
To show only level 2 items we need to create another relation on a separate sheet. This new sheet will act as our home screen and will be where the list of level 2 items sit. This screen will have a details layout so only needs one row with one cell of data that we can relate to - the name of the top level.
The reason we use this is that we want to relate level 2 items to their parent - which in our case is 'Food types' - the top level of the hierarchy.
All we need to do then is create a relation column that relates all the items with 'Food types' as their parent. This results in relating level 2 items - vegetables, fungi, fruit etc...
Now we can add an inline list on our home screen and connect it to our new relation! We should now be able to visit all items within our hierarchy from our top level.