Hierarchy is used to create an Expanded Nodes table, where each level in the hierarchy is stored in a seperate field. This makes it ideal for use in a listbox treeview, or a pivottable.
HierarchyBelongsTo is used to create an Ancestors table, which contains one record for every child-ancestor relation found in the data. This makes it better suited for allowing selection of entire trees of data.
Does that help?
Its a simple example:
LOAD COD_DEPARTAMENT, COD_DEPARTAMENT_UP, SIG_DEPARTAMENT
COD_DEPARTAMENT, COD_DEPARTAMENT_UP, SIG_DEPARTAMENT
1, , COMPANY 1
2,1, DEPARTAMENT 1
3,1, DEPARTAMENT 2
4,1, DEPARTAMENT 3
6, , COMPANY 2
7,6, DEPARTAMENT 1
8,6, DEPARTAMENT 2
9,6, DEPARTAMENT 3
10,6, DEPARTAMENT 4
HierarchyBelongsto (COD_DEPARTAMENT, COD_DEPARTAMENT_UP, SIG_DEPARTAMENT, CODIGO, UNIDADE, HLEVEL)
Hi. If you have 2 levels, then hierarchybelongsto makes no differences at all. With 3 levels, the difference is not that relevant but there is, and that's where it starts, basically is just to have a Parent ListBox that works better.
Let say you have 5 levels.
You select a parent in level 3. Hierarchy (simple one) will associate it with just its parent in level 2, and children in level 4. That's it, 1 level up, 1 level down.
But with hierarchybelongsto It will ALSO relate it with all ascendance and descendance. So it will know that the one selected (at level 3) has a boss in level 2, and also the superior boss in level 1 (Boss of his Boss, Parent of his parent). And not only descendance (children) directly at level 4, but also has hierarchy over some grandchildren/interns in level 5.
The more levels the more useful and notorious it becomes. But then again, only when selecting on the parent field which sometimes may be necessary, some other times not.