pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas <maps.on@gmx.net>
To: pgsql-sql@postgresql.org
Subject: multi table import from 1 denormalized source table
Date: Tue, 16 Nov 2010 06:57:30 +0100
Message-ID: <4CE21D4A.4070200@gmx.net> (raw)

Hi,

I frequently get tables from spreadsheets to import into the DB.

Usually it looks like this:
A1, A2, A3, A4,   B1, B2, B3,   with optional C1, C2,   D1, D2, ...

and there is a 1:n relation between A and B.
If provieded the C would be 1:1 to A and D 1:1 to B.

Up until now I let a VBA script order the source table by A, then scan 
the table line by line and create a new entry in the target table A* and 
fetch its serial ID everytime the script figures that A changed.
With this IDa create 1 C* and as many B*s until A changes again ... and 
of course fetch IDb to attach the D* records with a foreign key column.

Now I'm trying to get away w/o the VBA stuff.

Is there a clever way to split such denormalized sources while still 
obtaining the needed IDs to connect everything?



view thread (2+ messages)  latest in thread

Message-ID: <4CE21D4A.4070200@gmx.net>
Permalink:  ../4CE21D4A.4070200@gmx.net/
Also on:    postgresql.org/message-id/4CE21D4A.4070200@gmx.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: maps.on@gmx.net
  Subject: Re: multi table import from 1 denormalized source table
  In-Reply-To: <4CE21D4A.4070200@gmx.net>

* 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