Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hierarchy table structure
Message
 
À
03/01/2002 05:53:27
Dino Liberale
Ministero Lavori Pubblici
Trieste, Italie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00600157
Message ID:
00600172
Vues:
20
>Hi all,
>I am trying to resolve this recurseive situation:
>CONTEXT: a industry produce a complex article (like a car), a car is constituted of many parts (motor, etc.), motor is constituted on other many parts, and so on ...
>To save data I think a minimal table like this:
>
>TABLE PARTS
> 1 - id_part
> 2 - id_parent_part
> 3 - quantity
>
>QUESTION:
>How to manage the tree structure that result from a similar situation ?
>
>I know, this is a complex but common problem, could you help me with any idea or experience ?
>
>T.I.A.


Hi,

Despite somewhere is some truth in Hilmar's reply about the two tables, his solution can (and should ;) be approached differently, but which is not important to the problem. But anyway : whether you buy a nail or produce one, it's just another Item in the Item file.
The composites are another story, which can (no, should) just be held in one separate table, and the PK always consists of Parent and Child (in fact it's a relator). Never mind this too, because it isn't your problem.

Now just think of printing the full expanded bill of materials, for which you will need a recursive function indeed; the print will start with the main Item (may be the car, or may be the motor, just where you like it to begin), and the explosion of the first main part will follow.
Your recursive function will stop when all the branches of this main branche are finished printing, and the next branche will be taken. In fact not difficult at all when you have some experience on recursive programming. BTW, I can predict already that someone will come up with some super-smart three line SQL commands for it, which doesn't look recursive at all, but in fact is in the inside. But never mind this again.

Now when you'd have the print running, you can make a treeview, right ?
So just put everything in some temporary table containing the level-info per record, as if it were a print.

Good luck !
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform