I'm working on a project at the moment that will require storing of stock levels for individual products. The slight complication is that the products are chemicals and are stored in bulk and pre-weighed amounts (no, they're not illegal drugs!)
If I used table salt as an example, that might help to demonstrate. Each time you produce a batch of salt you get a yield (say the first batch produces 100g). You might sell the salt in amounts of 1g and 5g.
From the first batch, you pre-weigh 10 lots of 1g and 2 lots of 5g. So, the pre-weighed stock is 10 lots of 1g and 2 lots of 5g and your bulk stock is now 80g. As you sell the pre-weighed, you make up more and more pre-weighed packs until your bulk is down to 20g. So you make some more and this batch yields 110g. So your bulk is now 130g. You carry on transferring bulk to pre-weigh.
Each product is stored in the db and against that there is a weights, currency and price table for pre-weighed.
What will also be stored is the product yield per batch and as each product has pre-weighed packs produced. The weighed amounts are very precise and in much smaller sizes than the example I've given, hence the need for accuracy.
So, I think, in theory, my current bulk stock could be calculated by taking the sum of all the batch yields - the total of the pre-weighed packs made up. The pre-weighed stock could be calculated by taking the total packs pre-weighed - the sum of all those dispatched.
But then would this gradually get slower and slower as the number of items included in the sum grows and grows?
The other slight complication is that customers may ask for product from a specific batch (if they've had product from that batch before) so I can't really just bulk all the batches of each product in together. I need to have the ability to break it down by stock of each individual batch.
Would I be better just storing the current stock level of each batch in a seperate table / field and then summing them all up to get by product? Even though, in theory, I'm storing a calculated field.
Or any ideas on the best way to handle this?



LinkBack URL
About LinkBacks
Reply With Quote



Bookmarks