From: Tarlika Elisabeth Schmitz <postgresql3@numerixtechnology.de>
To: pgsql-sql@postgresql.org
Subject: extracting location info from string
Date: Sun, 22 May 2011 21:05:26 +0100
Message-ID: <20110522210526.0f8b66fa@dick.coachhouse> (raw)
A column contains location information, which may contain any of the
following:
1) null
2) country name (e.g. "France")
3) city name, region name (e.g. "Bonn, Nordrhein-Westfalen")
4) city name, Rg. region name (e.g. "Frankfurt, Rg. Hessen")
5) city name, Rg region name (e.g. "Frankfurt, Rg Hessen")
Using the tables below, I would like to derive COUNTRY.ID, REGION.CODE,
city name.
=====
CREATE TABLE person
(
id integer NOT NULL,
"name" character varying(256) NOT NULL,
"location" character varying(256),
CONSTRAINT person_pkey PRIMARY KEY (id)
);
CREATE TABLE country
(
id character varying(3) NOT NULL, -- alpha-3 code
"name" character varying(50) NOT NULL,
CONSTRAINT country_pkey PRIMARY KEY (id)
);
CREATE TABLE region
(
country character varying(3) NOT NULL,
code character varying(3) NOT NULL,
"name" character varying(50) NOT NULL,
CONSTRAINT region_pkey PRIMARY KEY (country, code),
CONSTRAINT country_region_fk FOREIGN KEY (country)
REFERENCES country (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE RESTRICT
)
=====
System: PostgreSQL 8.4
--
Best Regards,
Tarlika Elisabeth Schmitz
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: postgresql3@numerixtechnology.de
Subject: Re: extracting location info from string
In-Reply-To: <20110522210526.0f8b66fa@dick.coachhouse>
* 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