I guess anywhere we have 3 levels of hierarchies for a phone number. (Country code, Area code and the actual number). The advantage of seperating them into different columns(Either an integer or a string) is that he can group different phone numbers based on area code or country code.
sujay -----Original Message----- From: Joerg Bruehe [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 26, 2005 1:34 AM To: mysql@lists.mysql.com Cc: Sujay Koduri; Asad Habib Subject: Re: Phone Number Storage 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]