From: Steve Crawford <scrawford@pinpointresearch.com>
To: scott.marlowe <scott.marlowe@ihs.com>
To: Bruce Young <hbrucey@yahoo.com>
Cc: PostgresPHP <pgsql-php@postgresql.org>
Subject: Re: updating integer column
Date: Mon, 24 Feb 2003 11:27:04 -0800
Message-ID: <20030224192704.AF0D4103C2@polaris.pinpointresearch.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com>
References: <Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com>
> > oh and what is the best datatype to use for a 10 digit phone number?.
-snip-
> Secondly, for a phone number, ask yourself how you're going to treat it.
> Are you going to do a sum() across the numbers? Or maybe multiply them
> together?
>
> If yes, then you should store them as some kind of numeric, int, or as a
> float.
>
> If, however, the numbers are not going to be used for math but for
> identification, then it is likely that a text / varchar type would be a
> better choice.
Don't use int:
create table foo (ph int);
insert into foo values (5105551212);
ERROR: dtoi4: integer out of range
Use char(10).
Better yet, "properly" normalize phone numbers into area-code (char(3)),
prefix (char(3)) and number (char(4)) fields. This way you can error-check
your phones against the area-code table, determine approximate geographical
areas/time-zones, flag dangerous numbers (very high cost off-shore versions
of 900/976 numbers that look like ordinary phone numbers), etc.
If you really want to you can even include a prefix table to do the same
thing at the exchange level using NANPA data.
Even if you don't use a prefix table, updating your table when area-codes
split will be easier if the ac and prefix are in their own fields.
It may be overkill for your app but for a variety of reasons is a requirement
for ours.
Cheers,
Steve
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: scrawford@pinpointresearch.com, scott.marlowe@ihs.com, hbrucey@yahoo.com
Subject: Re: updating integer column
In-Reply-To: <20030224192704.AF0D4103C2@polaris.pinpointresearch.com>
References: <Pine.LNX.4.33.0302241014380.1816-100000@css120.ihs.com> <20030224192704.AF0D4103C2@polaris.pinpointresearch.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox