Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sequencing best practice
Message
De
22/06/2004 09:11:37
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
22/06/2004 00:22:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00915914
Message ID:
00916016
Vues:
8
This message has been marked as the solution to the initial question of the thread.
>Hi all,
>
>Is there a Best Practice out there for implementing a sequencing hierarchy? This would be very similar to a windows explorer.
>
>Currently, my implementation consists of two fields: SEQUENCE c(80) and SERIES c(1). I have an index on SEQUENCE+SERIES so that the grid would display the records in a hierarchical fashion. An example would be:
>
>ID  PID  SEQUENCE  SERIES
> 1    0  01000000
> 2    1  01010000
> 5    2  01010100
> 6    2  01010200
> 3    1  01020000
> 4    3  01020100
> 7    4  01020101
>...
>
The first fields of the table structure are perfectly adapted to a TreeView object. You don't need the field Sequence, at least, not for internal processing.

For an accounting system, I once tried to create an equivalent of the "sequence" with a UDF that used BinToC() for a binary representation. The idea of the sequence was to be able to add all lower-level accounts, to put them into a higher-level account. This was for internal use only.

If you need to show the information to the user, then you will have to use a system similar to what you are doing. In this case - and also for the "internal" use I mentioned above - it may be useful to have some sort of procedure that goes through an entire "branch" for a systematic replacement.

IOW, the structure seems appropriate, in principle. But there is one more problem: One parent might have more than 99 or 100 children. Perhaps you should increase it from the beginning, or use the notation which is well-known in IP version 4: 1.1.15...

>My problem is when I assign ID 4 to have a PID of 1 and move it after ID 2, I would have to change the sequence of ID 4 to that of ID 3 or 01020000. Then recreate the sequence of ID 3 and its children. Now imagine this if you have thousands of PID=1 records. I will have to update every sequence after the insertion point recursively down to its children.

Changing a few thousand records should be feasible, if you can access the records.

Using recursion is a little more complicated than non-recursive programming, but not very.

Also, you can replace the codes without using recursion. For instance, search for all records that start with "0103" and replace with "0104" + ...
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform