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 1hT8WO-0000ut-2p for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2019 17:25:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hT8WM-0002Y9-MF for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2019 17:25:50 +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 1hT8WL-0002KF-FT for pgsql-general@lists.postgresql.org; Tue, 21 May 2019 17:25:50 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT8WJ-0005Jn-5Y for pgsql-general@lists.postgresql.org; Tue, 21 May 2019 17:25:48 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 900CE23E45; Tue, 21 May 2019 13:25:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 21 May 2019 13:25:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=Q PtEmMbpFmSLnEbJUHaKmo9kGQOEnzxc9dQXstTEM+Q=; b=boAlaec/DCOU+q/t1 tn3ewdBMXm8VQN1qANuC1mLYclj/I/1ArrYJzn9fG6w3O+QF8PfUFV38qOH3JHA/ d4O4QUVN5GgLlQLDVWbxH/rnbMdo6biYBPFPMYvKdZcWWKXJBDkQnRdNa3bgLi/H JIY8yvQaaFyRNhhOKS6PADdjviQVBBRWgCOQkYUl5kysxLU0hUl9Xq9jOoSGAFJs nymk7RVmV9/G7jZptJAHa2YsePC+zAfT6Ki2SElPCWzJeWuCJUCn/cxqzyNtppeq fWHTQEot28FkCCqInypWT0roGO+eHosp/TXXHtbOFAXh0/TV/DtLKi6u69laT4np W/6qQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=QPtEmMbpFmSLnEbJUHaKmo9kGQOEnzxc9dQXstTEM +Q=; b=lZbeAL9dOWiC6oNkeWQHTFdzPWoGAXECxrZWK8uVu38CzFSTUE2+5gIs4 d6sSV7WXLb4oAgcCwOygkPKlXAHYR8WgYTYloqMnodjqbEy3PqBX2v7zL69wIVFk TFi5ytv6Hh52TxXL1FisqxgDoZ6bYF8FCo0o0c/c8u8/cd4xCDFECcCN1QwJN+kW dG+abQ037sUCzllOUCWwBNKlKZ0YIm1+2o4qAlLFy9hIxwsPJUsGVP9RxzFGPiqF RQUALUN7ll4/jBcD87xQtxuuQMy9cYcIdhPdG1aKAu2I0wciQTP4L4pOvOOe+ts0 63ed1/n18TRa0j9ir7lS6xxdoiJrQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddutddguddugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuffhomhgrihhnpehpvghophhlvgdrohhrghenucfkphephedtrdduleejrdek tddrvdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrg hklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from ranger.suse (50-197-80-2-static.hfc.comcastbusiness.net [50.197.80.2]) by mail.messagingengine.com (Postfix) with ESMTPA id 8CC12103D8; Tue, 21 May 2019 13:25:45 -0400 (EDT) Subject: Re: Bulk inserts into two (related) tables To: Rich Shepard , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <823a98a6-1695-ed79-b460-0dd8a6257b0a@aklaver.com> Date: Tue, 21 May 2019 10:25:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 5/21/19 10:22 AM, Rich Shepard wrote: > On Tue, 21 May 2019, Adrian Klaver wrote: > >> Well you are not going to know the org_id until the organization table >> is loaded, which means something like: >> >> 1) First run through file load the organizations table. >> >> 2) Build a mapping of org_id to organization. >> >> 3) Run through data file again and load people data using the mapping >> in 2) to provide the people.org_id. > > Adrian, > > That's what I planned to do. I wondered if there was a more direct way > known > to those with more experience than I have. The short answer is 'no.' The other way is to create the org_id for each organization ahead of time and put it into the data file. Either way you have create the org_id for the FK relationship, it is just a matter of where and when. > > Thanks, > > Rich > > -- Adrian Klaver adrian.klaver@aklaver.com