Re: use COPY TO on normalized database

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: Acm <alextabone(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: use COPY TO on normalized database
Date: 2007-09-15 22:25:44
Message-ID: 46EC5BE8.5050601@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Acm wrote:
> I am working with PostgreSQL 8.2.4.
>
> I need to use the SQL COPY (COPY table FROM file) statement to
> populate my database.
>
> I have created a normalized data model (up to 3NF). Is it possible to
> use COPY TO on a particular table (that is linked to other tables
> using foreign keys) whilst keeping the foreign keys and other tables
> updated?
>
> (Also, will de-normalizing the model to 2NF or 1NF help?)
>
> Thank you.
>
>
Use copy...from to load your data into a temp table. Then, do your data
manipulation in the database using insert into .... or other statements
to get data into the "real" 3NF tables. If you do all of this within a
transaction, if anything breaks, you can rollback and have no problems
with data integrity.

Sean

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sean Davis 2007-09-15 22:31:00 Re: GRANT on group does not give access to group members
Previous Message Marinos Yannikos 2007-09-15 21:45:41 read-only queries on PITRslaves, any progress?