Re: How to have a unique primary key on two tables - Mailing list pgsql-sql

From D'Arcy J.M. Cain
Subject Re: How to have a unique primary key on two tables
Date
Msg-id 20071122084854.9a865ef0.darcy@druid.net
Whole thread Raw
In response to Re: How to have a unique primary key on two tables  ("Bart Degryse" <Bart.Degryse@indicator.be>)
List pgsql-sql
On Thu, 22 Nov 2007 12:11:20 +0100
"Bart Degryse" <Bart.Degryse@indicator.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
namebased on the table's name and the nextval of that sequence is used as the default value for the field. Now you have
todo 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@druid.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.


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Bad Schema Design or Useful Trick?
Next
From: Louis-David Mitterrand
Date:
Subject: Re: dynmic column names inside trigger?