Hi!
Sujay Koduri wrote (re-ordered):
-----Original Message-----
From: Asad Habib [mailto:[EMAIL PROTECTED]
Sent: Monday, July 25, 2005 11:53 PM
To: mysql@lists.mysql.com
Subject: Phone Number Storage
Is it better to store phone numbers as strings or as integers? Offcourse,
storing them as integers saves space but this requires extra processing of
the user's input (i.e. CPU time). Are there any other
advantages/disadvantages of doing it one way or the other?
- Asad
I think it is better to store the phone numbers as strings only. As phone
numbers may also include '-', if you allow entering international numbers,
it is good to store them as strings only.
Or you can ask the area code and the actual number seperately and store them
seperately in two columns as integers.
IMO, this is quite an USA-centric view in the answer: In general, phone
numbers will also contain a country code.
Outside the USA, it is quite common that codes (area or country) may
begin with a leading "0" which any numeric type would drop as not
significant, so you _must_ use strings for these.
Also: A telephone number is no numeric value, arithmetic operations do
not make sense on it. Think of extensions: phone numbers 1234-0 and
1234-56 are related, so you would order them (if at all) as strings and
not as numeric values.
The same applies to postal codes, social security numbers, part numbers etc.
While you may use a numeric type for some ID value you want to generate
yourself (using autoincrement), IMO this is on the borderline of correct
modeling. For phone numbers, you should use strings.
HTH,
Joerg
--
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]