pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D'Arcy J.M. Cain <darcy@druid.net>
To: Bart Degryse <Bart.Degryse@indicator.be>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to have a unique primary key on two tables
Date: Thu, 22 Nov 2007 08:48:54 -0500
Message-ID: <20071122084854.9a865ef0.darcy@druid.net> (raw)
In-Reply-To: <474571E8.A3DD.0030.0@indicator.be>
References: <99d8c2310711220301p57c9b7c5i4620a7e658d13b7d@mail.gmail.com>
	<474571E8.A3DD.0030.0@indicator.be>

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.



view thread (4+ messages)

Message-ID: <20071122084854.9a865ef0.darcy@druid.net>
Permalink:  ../20071122084854.9a865ef0.darcy@druid.net/
Also on:    postgresql.org/message-id/20071122084854.9a865ef0.darcy@druid.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: darcy@druid.net, Bart.Degryse@indicator.be
  Subject: Re: How to have a unique primary key on two tables
  In-Reply-To: <20071122084854.9a865ef0.darcy@druid.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox