ZwartWitVlindertje wrote:
> My question is:
> Number 1 + Number 2 = Number 3
>
> What do I do to store 'Number 3' in the DB?
If numbers 1 and 2 are already stored in the database, you
don't need to
store number 3. In fact, you shouldn't. A general principle
of databases
is that data should be stored at its basic level, and you
should never
store the result of a calculation derived from numbers
already stored in
the database.
Why? Let's say your database stores prices, and everything is
subject to
10% sales tax. If you create another column for the
tax-inclusive price,
you will have to update every single record in the database
if the tax
rate goes up to 15%. However, by storing the price on its
own, you can
always calculate the tax-inclusive price either in PHP or in
your SQL query.
SELECT price * 110 AS tax_inc FROM price_table
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/