Jeff O'Brien wrote:
>
> i have a zipcode column in a table.
> if i set the type to integer then if the zipcode is 02536 it stores 2536.
> i know i can change the type to char to fix the problem but is that
> recommended?
In fact, it is usually done that way. In most cases you want to store
numbers that do not hold an amount of some kind (dollars, liters,
inches, kilograms, units) as a string (char, varchar, whatever), because
- you can be reasonably sure that you don't want to do arithmetics with
them (makes no sense to multiplicate a serial number);
- it avoids sorting problems like the one you mentioned; and finally,
- you're open to add letters once you run out of digits.
The last one might sound unlikely to you, but believe me, many companies
tripped over that problem.
> also i have a large table that stores a lot of different numbers for
> estimating which does many math calculations in my app with these numbers
> how should i store all those numbers. some will be integers, longs and
> doubles.
> if i store them all as chars i can convert them before i use them but is
> that the right way to do things.
No, I would store these in their native format (ie. integer or floating
point), because otherwise you would waste performance when doing the
calculations. And the likelihood of running into problems when doing
comparisons (e.g. the string "4" is "greater than" the string "10") is
another reason.
The better way would be to convert them to strings only when needed -
e.g. for insterting them into a listbox.
Cheers,
Frank+++
--
Günter Schmidt & Co. oHG
Frank Bitterlich eMail: bitterlich at gsco dot de
Schlosserstr. 2-4 WWW: http://www.gsco.de/gsco
D-60322 Frankfurt Tel.: 069 / 156809-29
GERMANY Fax: 069 / 156809-28
|