pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Bulk inserts into two (related) tables
Date: Wed, 22 May 2019 12:09:38 -0700
Message-ID: <a29a695e-acba-37f0-e73e-8d71dd4385de@aklaver.com> (raw)
In-Reply-To: <alpine.LNX.2.20.1905221039260.1484@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1905210945100.6551@salmo.appl-ecosys.com>
	<CA+bJJbyAsgWaxHvMBz3kTxWcekwGPv3yLXbKO4Yixgj5td25KQ@mail.gmail.com>
	<alpine.LNX.2.20.1905211022360.6551@salmo.appl-ecosys.com>
	<CA+bJJbwjTGmnTw55gvjbeNfutPY1Z-PsXoz_f7ycLDGac2SPxA@mail.gmail.com>
	<alpine.LNX.2.20.1905220535340.1484@salmo.appl-ecosys.com>
	<CAMa1XUgOeJ-TGX7DX-RrEzZUhdyLLykC6p+GFm70DeX6x9RavQ@mail.gmail.com>
	<alpine.LNX.2.20.1905220725100.1484@salmo.appl-ecosys.com>
	<CA+bJJbxkuX0=t8zyd2TV6Gf6xL1qXhLXstBm_koq63a7aK=i3w@mail.gmail.com>
	<alpine.LNX.2.20.1905220857540.1484@salmo.appl-ecosys.com>
	<CA+bJJbw5NxSE=hAKmT03RpOqdFuDDSvnzah7GpSxJU7ST8fjOA@mail.gmail.com>
	<alpine.LNX.2.20.1905221039260.1484@salmo.appl-ecosys.com>

On 5/22/19 10:53 AM, Rich Shepard wrote:
> On Wed, 22 May 2019, Francisco Olarte wrote:
> 
>> Also, when I speak of "unique identifier" I'm not speaking of the one if
>> your FINAL tables, I assume you would have at least the *_id field as
>> PKEY, so nothing else needed, but the one in your SOURCE data set (it can
>> be anything, like the row number in the original excel).
> 
> Francisco/Jeremy,
> 
> I'm grateful for you patient help. The 'unique identifier' in the source
> file has been provided (just now) using nl <https://ss64.com/bash/nl.html;.
> The syntax I used is:
> 
> nl -b a -n ln -s , -v 339 source.txt > out.txt
> 
> because the organizations table has 338 as the maximum org_id number.
> 
> I believe this fulfills the need for a known unique ID in the source file,
> and when I parse each row using gawk to create the two files for table 
> input
> I can use it in both the organizations table (as the PK) and the people
> table (as the FK referring to the organizations table). I can let postgres
> assign the unique ID for the new rows in the people table.
> 
> Am I still missing something critical?

A sample of the data you are cleaning up.

I think what people are trying to wrap there head around is how 800 
lines in the file is being split into two subsets: the organization data 
and the people data. In particular how that is being done to preserve 
the relationship between organizations and people? This is before it 
ever gets to the database.


> 
>> MMM, apart from angel dust I do not know what PCP could stand for.
> 
> Primary Care Physician.
> 
> Best regards,
> 
> Rich
> 
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (32+ messages)  latest in thread

Message-ID: <a29a695e-acba-37f0-e73e-8d71dd4385de@aklaver.com>
Permalink:  ../a29a695e-acba-37f0-e73e-8d71dd4385de@aklaver.com/
Also on:    postgresql.org/message-id/a29a695e-acba-37f0-e73e-8d71dd4385de@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, rshepard@appl-ecosys.com
  Subject: Re: Bulk inserts into two (related) tables
  In-Reply-To: <a29a695e-acba-37f0-e73e-8d71dd4385de@aklaver.com>
  References: <alpine.LNX.2.20.1905210945100.6551@salmo.appl-ecosys.com> <CA+bJJbyAsgWaxHvMBz3kTxWcekwGPv3yLXbKO4Yixgj5td25KQ@mail.gmail.com> <alpine.LNX.2.20.1905211022360.6551@salmo.appl-ecosys.com> <CA+bJJbwjTGmnTw55gvjbeNfutPY1Z-PsXoz_f7ycLDGac2SPxA@mail.gmail.com> <alpine.LNX.2.20.1905220535340.1484@salmo.appl-ecosys.com> <CAMa1XUgOeJ-TGX7DX-RrEzZUhdyLLykC6p+GFm70DeX6x9RavQ@mail.gmail.com> <alpine.LNX.2.20.1905220725100.1484@salmo.appl-ecosys.com> <CA+bJJbxkuX0=t8zyd2TV6Gf6xL1qXhLXstBm_koq63a7aK=i3w@mail.gmail.com> <alpine.LNX.2.20.1905220857540.1484@salmo.appl-ecosys.com> <CA+bJJbw5NxSE=hAKmT03RpOqdFuDDSvnzah7GpSxJU7ST8fjOA@mail.gmail.com> <alpine.LNX.2.20.1905221039260.1484@salmo.appl-ecosys.com> <a29a695e-acba-37f0-e73e-8d71dd4385de@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox