X-Original-To: pgsql-php@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 44126475E8A for ; Mon, 24 Feb 2003 14:55:50 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 52477-06 for ; Mon, 24 Feb 2003 14:55:22 -0500 (EST) Received: from polaris.pinpointresearch.com (66-7-238-176.cust.telepacific.net [66.7.238.176]) by postgresql.org (Postfix) with ESMTP id 9C7AD475E97 for ; Mon, 24 Feb 2003 14:27:04 -0500 (EST) Received: from there (66-7-238-179.cust.telepacific.net [66.7.238.179]) by polaris.pinpointresearch.com (Postfix) with SMTP id AF0D4103C2; Mon, 24 Feb 2003 11:27:04 -0800 (PST) Content-Type: text/plain; charset="iso-8859-1" From: Steve Crawford Organization: Pinpoint Research To: "scott.marlowe" , Bruce Young Subject: Re: updating integer column Date: Mon, 24 Feb 2003 11:27:04 -0800 X-Mailer: KMail [version 1.3.1] Cc: PostgresPHP References: In-Reply-To: MIME-Version: 1.0 Message-Id: <20030224192704.AF0D4103C2@polaris.pinpointresearch.com> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/50 X-Sequence-Number: 1901 > > 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).=20 Better yet, "properly" normalize phone numbers into area-code (char(3)),=20 prefix (char(3)) and number (char(4)) fields. This way you can error-check= =20 your phones against the area-code table, determine approximate geographical= =20 areas/time-zones, flag dangerous numbers (very high cost off-shore versions= =20 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=20 thing at the exchange level using NANPA data. Even if you don't use a prefix table, updating your table when area-codes= =20 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 requireme= nt=20 for ours. Cheers, Steve