December 2, 2018 at 1:45 pm
Hi ,
I have recently discovered the tally table concept and its usage to replace loops. Therefore I would like to use it to traverse a hierarchy and build a sort path.
I have an adjency table storing the node_id and the parent_node_id and some other data.
My problem is that I don’t know to combine the tally table and relation parent node/child node.
Hope my explanations are clear enough so that someone can help me.
Thank you very much.
December 3, 2018 at 6:19 am
Please see the following articles.
Hierarchies on Steroids #1: Convert an Adjacency List to Nested Sets
Hierarchies on Steroids #2: A Replacement for Nested Sets Calculations
--Jeff Moden
Change is inevitable... Change for the better is not.
December 3, 2018 at 6:27 am
Hi Jeff,
I read both article but I' have probably miss something...
December 3, 2018 at 6:37 am
s.duvernay 71743 - Sunday, December 2, 2018 1:45 PMHi ,I have recently discovered the tally table concept and its usage to replace loops. Therefore I would like to use it to traverse a hierarchy and build a sort path.I have an adjency table storing the node_id and the parent_node_id and some other data.My problem is that I don’t know to combine the tally table and relation parent node/child node.Hope my explanations are clear enough so that someone can help me.Thank you very much.
Can you provide the DDL?
December 3, 2018 at 7:26 am
s.duvernay 71743 - Monday, December 3, 2018 6:27 AMHi Jeff,
I read both article but I' have probably miss something...
The point of the first article is that maintaining the hierarchy through an Adjacency List is the best way to maintain it and that Nested Sets is the best way to traverse the Hierarchy. Hierarchies usually don't change as often as other data and so you don't need to constantly calculate how to traverse the hierarchy if nothing has changed. Instead, you use the technique to express the Adjacency List as Nested Sets in a very high performance manner after the hierarchy has changed so you can continue to enjoy the benefits of both an Adjacency List (ease of maintenance) and Nest Sets (nasty fast).
To be sure, using ONLY a Tally Table will have no benefit in helping to traverse a hierarchy. However, a Tally Table was used and is critical to creating the Nested Sets from the Adjacency List in a very high performance manner.
As for the second article, it does the preaggregation of the usual/most common values that you would need to traverse a hierarchy for and does so with the same high performance. Instead of traversing the hierarchy for "totals", you just SELECT them from the preaggregated table (similar to what people would call a DW table).
--Jeff Moden
Change is inevitable... Change for the better is not.
December 3, 2018 at 8:34 am
@jeff: thank you very much for your additional explanations.
@jonathan-2: if I'm still blocked I will post the DDL with some data sample.
Thanks.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply