Re: Bulk inserts into two (related) tables - Mailing list pgsql-general

From Rich Shepard
Subject Re: Bulk inserts into two (related) tables
Date
Msg-id alpine.LNX.2.20.1905221154441.1484@salmo.appl-ecosys.com
Whole thread Raw
In response to Re: Bulk inserts into two (related) tables  (Jeremy Finzel <finzelj@gmail.com>)
List 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



pgsql-general by date:

Previous
From: Jeremy Finzel
Date:
Subject: Re: Bulk inserts into two (related) tables
Next
From: Adrian Klaver
Date:
Subject: Re: Bulk inserts into two (related) tables