In all the applications I have made where a database is used I typically store the calculated value along with the variables needed to calculate that value. For example, if
In my experience, the most common thing to do is to a) store the calculated value, b) without any CHECK constraints in the database that would guarantee that the value is correct.
The right thing to do is either
MySQL doesn't support CHECK constraints. So your options are