are primary keys always 'needed' - Mailing list pgsql-novice

From Serge Fonville
Subject are primary keys always 'needed'
Date
Msg-id 680cbe0e1002280838h17eee864w9f2ceb1b632e65bf@mail.gmail.com
Whole thread Raw
Responses Re: are primary keys always 'needed'
Re: are primary keys always 'needed'
Re: are primary keys always 'needed'
List pgsql-novice
Hi,

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.
Mainly:
- 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

Regards,

Serge Fonville

--
http://www.sergefonville.nl

Convince Google!!
They need to support Adsense over SSL
https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=10528
http://www.google.com/support/forum/p/AdSense/thread?tid=1884bc9310d9f923&hl=en

pgsql-novice by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Browsing through the Postgres source
Next
From: Tom Lane
Date:
Subject: Re: are primary keys always 'needed'