Hierarchical Data Storage

Bart Pietercil bart.pietercil at gmail.com
Mon Feb 12 02:46:07 CST 2007


On 12-feb-07, at 09:24, Ruslan Zasukhin wrote:


>>
>>
>> So for this Valentina (2.5.5) I basically implement a flat table T1
>> like this
>
>> T1(rec_id 'automatic', values_i_need_in_the_table,  
>> leftfield,rightfield)
>
>
> ------------
>> There is probably something to be gained if I am to introduce already
>> a binary link (self join) in order to have an easy acces to the
>> direct children of a certain item without needing to go through the
>> whole stack. It looks like we would end up with a mixed model then.
>
> actually find direct children is as easy as
>
>     WHERE parentPtr = somevalue


That's what I mean, in the preorder tree model I don't need a  
parentPtr .
I can find the first left child by doing WHERE leftfield =  
(current_leftfield + 1), but I need to always walk through the  
results of the query (give_descendants) to find more possible direct  
children.

But by using a parentPtr I can use WHERE parentPtr = my_own_recid.  
But parentPtr is if you want "part" of the recursive model.

So we are using mixed mode. I think we will have great speed with the  
mixed model.

Of course having binary hierarchical is the ideal solution, because  
as you said, the update and insert routines that for now are  
"dangerous" (rebuilding all descendants could mean lock on entire  
table) could be handled internally maybe even without locking the  
table (the "left' and 'right' would be part of the link not of the  
table correct ?)

Can this be made for 3.0 ? :-)

Thinking about this, I would say that the mixed model is the model to  
implement, so this would be a marriage between recursive model AND  
(not OR) preorder tree traversal
Binary Hierarchical uses pointer (= recursive model) for children and  
uses seq_left and seq_right for querying the complete hierarchy.

Hmmm...



Bart

>
>
>> Recursive model (without recursion because we only use it for level n
>> + 1) +  preorder tree traversal for links that are going deeper than
>> level n +1
>
>
>
>
> -- 
> Best regards,
>
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc
>
> Valentina - Joining Worlds of Information
> http://www.paradigmasoft.com
>
> [I feel the need: the need for speed]
>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina



More information about the Valentina mailing list