Viorel wrote: > It is your decision, but i still say : Don't put calculated values in > the database.
It really is a question of balance. Is it better to keep calculated values up to date on the WRITE, or determine those calculated values on a READ? If the application will perform a WRITE more frequently than a READ, or even in a roughly equivalent frequency, then calculate on a READ. If the application will be doing more READs than WRITEs, then calculate and store the values upon WRITE. The more often the READs are done, the better for your throughput. The more expensive (processing-wise) your calculations are, the better for your throughput. In Juan's case, I don't think I would do it on a per-lineitem for the invoice, but I would do it on persisting the invoice. Give the user the option to 'recalc my bill' if they really wanted to see the fully determined invoice, but on the first addition or deletion or change of a lineitem, I'd clear the subtotal, taxes, and total, and show/enable the 'recalc now'. If a user is sitting down to enter 10 lineitems, don't let the 'automatic calcs' get in the way of the users throughput in entering those 10. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

