dbTalk Databases Forums  

Typical foreign key creation question

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Typical foreign key creation question in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sean Davis
 
Posts: n/a

Default Typical foreign key creation question - 08-04-2004 , 02:42 AM






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


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.