Typical foreign key creation question - Mailing list pgsql-novice

From Sean Davis
Subject Typical foreign key creation question
Date
Msg-id 65330CBA-E5E1-11D8-8690-000393CFE1C4@mail.nih.gov
Whole thread Raw
List pgsql-novice
I am migrating from mysql to postgresql.  I have many auto_increment
columns, all requiring code during loading to explicitly save the last
insert id of one table to place into another linked table.  I know that
I can probably do this with sequences and directly selecting current
value.  However, I would like to learn to do this more simply in
postgresql using views/triggers.  I have looked for a code example
showing the "canonical" linked table creation idiom in postgresql, but
have not found it.  I have tables that look like:

CREATE TABLE abixref (
                                  xrefid int,
                                 platepos      INT NOT NULL,
                                 gene_id       VARCHAR(30),
                                 value         VARCHAR(75),
                                 dbid          INT NOT NULL
                             );

CREATE TABLE abidb (
                            dbid         INT NOT NULL,
                            db           VARCHAR(30),
                           );

Of course, dbid is the foreign key with abidb referencing the column of
the same name in the other table.

Thanks,
Sean


pgsql-novice by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Performance Bottleneck
Next
From: Oliver Fromme
Date:
Subject: Re: Performance Bottleneck