Re: Unique or Primary Key?

Поиск
Список
Период
Сортировка
Искать
От
Eric G. Miller
Тема
Re: Unique or Primary Key?
Дата
в 22:09:24
Msg-id
20010502185009.D4206@calico.local
Ответ на
Unique or Primary Key? (pgsql@itsbruce.uklinux.net)
Список
Дерево обсуждения
Unique or Primary Key? pgsql@itsbruce.uklinux.net
Re: Unique or Primary Key? "Eric G. Miller" <egm2@jps.net>
Re: Unique or Primary Key? GH <grasshacker@over-yonder.net>
Re: Unique or Primary Key? Bruce Richardson <pgsql@itsbruce.uklinux.net>
RE: Unique or Primary Key? "Christian Marschalek" <cm@chello.at>
RE: Unique or Primary Key? Joel Burton <jburton@scw.org>
On Thu, May 03, 2001 at 12:58:03AM +0100, pgsql@itsbruce.uklinux.net wrote:
> This table is man-in-the-middle of a many-to-many relationship:
> 
> CREATE TABLE cv_entries (
>         subscriber INTEGER NOT NULL 
>                 REFERENCES subscribers
>                         ON DELETE CASCADE
>                         ON UPDATE CASCADE,
>         entry_type INTEGER NOT NULL
> 	        REFERENCES cv_entry_types
>                         ON DELETE CASCADE
>                         ON UPDATE CASCADE,
>         ordinal INTEGER, 
> 	value1 TEXT, 
> 	value2 TEXT, 
> 	minimum_trust SMALLINT, 
> 	UNIQUE(subscriber, entry_type, ordinal)
> );
> 
> I used a unique index here because I couldn't see any reason for a
> Primary Key - this table will always be searched on either the
> subscriber or entry_type index.
> 
> Was I wrong?  Should this be a Primary Key?

I think it's a distinction without a difference. A primary key is just a
way to identify a unique tuple that's been chosen from a possible
set of candidate keys (often there's only one candidate).  And,
primary keys are enforced with a unique index...

-- 
Eric G. Miller 
В списке pgsql-general по дате отправления
От: Mitch Vincent
Дата:
Сообщение: Re: Multi Procerssor
От: Tom Lane
Дата:
Сообщение: Re: Tuple Max Size on 7.1
FAQ