[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] How to have a unique primary key on two tables
From:       "D'Arcy J.M. Cain" <darcy () druid ! net>
Date:       2007-11-22 13:48:54
Message-ID: 20071122084854.9a865ef0.darcy () druid ! net
[Download RAW message or body]

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 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@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.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic