Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Friends, I am developing an application for medium size shopping mall in ASP.net4 with sql server 2008. Should I store derived values like Total price in database or should I calculate this type of values from unit price each time when necessary. Earlier I preferred storing this type derived values in database as it helped me to show data to the user very easily. Waiting for your suggestion. Thank you friends.
Posted

1 solution

Hi,
It's not a good practice to store calculated (aggregated) data in the database, for your report's simplicity, design a view and bind it to your report!
Imagine different scenarios here, based on your current logic, if the customer canceled the order or changed the number of the items in specific order, you need to do the calculations again and you need to update your aggregated fields! but if you aren't keeping them in the database, you don't care because you're view will take care of the calculations and your customer will get the correct results.
 
Share this answer
 
Comments
Brajabas 22-Jun-12 10:36am    
Thanks Sameer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900