Re: Need help with `unique parents` constraint - Mailing list pgsql-sql

From Greg Sabino Mullane
Subject Re: Need help with `unique parents` constraint
Date
Msg-id 5dcda8f8f56611d5d4abfc26c79b5276@biglumber.com
Whole thread Raw
In response to Re: Need help with 'unique parents' constraint  ("Leif B. Kristensen" <leif@solumslekt.org>)
List pgsql-sql
-----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-----




pgsql-sql by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: refer a column as a varible name?
Next
From: "Wei"
Date:
Subject: How do I convert an integet to a timestamp?