X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 17F48D8C9E for ; Mon, 12 Sep 2005 21:38:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62587-07 for ; Tue, 13 Sep 2005 00:38:45 +0000 (GMT) Received: from biglumber.com (biglumber.com [207.228.252.42]) by svr1.postgresql.org (Postfix) with SMTP id 107BDD8C8C for ; Mon, 12 Sep 2005 21:38:46 -0300 (ADT) Received: (qmail 14001 invoked from network); 13 Sep 2005 00:38:49 -0000 Received: from unknown (HELO localhost) (207.228.252.42) by 0 with SMTP; 13 Sep 2005 00:38:49 -0000 From: "Greg Sabino Mullane" To: pgsql-sql@postgresql.org Subject: Re: Need help with `unique parents` constraint X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <200509122002.34864.leif@solumslekt.org> Date: Tue, 13 Sep 2005 00:38:49 -0000 X-Mailer: JoyMail 1.48 Message-ID: <5dcda8f8f56611d5d4abfc26c79b5276@biglumber.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.093 required=5 tests=[AWL=0.093] X-Spam-Level: X-Archive-Number: 200509/134 X-Sequence-Number: 22681 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > Thank you for an excellent answer. I think I will have to study your > code for a while. But is it such a bad idea to have a separate column > for the primary key here? I see that there are two schools on this, > with diametrically opposed views. For my own part, I feel that it at > least doesn't hurt to have a surrogate key. Secondly, a single key > value is easier to reference from another table than a composite key. Not "bad", but perhaps slightly inefficient and redundant. It depends on how your table is actually structured, but if the only way your app will ever refer to that table is in the context of those 2 foreign keys, then it makes sense to go ahead and make them a primary key. If there are other important fields in the table, /and/ if it is referenced from other tables, then I might add another column. But generally, this should be the exception and not the rule. - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200509122031 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iD8DBQFDJh99vJuQZxSWSsgRAiRFAJwKiGVsJhcbxIe0nQ3bnxJUZupucACgnUa/ 57e9UDfVkv/4AMp2wpqEa3c= =20d1 -----END PGP SIGNATURE-----