On 5/23/12, gaccep <
germ...@gmail.com> wrote:
> I was more concerned with other parts of the system like, Purchase
Okay.
I guess if it were me, my first thought would be to have a collection
in which each document represented one level in a multi-level
explosion, with the next-level components and their quantities in an
array, like so:
{ "_id": "Menu 1", "next level items": [ { "item":"bogey1", "qty" : 2
}, { "item": "bogey2", "qty" : 1 }, { "item": "bogey3", "qty": 3 } ] }
Since this is a multi-level bill of material (BOM) concept, each item
in the "next level items" array can itself be a bill of material, so,
like this:
{ "_id": "bogey1", "next level items": [ { "item": "carrots", "qty": 2
}, { "item": "onions", "qty": 1 }, { "item": "saffron", "qty": 0.25 }
] }
You would have to loop in your client code to iterate through the
levels to "explode" down to the required quantities of the lowest
level items, which is what your Purchasing agents need to buy. Not
pretty, but Bill of Materials never really is. This is no messier,
and might even be a little more elegant, than the same solution in an
RDBMS.
Your other option would be to denormalize the model to the extreme
that you have a complete top-to-bottom Bill of Material -- all levels
-- in a single document. That would make reading data extraordinarily
simple, but then maintenance could be a real challenge. If, for
example, "cumin" gets added as a "next level item" in "bogey1", and
"bogey1" occurs in many menus. As always in a NoSQL data design, how
you are going to use the data, how volatile it is, etc., are questions
that have to be considered as part of the design process. The
structure that I proposed might strike a balance in your situation.
Or not.
Information about what menus are served in which hospitals in which
weeks (i.e., demand) would be in a separate "Schedule" or "Demand"
collection, not your "BOM" collection. The "Schedule" collection
would tell you how many of what "top level" items (menus) you need,
and when. The "BOM" collection would then tell you what dishes and
ingredients are required to manufacture each of those top level items.
Your MRP client program would read those two collections to produce a
third collection of planned or projected orders for your Purchasing
department.
I apologize if I seem to be preaching the obvious. I'm just trying to
respond to the level of detail that was in the question.
HTH,
gs