First, please note this is a *design* question; i don't need code - not yet at least :)
Schematically, in my warehouse, items (goods) are charged upon receipt of "charge receipts", and are discharged upon issue of "discharge receipts".
In an RDBMS, to keep track of how many items in "warehouse" have been charged, discharged, and unsold (the difference), i could - on the fly - run proper queries on the "receipts" tables.
For performance purposes, i could instead store those values in the "warehouse" table directly, and update them each time a new receipt is created.
But, the question is: apart from performance, which is the best way to guarantee - or to enforce - consistency among "warehouse" and the two "receipts" tables?
I'm looking for *acquired* practices.