pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 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 09:07:29 -0700 (PDT)
Message-ID: <alpine.LNX.2.20.1905220857540.1484@salmo.appl-ecosys.com> (raw)
In-Reply-To: <CA+bJJbxkuX0=t8zyd2TV6Gf6xL1qXhLXstBm_koq63a7aK=i3w@mail.gmail.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>

On Wed, 22 May 2019, Francisco Olarte wrote:

> You are not reading what we write to you. Note YOU AND ONLY YOU are the
> one speaking of PK. We are speaking of "unique identifier" ( that would
> be, IIRC, "candidate keys", you can peek any as your PK, or even introduce
> a new synthetic one with a sequence, or a femto second exact timestamp or
> whatever ).

Francisco,

Let me clarify.

The organizations table has org_id (an integer) as PK.

The people table has person_id (an interger) as PK and org_id as the
reference to organization.org_id.

Does this help?

> When you are fluent in SQL you do not try to play with files, you import
> every column of your data into temporary tables, clean them up, and join (
> if needed ) them until you have a select that gives you what you want and
> then insert this. Normally you insert several SELECTS into temporary
> tables ( specially when you only have thousands of records ) so you can do
> the clean up in steps.

Most of my time is spent writing using LaTeX/LyX. Depending on the project's
needs I'll also use SQL, R, GRASS, and other tools. I'm a generalist, like
your PCP, not a specialist. But, I also rely on emacs, grep, sed, and awk
for data munging and am more fluent with these tools than I am with SQL or
Python.

For me, the quickest and simplest appoach is to add the PKs to each table,
and the org_id into the people table, when I separate the cleaned text file
into the columns for each table.

Regards,

Rich





view thread (32+ messages)  latest in thread

Message-ID: <alpine.LNX.2.20.1905220857540.1484@salmo.appl-ecosys.com>
Permalink:  ../alpine.LNX.2.20.1905220857540.1484@salmo.appl-ecosys.com/
Also on:    postgresql.org/message-id/alpine.LNX.2.20.1905220857540.1484@salmo.appl-ecosys.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: rshepard@appl-ecosys.com
  Subject: Re: Bulk inserts into two (related) tables
  In-Reply-To: <alpine.LNX.2.20.1905220857540.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>

* 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