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 1hTWS2-0000Pc-RN for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 18:58:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hTWS1-0008Cw-Lx for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 18:58:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTWS1-0008Ck-Cc for pgsql-general@lists.postgresql.org; Wed, 22 May 2019 18:58:57 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTWRz-00028y-5k for pgsql-general@lists.postgresql.org; Wed, 22 May 2019 18:58:57 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id C131C99387 for ; Wed, 22 May 2019 11:58:52 -0700 (PDT) Date: Wed, 22 May 2019 11:58:52 -0700 (PDT) From: Rich Shepard To: "pgsql-generallists.postgresql.org" Subject: Re: Bulk inserts into two (related) tables In-Reply-To: Message-ID: References: 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 Wed, 22 May 2019, Jeremy Finzel wrote: > Are you saying your database already has an organizations table, and this > data file is appending to it with all-brand-new organizations and people? Jeremy, The database has both organizations and people tables (among others) which are already populated. The source file appends rows to both tables. > Say you have 800 people. Are you honestly saying that there are also 800 > organizations? If so, I guess your solution would work. However, I thought > that it was the case that multiple people belong to the same organization. > Hence, the entire problem of mapping we have been discussing. No. But, each organization may have several people, each one at a different facility. Think of a bank with one headquarters but different mangers in each of their branches. > Also, you said previously that some fields from your data file would be > populated in *both tables*. That is a fundamental violation of DB design. > Why are you duplicating that data in two places? Not if the duplicated data field is the primary key in the organizations table and the referenced foreign key in the people table. Regards, Rich