Values that undergo calculations, if you store the value with the calculations in the database?

0

I'm developing a system where a product undergoes 3 changes before arriving at its final value:
Individual Discount, Sale Bonus and Overall Discount
I want to know if, I should store only the original value of the product in the database or if I already do all the calculations related to this product and then saved the final value of it. In my case, the daily calculations would still be done. It would work as if it were quantity. Product * daily.
By database normalization, how would the correct procedure to persist this data?

    
asked by anonymous 31.10.2014 / 23:23

1 answer

1

You choose, if your system is architected to have database processing, then you can already store the final value of the product, but this will prevent you from knowing what the rebates were right away (You would have to undo the calculations for that).

If you run the calculation before storing the value and in the end already storing it discounted, you would need to create a field in the table to store the original value. While if you store the original value you can display the discount amount on a view, but the process can be the reverse as well.

Anyway, it depends on your architecture, what do you feel most comfortable about? Store the original value and then cash? Or the other way around?

    
01.11.2014 / 01:05