Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tree structures?
Message
From
19/12/1998 06:01:44
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00168160
Message ID:
00169093
Views:
21
>Im wondering how one would implement a set of records that are sorted tree like, as oposed to linearly. ie create a family tree where each node can have a marrage link, more than one children link, and a parent link. Not a simple tree, either: there would actualy have to be more that one marrage link, and maried into the family people would only have one link.
>
>Any idea how one would do this, indeed, is it possible?

Jeff,

For the table I use a two methods. One is the self-referential FK, where each child keeps the PK of its parent, along with its sibling order. I have a routine which then translates those into a single field which contains one column (or two, depending on the data need) column for each level into the tree.

If there are going to be 8 levels, and we are allowing (using base 10; in reality one would use base 254, leaving out chr(0) ) 10 children per level:

Parent is: 00000000
First child of parentis: 01000000
Second child of parent is 0200000
First Sib of Parent is: 1000000

Now, the beauty of this is that an index puts it in correct order; and additem works fastest, in most controls (it ismy observation) when the control knows we are adding to the end of the item list for the control. A very simple routine turns the child/parent and sib order information into this field.

HTH,

Hank
Previous
Reply
Map
View

Click here to load this message in the networking platform