Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2B2BF384473 for ; Thu, 8 Dec 2011 02:49:06 -0400 (AST) Received: from mailout-de.gmx.net ([213.165.64.22]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RYXmy-0007nl-Am for pgsql-sql@postgresql.org; Thu, 08 Dec 2011 06:49:05 +0000 Received: (qmail invoked by alias); 08 Dec 2011 06:48:51 -0000 Received: from mue-88-130-5-014.dsl.tropolys.de (EHLO [192.168.1.113]) [88.130.5.14] by mail.gmx.net (mp008) with SMTP; 08 Dec 2011 07:48:51 +0100 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX1+UZA9lDnKUgHggSWoINILMT+smJAQusXnWgD/oFc mYYurphfFOiqFX Message-ID: <4EE05DD3.2080308@gmx.net> Date: Thu, 08 Dec 2011 07:48:51 +0100 From: Andreas User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: pgsql-sql Subject: Question on imports with foreign keys Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -3.1 (---) X-Archive-Number: 201112/25 X-Sequence-Number: 36086 Hi, suppose you need to import a csv with standard ciolums like name, adress, phone, ... and some additional text columns that need to be split off into referenced tables. Those lookup-tables will only be needed for a project with limited life time so I create a schema that might be called "project_x". There I create the necessary lookup tables. The core of the import will be added to the customers table with unlimited livespan. The customers table has a PKey id which is a serial. I don't want to add FKey columns into customers for the new lookup-tables so I create another table in project_x "projectinfos" that stores those FKeys and another FKey that references customers.id. First question: Is this a stupid aproach? If not: How is the easiest way to to find the customer.id of the new customers so I can insert the projectinfos?