Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B8F6E2E0045 for ; Thu, 22 Nov 2007 09:49:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 95957-01 for ; Thu, 22 Nov 2007 09:48:57 -0400 (AST) Received: from smaug.vex.net (smaug.vex.net [208.76.104.132]) by postgresql.org (Postfix) with ESMTP id 9D9D42E003D for ; Thu, 22 Nov 2007 09:48:57 -0400 (AST) Received: from dilbert (dilbert.druid.net [207.35.13.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smaug.vex.net (Postfix) with ESMTP id 67F7417D5E; Thu, 22 Nov 2007 08:48:55 -0500 (EST) Date: Thu, 22 Nov 2007 08:48:54 -0500 From: "D'Arcy J.M. Cain" To: "Bart Degryse" Cc: Subject: Re: How to have a unique primary key on two tables Message-Id: <20071122084854.9a865ef0.darcy@druid.net> In-Reply-To: <474571E8.A3DD.0030.0@indicator.be> References: <99d8c2310711220301p57c9b7c5i4620a7e658d13b7d@mail.gmail.com> <474571E8.A3DD.0030.0@indicator.be> X-Mailer: Sylpheed 2.4.5 (GTK+ 2.12.0; i386--netbsdelf) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/115 X-Sequence-Number: 29643 On Thu, 22 Nov 2007 12:11:20 +0100 "Bart Degryse" 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 | 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.