are primary keys always 'needed'

Поиск
Список
Период
Сортировка
От Serge Fonville
Тема are primary keys always 'needed'
Дата
Msg-id 680cbe0e1002280838h17eee864w9f2ceb1b632e65bf@mail.gmail.com
обсуждение исходный текст
Ответы Re: are primary keys always 'needed'  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: are primary keys always 'needed'  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: are primary keys always 'needed'  (Michael Glaesemann <grzm@seespotcode.net>)
Список 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 по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Browsing through the Postgres source
Следующее
От: Tom Lane
Дата:
Сообщение: Re: are primary keys always 'needed'