It seems to me, that you don't want to store this value at all.
If you store it you will need to implement all sorts of checks and code to make sure that it is maintained accurately and stays in step with the related data (orders; purchases etc).
Whereas, if you calculate it on the fly (as you already know how to do), then it will always be accurate automatically and will also save you the extra head-ache of maintaining the data.
To better understand this concept have a look through Normalisation and Table structures which explains it quite well.
If you store it you will need to implement all sorts of checks and code to make sure that it is maintained accurately and stays in step with the related data (orders; purchases etc).
Whereas, if you calculate it on the fly (as you already know how to do), then it will always be accurate automatically and will also save you the extra head-ache of maintaining the data.
To better understand this concept have a look through Normalisation and Table structures which explains it quite well.
Comment