Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 258F5B5DBBD for ; Mon, 23 May 2011 13:02:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 34883-07 for ; Mon, 23 May 2011 16:02:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from zebedee.cranntara.net (zebedee.cranntara.net [91.186.7.79]) by mail.postgresql.org (Postfix) with ESMTP id 043B0B5D90E for ; Mon, 23 May 2011 13:02:09 -0300 (ADT) Received: from [88.210.188.180] (helo=bolek.coachhouse) by zebedee.cranntara.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1QOXa0-0003C9-FC for pgsql-sql@postgresql.org; Mon, 23 May 2011 17:02:06 +0100 Received: from dick.coachhouse ([192.168.1.32] ident=tarlika) by bolek.coachhouse with esmtp (Exim 4.69) (envelope-from ) id 1QOX8U-0001q5-WD for pgsql-sql@postgresql.org; Mon, 23 May 2011 16:33:39 +0100 Date: Mon, 23 May 2011 16:33:41 +0100 From: Tarlika Elisabeth Schmitz To: pgsql-sql@postgresql.org Subject: Re: extracting location info from string Message-ID: <20110523163341.56edb1aa@dick.coachhouse> In-Reply-To: References: <20110522210526.0f8b66fa@dick.coachhouse> <20110522230041.28d1bc35@dick.coachhouse> <4DD9BB87.7070000@postnewspapers.com.au> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201105/134 X-Sequence-Number: 35418 On Mon, 23 May 2011 00:25:16 -0400 Lew wrote: >That isn't a table structure, that's a freeform text structure. You >didn't state your question, Tarlika, but your database structure is >terrible. For example, "region" and "country" should be different >columns. I presume you are referring to my original post: CREATE TABLE person ( id integer NOT NULL, "name" character varying(256) NOT NULL, "location" character varying(256), CONSTRAINT person_pkey PRIMARY KEY (id) ); Sorry, this was just a TEMPORARY table I created for quick analysis of my CSV data (now renamed to temp_person). The target table is: CREATE TABLE person ( id integer NOT NULL, "name" character varying(100) NOT NULL, country character varying(3), county character varying(3), town character varying(50), CONSTRAINT trainer_pkey PRIMARY KEY (id), CONSTRAINT country_person_fk FOREIGN KEY (country) REFERENCES country (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE RESTRICT, CONSTRAINT county_person_fk FOREIGN KEY (country, county) REFERENCES county (country, code) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, ); -- Best Regards, Tarlika Elisabeth Schmitz