Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AD0F51F60709 for ; Fri, 9 Dec 2011 05:57:50 -0400 (AST) Received: from mail.sihirhosting.com ([77.92.143.143]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RYxD9-00084q-Vb for pgsql-sql@postgresql.org; Fri, 09 Dec 2011 09:57:50 +0000 Received: (qmail 28502 invoked by uid 509); 9 Dec 2011 11:38:48 +0200 Received: from 212.156.129.218 by gaya (envelope-from , uid 507) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.7/2391. spamassassin: 3.0.2. perlscan: 1.25-st-qms. Clear:RC:0(212.156.129.218):SA:0(-95.7/6.7):. Processed in 1.467367 secs); 09 Dec 2011 09:38:48 -0000 X-Spam-Status: No, hits=-95.7 required=6.7 X-Antivirus-MYDOMAIN-Mail-From: emre.hasegeli@tart.com.tr via gaya X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:0(212.156.129.218):SA:0(-95.7/6.7):. Processed in 1.467367 secs Process 28441) Received: from unknown (HELO tart-hasegeli-development) (emre.hasegeli@tart.com.tr@212.156.129.218) by mail.sihirhosting.com with AES256-SHA encrypted SMTP; 9 Dec 2011 11:38:46 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: Andreas Cc: pgsql-sql@postgresql.org Subject: Re: Question on imports with foreign keys References: <4EE05DD3.2080308@gmx.net> <4EE08CFE.3090209@gmx.net> Date: Fri, 09 Dec 2011 11:39:07 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Emre Hasegeli" Organization: =?utf-8?B?VGFydCDEsG50ZXJuZXQgVGVrbm9sb2ppbGVyaSBBxZ4=?= Message-ID: In-Reply-To: <4EE08CFE.3090209@gmx.net> User-Agent: Opera Mail/11.60 (Linux) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/36 X-Sequence-Number: 36097 On Thu, 08 Dec 2011 12:10:06 +0200, Andreas wrote: > Lets's say there were already 1000 records in the customers table. > Now I add 357 new customers to this table. > If I use one of your queries I'd get all 1357 entries of customers > since "project_x.projectinfos" would be newly created for this project > and therefor empty. > I need to know which customers.id was created for which line in the > temporary table that I read in with copy. > When I have those ids I can fill "project_x.projectinfos" with just > those new 357 customer.ids and foreign keys refering the new > lookup-tables. Sorry, I do not understand exactly. What is the difference between the new 357 customers and the existent 1000 customers? If it is the date they inserted, then the should be filtered by the date. If it is another attribute like project they are related, then they should be filtered by the project column or the relation table.