Re: Bulk inserts into two (related) tables

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Bulk inserts into two (related) tables
Date: 2019-05-22 18:58:52
Message-ID: alpine.LNX.2.20.1905221154441.1484@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-05-22 19:09:38 Re: Bulk inserts into two (related) tables
Previous Message Jeremy Finzel 2019-05-22 18:30:29 Re: Bulk inserts into two (related) tables