Subject Re: [ib-support] Numeric, Decimal, Double Precision and Float data types. What and when to use?
Author Paul Schmidt
On 10 Jul 2002 at 12:06, Theo Bebekis wrote:

> Hi
>
> could please someone give me more details, than those
> provided by Interbase docs, about those data types?
> Is there any white paper providing more info on the issue?
>
> What do you recommend me to use?
> Numeric and Decimal or the IEEE types (Double and Float)?
> Does it depends? On what?

Under Firebird (and Interbase) NUMERIC and DECIMAL are functionally equivilent,
they are slightly different under the standard, and are different from a double. The
best reason for using them, is they are self documenting, if a field is intended to
hold values of less then 1000000 with two decimal places (say money values) then
you can use a NUMERIC(9,2), which shows that you intend to use the field for
values limited this way. DOUBLE PRECISION only shows that the value is a real
number.

> Also...
> I see that MASTSQL database, provided with some of Delphi's demo apps,
> uses DOUBLE PRECISION for ORDERNO and CUSTNO of the ORDERS table to
> name a few cases.
>
> Is that a wise decision? Why not just INTEGER?
> Usually that kind of fields are of the INTEGER type, or not?
>
> ORDERNO is the primary key where CUSTNO is foreign key to
> CUSTOMER table.
>

You should never use a double as a primary key, because doubles are slightly
inaccurate when using certain values, often examples that do this kind of thing,
were "converted" from something else. These days you should use either a
NUMERIC(18,0) -- 64 bit integer -- or INTEGER column for a primary key, then
attach that column to a generator using a before insert trigger. The 64bit integer is
prefered, because the range of values is so great it's unlikely that any table will run
out of values.

Paul Schmidt, President
Tricat Technologies
paul@...
www.tricattechnologies.com