Module 4 · Lecture 4.4
Hierarchies
Hierarchical classes let Veezoo aggregate along a structure and let users drill down level by level.
Branches roll up into districts, and districts into divisions, but asking for sales per division only returns the branches. Orders are matched to a branch, so that is the level Veezoo answers on. This lecture shows how a hierarchical class changes that, so Veezoo aggregates along the structure and users can drill down level by level.
It also covers the less obvious use of hierarchies: building one by hand. Five raw order statuses become the three words people actually say, which are canceled, open, and done.
Key points
- A hierarchical class holds several levels of one structure, such as branch, district, and division.
- Setup in Studio: tag the class as hierarchical, then point the hierarchy column at the database column the levels come from.
- After saving, sync the entities. Each one arrives tagged as a leaf or as a node with children.
- Every entity below the top level carries a parent, and those parents are what the hierarchy is built from.
- Veezoo then aggregates along the structure, so a division can be opened to reveal its districts and branches.
- Hierarchies can be built by hand when no column defines them. Add the grouping entities and set the parent on each raw value.
- Hand-added entities need no ID, because no database row backs them.
Check your understanding
"Sales per division" shows only the lowest-level branches, even though branches roll up into districts and divisions. What is the fix?
Once the class is hierarchical and its hierarchy column is set, Veezoo aggregates along the structure and drills down level by level.
Orders have five statuses, including "canceled by customer" and "canceled by us". Users just want to ask for canceled orders. How is this modelled?
Hierarchy entities can be added by hand with no ID, and the parent wires the raw statuses into the group users ask for.
Product category and subcategory sit in two separate database columns. Can they become one hierarchy?
A hierarchy works within one class, so two columns stay two classes unless both levels arrive in a single column.