Subject Re: [firebird-support] Re: server-side number formatting
Author Martijn Tonies
> > I have a table that contains two columns/fiels :
> > - AMOUNT NUMERIC(18,4)
> > - IS_PERCENTAGE SMALLINT
> >
> > The IS_PERCENT field acts as a 'flag' on how to interpret the
> AMOUNT
> > field. If IS_PERCENTAGE is '1', then the AMOUNT field contains a
> > percentage value, otherwise it contains a currency value.
> >
> > AMOUNT = 12345, IS_PERCENT = 0 ---> $12,345
> > AMOUNT = 10, IS_PERCENT = 1 ---> 10%
> >
> > These fields are used repeatedly all around the database, and was
> > decided as the 'better' approach, compared to dealing with two
> separate
> > columns (i.e. CURRENCY_AMOUNT and PERCENTAGE_AMOUNT). The argument
> was
> > that keeping the value in separate column will create a more
> complicated
> > logic, not to mention the null handling headaches.

Actually, in my opinion, you opened a rats nest...

A field should hold only one value. Not multiple values depending on another
column.

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com