>>The only time I've done something like this there was a requirement to allow a 'bundle' to be made up not only of items but also to contain other 'bundles'. The data structure was something like (using your Items table as is):
>>
>>Bundles
>>Id (PK)
>>Name
>>Price ?
>>etc....
>>
>>BundleList
>>Id (PK)
>>BundleId -> Bundles.Id
>>Quan
>>ComponentId
>>IsBundle
>>
>>If IsBundle is false then ComponentId points to Items.Id
>>If IsBundle is true then ComponentId points to Bundles.Id and can be processed recursively to also expand that bundle if required. End result is that even deeply nested collections of bundles can be unwound to a full list of items.....
>
>Last time I had something like this it was a similar table (self-referencing) in a production environment. The term used was "poluproizvod" (semi-product), which was appropriate in that context. It was to be used as a component in a final product, and it could have contained semi-products. It didn't go deeper than two or three levels. Don't know whether this expression would work in English. Sub-assembly, maybe.
>
>Actually, then I heard from someone, in a discussion on the subject, that the most complicated and largest contraption in use, an ocean liner, didn't go deeper than ten levels.
Last statement is interesting. Of course, once you go beyond one level the only approach that makes sense is a self-referencing/recursive one.
The one I worked on was basically for recipes (i.e. food). There were ~1000 ingredients from which recipes were built. More than five levels were quite common. Also fractions of a recipe as well as multiples were allowed. e.g based on Bread:
Recipe 1 : 100 loaves of bread
Item :Flour 20Kg
Water 100 litres
Recipe 2: 1 Loaf of Bread
Recipe 1 : 100th
Recipe 3: 1 Slice of Bread
Recipe 2 : 20th.
Recipe 4: Cheese Sandwich
Recipe 3 2
Recipe x (Cheese) 10gm
Obviously the 'Slice of Bread' recipe is primarily there for convenience - you could equally well make a sandwich with 1000th of the bread recipe. In practice it was also used to help compute production costs - i.e, in this case, the cost of slicing the bread.
Disclaimer : I am not a cook - do not attempt to make bread by following my recipe :-}
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only