Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best Practice - Internal Code field for Heirarchial tabl
Message
From
31/08/2004 16:23:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00937935
Message ID:
00938187
Views:
29
This message has been marked as the solution to the initial question of the thread.
>Hi all
>
>I have this table which is displyed as a TreeView and is self-joined. The fields are as under:
>
>iID - Unique ID
>iPID - Parent record's ID
>cName
>cCode - Code field for which this query is about
>iSrNo - related to code field
>
>This will have records as below:
>
>1      0      ABC              001            1
>2      1      ABCChild1        001001         1
>3      1      ABCChild2        001002         2
>4      1      ABCChild3        001003         3
>5      3      ABCGranChildof2  001002001      1
>so on
>
>
>This code is not a specification, but I felt that it may be required, but then it has it's own processing and management overheads. The reason I had thought this would be necessary is because, I had felt that when I report I can ask for a report based on cCode = "001" or cCode = "001002" and the node and all it's children will come up.
>
>Similarly the iSrNo field is to allow the user to change the display order of the children nodes like for eg. the user wants the ABCChild3 to preceed ABCChild2 then he can change the Sr. No. from 3 to 2 and 2 to 3 (I will modify cCode accordingly on save).
>
>Have I done it right or there are better ways to do and get the same results.
>
>Please advise.

Bhavbhuti,
IMHO on the long run this would be tedious and even defeat a simple treeview structure (NodeID,ParentID,NodeText). You might never know beforehand how much deep your grandchildren node would be. cCode field might quickly run out of space.
I suggest a structure like :

NodeID,ParentId,NodeText,Level (0-root,1,...N),RootId (rootNode ID of this node),OrderInGroup

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform