Relate Data With Hierarchies
Hierarchy Collections in Conscia
Conscia's DX Graph enables not only relationships between Collections, but relationships between records within a single Collection. By defining a Collection as Hierarchical, any given record can be assigned as a Parent Record to another, enabling complex stem-and-leaf relationships to be modelled within the Graph.
What's more, as each Record is modified, the relationship paths for the entire Collection are re-established in real time. This means that if a node is moved from one branch of the tree to another, all branches and leaves beneath it are similarly transported alongside it to their new niche in the hierarchy.
Finally, the API payload for each Record in a Hierarchical Collection includes the "ancestors" of that Record (itself, its parent, and upward to a root node with no parent) and the "descendants" of that Record (itself, its children, and their children recursively to the furthest leaves). This data enables complex visualization of the DX Graph Hierarchy data by external services or tools.
Creating a Hierarchy Collection
In this example, we will instantiate and populate a simple Hierarchy Collection.
- From the main navigation, navigate to Settings -> Data Model.
- Select the + to create a new Collection. Note the Data Record Identifying Property (
drip
) that you establish during creation. - Once created, right-click that Collection and Edit Schema.
- Add the
drip
String field and set it as Unique. - Add a descriptor field (
name
in this example) and a field to store the parent's data record identifying property (parent_drip
in this example).
- Right-click the Collection again and select "Set as Hierarchical". Populate the following values:
Field | Value |
---|---|
Parent Field | parent_drip |
Node Name Field | name |
Hierarchy Path Field | enter a field name of your choosing |
Parent Field Title | enter a readable name of your choosing |
Search Fields | Select as many fields as you wish. |
Display Property | name |
- Submit to save this change. The Schema will have updated to include
_hierarchyNodeName
(Hierarchy Path), a special field populated procedurally by Conscia, as well as removingparent_drip
from the visible Schema:
Establish Records in the Hierarchy
Once we have a Hierarchical Collection (and have instantiated it to the Left Navigation) we can populate this Collection with Records!
To establish a Hierarchical relationship between Records, the parent record must be created first. So, we'll start by creating a Grandparent record, then work down the tree shown here to create a representational hierarchy. The data record identifiers are arbitrary; they just have to be unique.
Hierarchy Collection Records
drip | name | parent_drip |
---|---|---|
100 | grandparent | / |
10 | parent | grandparent (or 100) |
1 | child | parent (or 10) |
2 | sibling | parent (or 10) |
-10 | grandchild | child (or 1) |
As you work, you will see the Hierarchy Path updating in real time. We've added the diagram for ease of interpretation. Once completed, it may look something like this:
It's straightforward to adjust or manipulate records from this point. For instance, if the grandchild data was entered incorrectly and its parent is actually sibling, simply edit the record, remove the existing parent_drip
, and populate a new one. The Hierarchy Path of the Grandchild will change, as will the _ancestor and _descendant arrays of Records throughout the Collection. We can even "disown" sibling, making it a root node, and see all-new Hierarchy Paths calculate in real-time!