> id parent_id order_num level left_id right_id name
> 5 5 1 1 1 10 Root A
> 7 7 1 1 1 4 Root B
> 6 5 1 2 2 5 Sub1 of A
> 1 5 2 2 6 9 Sub2 of A
> 2 5 1 3 3 4 Child of Sub1
> 3 5 1 3 7 8 Child of Sub2
> 4 7 1 2 2 3 Sub of B
>
> When this tree is outputed as a menu structure it looks correct. I just
don't understand why.
> Could anybody help me out here ?
The structure is a list of "Modified Preorder Trees" (MPT)
Parent_id is the id of the root of the tree. Each root is the base of a MPT.
Order_num is the sort order of the roots.
Level is the level inside a tree
Left_id and Right_id are not id numbers, but the numbers you see below in
the explanation of a single tree.
Modified Preorder Tree
A tree in which the nodes are connected by left and right
'links'.
1[top]14
|
--------------------------
| |
2[childA]7 8[childB]13
| |
------------- ---------------
| | | |
3[childC]4 5[childD]6 9[childE]10 11[childF]12
This way it takes only a single query to retrieve a (sub)tree.
Inserting new nodes takes more effort (two update queries, one insert), but
when this occurs rather infrequently it's far more efficient overall.
Furthermore, retrieving a (sub)tree does not require recursive functions
(which are quite inefficient in a language such as PHP).
Regards, Jigal
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]