From: | Paul Schmidt <wogsterca(at)yahoo(dot)ca> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: OT: Address Fields |
Date: | 2003-08-11 02:42:11 |
Message-ID: | 1060569730.2468.118.camel@habs.tricat.bog |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 2003-07-31 at 05:39, 2trax wrote:
> Hi everyone,
>
> Just wondering if anyone has any tips on the best way to represent
> international addresses (ie from any country) in a database?
>
> It seems to me that the most flexible way is to use a text field to hold
> everything, apart from the country which suits a varchar? and perhaps have
> another dedicated varchar field to hold USA ZIP codes / UK post codes for
> easy searching?
>
Here is an idea write a small parsing routine, so that you can use a
table to do it. Something like this:
%1 - suite, %2 - street number, %3 = street, %4 = city, %5 = district %6
= postal-code, %7 = country, %n = new-line.
Then create a table to hold the information, possibly with different
formats whether suite numbers are used or not. Something like this:
create table country_formats (
country char(2),
country_name varchar(30),
with_suite varchar(60),
without_suite varchar(60));
Then add records like this:
"CA", "%1-%2 %3%n%4, %5%n%6 %7", "%%2 %3%n%4, %5%n%6 %7"
"US", "%1-%2 %3%n%4, %5%n%6 %7", "%%2 %3%n%4, %5%n%6 %7"
Now you enter addresses as individual components, using a single
standard data entry screen, and let the parser do the formatting.
W
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2003-08-11 03:00:01 | Re: Conditional row grained replication with DBMirror |
Previous Message | Ron Johnson | 2003-08-11 02:13:06 | Re: Email DML Errors and Constraint Violations |