Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 10:17 AM
shumaker@cs.fsu.edu
Guest
 
Posts: n/a
Default Text versus Number field.

I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

This is very inefficient though, as a string of digit characters takes
up much more memory than a 32bit or even a 64bit int.

Storing as a number still allows for formatting when displaying the
number, correct?

I am creating a table and would like opinions regarding this please.

  #2  
Old November 13th, 2005, 10:18 AM
dkintheuk
Guest
 
Posts: n/a
Default Re: Text versus Number field.

I work for a telephone company and there is a great deal of difference
between local UK numbers (one leading zero), international numbers
(double zero) local numbers (no leading zeros).

Yes i know that you could have an indicator but it is far simpler to
hold numbers in text format for this purpose.

Its possible to argue the case all over the place but experience has
shown me that text for phone numbers always works best.

Just a thought...

Rob.

  #3  
Old November 13th, 2005, 10:18 AM
Rick Brandt
Guest
 
Posts: n/a
Default Re: Text versus Number field.

shumaker@cs.fsu.edu wrote:[color=blue]
> I see other posts where some say fields that will hold a number with
> leading zeros should be stored as text instead of numbers.
>
> This is very inefficient though, as a string of digit characters takes
> up much more memory than a 32bit or even a 64bit int.
>
> Storing as a number still allows for formatting when displaying the
> number, correct?
>
> I am creating a table and would like opinions regarding this please.[/color]

It depends. If there is a requirement to store both of these...

012
0056

....Then a format of a number field cannot do the job. Also if...

012
12
0012

....need to be treated as different entries then a number field cannot do the
job.

The performance differences between using text versus number are largely
theoretical these days. Yes if you were doing massive calculations and ran
a series of timed loops you would see a difference. In any "normal"
situation you will not.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


  #4  
Old November 13th, 2005, 10:18 AM
Bob Quintal
Guest
 
Posts: n/a
Default Re: Text versus Number field.

shumaker@cs.fsu.edu wrote in
news:1114544307.121409.11360@g14g2000cwa.googlegro ups.com:
[color=blue]
> I see other posts where some say fields that will hold a
> number with leading zeros should be stored as text instead of
> numbers.
>
> This is very inefficient though, as a string of digit
> characters takes up much more memory than a 32bit or even a
> 64bit int.
>
> Storing as a number still allows for formatting when
> displaying the number, correct?
>
> I am creating a table and would like opinions regarding this
> please.
>[/color]
Rule #1:
If you will add, divide, multiply or divide this number then
store it as a number.
else
store it as a string
endif

If leading zeroes are important, I suspect that the else
condition will apply.

--
Bob Quintal

PA is y I've altered my email address.
  #5  
Old November 13th, 2005, 10:18 AM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: Text versus Number field.

shumaker@cs.fsu.edu wrote:[color=blue]
> I see other posts where some say fields that will hold a number with
> leading zeros should be stored as text instead of numbers.[/color]

There are no numbers with leading zeroes. There are just numbers.
[color=blue]
> This is very inefficient though, as a string of digit characters takes
> up much more memory than a 32bit or even a 64bit int.[/color]

How many zeroes were you planning to store? Each one is likely to
require one byte.
[color=blue]
> Storing as a number still allows for formatting when displaying the
> number, correct?[/color]

Yes.
[color=blue]
> I am creating a table and would like opinions regarding this please.[/color]

Store numbers as numbers. It's easier to have an opinion when one knows
what you are trying to do and why.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
  #6  
Old November 13th, 2005, 10:18 AM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: Text versus Number field.

dkintheuk wrote:[color=blue]
> Its possible to argue the case all over the place but experience has
> shown me that text for phone numbers always works best.[/color]

Well, that settles it. Thanks for the ruling.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
  #7  
Old November 13th, 2005, 10:18 AM
Salad
Guest
 
Posts: n/a
Default Re: Text versus Number field.

Lyle Fairfield wrote:
[color=blue]
> shumaker@cs.fsu.edu wrote:
>[color=green]
>> I see other posts where some say fields that will hold a number with
>> leading zeros should be stored as text instead of numbers.[/color]
>
>
> There are no numbers with leading zeroes. There are just numbers.
>[color=green]
>> This is very inefficient though, as a string of digit characters takes
>> up much more memory than a 32bit or even a 64bit int.[/color]
>
>
> How many zeroes were you planning to store? Each one is likely to
> require one byte.
>[color=green]
>> Storing as a number still allows for formatting when displaying the
>> number, correct?[/color]
>
>
> Yes.
>[color=green]
>> I am creating a table and would like opinions regarding this please.[/color]
>
>
> Store numbers as numbers. It's easier to have an opinion when one knows
> what you are trying to do and why.
>[/color]
The day I store SSNs and phone numbers as a numeric field and not as an
alphanumeric field is the day after I retire from programming and
progress to another type of work.
  #8  
Old November 13th, 2005, 10:18 AM
Larry Linson
Guest
 
Posts: n/a
Default Re: Text versus Number field.


<shumaker@cs.fsu.edu> wrote
[color=blue]
> I see other posts where some say fields
> that will hold a number with leading zeros
> should be stored as text instead of numbers.
>
> This is very inefficient though, as a string
> of digit characters takes up much more
> memory than a 32bit or even a 64bit int.
>
> Storing as a number still allows for formatting
> when displaying the number, correct?
>
> I am creating a table and would like
> opinions regarding this please.[/color]

One general rule that seems to work well is to store in numeric field format
if the number is to be used in calculations; store in text if the "number"
is for identification. After a few years in the application development
business, I am no longer surprised when a "Product ID Number" turns out to
have alphabetic characters, or when the client later decides to use
alphabetic characters in a previously all-numeric identification.

Lyle is correct... "leading zeros" are only a particular format for
displaying numbers. 000012 is the same number as 0012 or 12. Rick is
correct... if 000012 is different from 0012 or 12, you are not talking about
numbers, but about numeric characters which you will have to store in text.


  #9  
Old November 13th, 2005, 10:19 AM
dkintheuk
Guest
 
Posts: n/a
Default Re: Text versus Number field.

Oooo you are cheeky!

Its nice to know that I'm not bonkers after all now i've looked at the
other answers. They also explain it better i.e. calculations use
numeric, idnetifiers use alphanumeric... easy.

Rob.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles