Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gT7Gx-0004y9-Bw for pgsql-general@arkaria.postgresql.org; Sat, 01 Dec 2018 15:33:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gT7Fw-0000P1-1w for pgsql-general@arkaria.postgresql.org; Sat, 01 Dec 2018 15:32:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gT7Fv-0000Or-Mh for pgsql-general@lists.postgresql.org; Sat, 01 Dec 2018 15:32:31 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gT7Ft-00084C-48 for pgsql-general@postgresql.org; Sat, 01 Dec 2018 15:32:30 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 40596992EE for ; Sat, 1 Dec 2018 07:32:27 -0800 (PST) Date: Sat, 1 Dec 2018 07:32:27 -0800 (PST) From: Rich Shepard To: pgsql-general@postgresql.org Subject: Re: Process for populating tables in new database [RESOLVED] In-Reply-To: <46b7813b-9c5c-c98f-8895-88bc4de635e7@aklaver.com> Message-ID: References: <46b7813b-9c5c-c98f-8895-88bc4de635e7@aklaver.com> User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 1 Dec 2018, Adrian Klaver wrote: > If you don't supply the key it will be generated as the default for the PK > column is a sequence. Thanks, Adrian. I thought this to be the case and did not find confirmation in the manual (perhaps I just missed seeing it.) > So are the tables you are INSERTing into currently unpopulated? Yes. > In any case you will need to do this in sequence, where you populate the > company table and then the contact table. The question is whether you want > to pre-assign the company id's in the company data and the company_id_fk > in the contacts data or not. If not then you will need to grab the company > id's after populating the company table and match those to the contacts > data before inserting it. This clears up everything. I'll let pg assign company id's then use them as you write to relate the other tables to the proper company/contact. Much appreciated, Rich