hierarchy table to treeview

i have a parent-child table like this:




create table product_structure {

   number varchar(20),

   parents varchar(20),

   description varchar(50)

}



im implementing a multi-parented tree

In my case, a child could have more than 1 parent, like the following:


G  A

 \ /

  B

 / \ 

X   C

  /  \

  D   E

  \ /

   F



i have to turn this into a treeview like this


G

 \                              

  B                             

 / \                        

X   C                           

  /  \                               

  D   E                     

  \ /

   F  


and


A

 \                              

  B                             

 / \                        

X   C                           

  /  \                               

  D   E                     

  \ /

   F  

 

note: i need to separate the "big" parent



any idea?

saving this is simple, but retrieve isn’t…

are recursive method is the best way to fill the tree?

what is the efficient way to make this a treeview?

i think about recursive the self relation in CActiveRecord model.

thanks for your comment

I am not quite sure if this is what you are searching for but as you are working with trees this behavior could be helpful: http://www.yiiframework.com/extension/nestedsetbehavior/

Hope it helps