473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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.

Nov 13 '05 #1
8 2437
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.

Nov 13 '05 #2
sh******@cs.fsu.edu wrote:
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.


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
Nov 13 '05 #3
sh******@cs.fsu.edu wrote in
news:11*********************@g14g2000cwa.googlegro ups.com:
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.

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.
Nov 13 '05 #4
sh******@cs.fsu.edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.
There are no numbers with leading zeroes. There are just 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.
How many zeroes were you planning to store? Each one is likely to
require one byte.
Storing as a number still allows for formatting when displaying the
number, correct?
Yes.
I am creating a table and would like opinions regarding this please.


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
Nov 13 '05 #5
dkintheuk wrote:
Its possible to argue the case all over the place but experience has
shown me that text for phone numbers always works best.


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
Nov 13 '05 #6
Lyle Fairfield wrote:
sh******@cs.fsu.edu wrote:
I see other posts where some say fields that will hold a number with
leading zeros should be stored as text instead of numbers.

There are no numbers with leading zeroes. There are just 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.

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

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

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

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.
Nov 13 '05 #7

<sh******@cs.fsu.edu> wrote
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.


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.
Nov 13 '05 #8
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.

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Irwinsp | last post by:
Hi All, I have a form with an auto number field displayed. The field looks great except when the user is entering a new record. The field then has the text "auto number" in it. Is there a...
6
by: Sami | last post by:
Problem: Social Security number being used in a database. First problem is that it will not permit numbers beginning in zero to be entered - it sees it as a null or empty space from what I can...
2
by: Megan | last post by:
Hi everyone- I'm trying to convert social security numbers from a text data type to a number data type, but I lose data on some of the social security numbers, especially SS#s with 0's in them....
2
by: Jon Lapham | last post by:
I have a table that stores TEXT information. I need query this table to find *exact* matches to the TEXT... no regular expressions, no LIKE queries, etc. The TEXT could be from 1 to 10000+...
2
by: Carrie | last post by:
I have a number field with some numbers containing a decimal and some numbers with no decimal. In the code behind I put it into a decimal variable and to show this on a label I have the text of the...
4
by: Paul J. Lucas | last post by:
I have a simple form that contains an INPUT element that has an initial value. <form name="Form"> <input name="Number" type="text" value="Hello"> </form> When the form loads, I want all of...
0
by: Akaata | last post by:
Hi, How to change a text field into a number field using DB2 spufi? The text field contained a number value. Tia
12
by: Coni | last post by:
Hi All, I am working in Access to print Invoices. On each invoice there is a line number column which is a field to number each line for a product purchase. I would like to know if there is a...
2
by: Suhas Parchure | last post by:
I want a text field which should accept only text not number . How can i do that?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.