From: | "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net> |
---|---|
To: | "Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: How to have a unique primary key on two tables |
Date: | 2007-11-22 13:48:54 |
Message-ID: | 20071122084854.9a865ef0.darcy@druid.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, 22 Nov 2007 12:11:20 +0100
"Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be> wrote:
> When you use serial a kind of macro is performed: in fact an integer field is created, a sequence is created with a name based on the table's name and the nextval of that sequence is used as the default value for the field. Now you have to do these steps "manually".
The second part, if you really mean the ID to be like a primary key is
to put a constraint on the tables to assure that an ID in one does not
exist in the other. That may sound like overkill if the situation can
"never" occur but it doesn't hurt to program defensively.
--
D'Arcy J.M. Cain <darcy(at)druid(dot)net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From | Date | Subject | |
---|---|---|---|
Next Message | Louis-David Mitterrand | 2007-11-22 13:54:04 | Re: dynmic column names inside trigger? |
Previous Message | Richard Huxton | 2007-11-22 13:46:03 | Re: [SQL] Bad Schema Design or Useful Trick? |