eddiec wrote:
hi everyone,
I am designing a pallet management system. Many items are placed onto one
pallet. The items are all unique and have distinct features. Now, as far
as application design is concerned the most intuitive way of handling this
would be to have a Pallet object that holds an array of Item objects,
which reflects the situation in real life. As far as database design is
concerned, however, it is easier for the item to 'know' which pallet it
belongs to.
e.g. I would create a table for the individual items where one of the
fields is palletID.
So what do I do? It would be very confusing (I think) to have different
design approaches in the application and in the database schema.
TIA
eddiec :-)
Hi,
if you insist on realizing the datastructure within your objects, then this
is a question about OO design, which is of interest in this news group only
as far as C++ happens to support OO design.
However, in C++ there are other approaches to go about your particular
problem. You have two types of objects: pallets and items. Moreover, each
item is placed on one and only one pallet. Thus, abstractly, you have a map
assigning pallets to items:
f : Items --> Paletts.
Viewed from this angle, you might use a container (like
std::map<Item,P alett>) that implements this setup. However, you might also
want to iterate through all items on a given pallet. Thus, the container
should allow for efficient compuatation of preimages and offer an iterator
type for this purpose.
Solving this problem as a (possibly templated) container has the advantage
that you can change the implementation afterwards without affecting the
design of the classes Pallet and Item.
Best
Kai-Uwe Bux