I was wondering if primary keys are always needed.
What I understand;
- The value of a primary key is unique per table
- Primary keys are unique and not null.
I have a couple of tables.
Some have a serial that is used as a foreign key in another table.
Some tables consist of a combination of two foreign keys (that are
unique together) and a field that is uniquely related to that
combination (but is not necessarily unique within the table)
Others have no unique field or combination at all
For the tables that are only used in the foreign part of the
relationship(s), is there an added value for user of a surrogate
primary key, which will never be referenced.
I did a lot of googling and found very varying opinions.
- Always use a primary key, no reason why, it's just 'better'
- Use primary keys when it makes sense.
How do I determine what 'sense' or 'better' mean?
Thanks for all the feedback
They need to support Adsense over SSL
pgsql-novice by date
|Next:||From: Tom Lane||Date: 2010-02-28 17:02:35|
|Subject: Re: are primary keys always 'needed' |
|Previous:||From: Bruce Momjian||Date: 2010-02-28 01:42:02|
|Subject: Re: Browsing through the Postgres source|