Maintaining hierarchies in Snowflake
As we have seen, a hierarchy is a grouping of classifications and relationships. It is an adjacent but separate dimension to the entity that it organizes. As a standalone dimension, hierarchies are subject to the same changes in business rules as any master data. However, before we attend to change-tracking, we must get comfortable traversing a ragged hierarchy’s recursive relationships.
Once again, Snowflake has us covered with native features that allow us to easily map out the paths and levels of a ragged hierarchy.
Recursively navigating a ragged hierarchy
You have been put in charge of the pirate frigate Queen Anne’s Revenge. Its logbook shows all crew members, ranks, and direct reports. The details are listed as follows:
Figure 16.7 – A ragged hierarchy contained in the pirate dimension
As you review the records, you realize that this list makes it difficult to make sense of the complex...