Database Design Advice

Peter Sergeant pete at clueball.com
Fri Nov 8 17:11:14 GMT 2013


On Fri, Nov 8, 2013 at 3:02 PM, Abigail <abigail at abigail.be> wrote:

> I opted for two columns, "additional" and "percentage", the first
> defaulting to 0, the other to 1. Prices can then be easily calculated
> as original_price * percentage + additional. No conditionals needed.
> And the calculation is currency agnostic. For discounts, the percentage
> is less than 1, or the additional is negative.
>
> This solution proved to be really great -- two years after my
> implementation
> I got the request "Can we have discounts from discounts? We'd like to be
> able to give both a percentage and a set discount" [1]. I told them,
> "If you just fill in both discounts, it will do what you want".
>

Unless what you want is the percentage discount applied to the price after
the flat discount, which doesn't seem unreasonable.

-P


More information about the london.pm mailing list