Re: surrogate key or not? - Mailing list pgsql-sql

From Michael Glaesemann
Subject Re: surrogate key or not?
Date
Msg-id FF7F62AC-DC8E-11D8-AA48-000A95C88220@myrealbox.com
Whole thread Raw
In response to Re: surrogate key or not?  (Kenneth Gonsalves <lawgon@thenilgiris.com>)
Responses Re: surrogate key or not?  (Kenneth Gonsalves <lawgon@thenilgiris.com>)
Re: surrogate key or not?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
On Jul 23, 2004, at 4:57 PM, Kenneth Gonsalves wrote:

> On Friday 23 July 2004 12:27 pm, Karsten Hilbert wrote:
>
>> BTW, our full schema is here:
>>
>> http://www.hherb.com/gnumed/schema/
>
> i was looking at your schema. i'm not a database pro, but in master 
> tables i
> see you have made the serial id as the primary key. i do it this way:
>
> id    serial unique
> name    varchar(25) not null
> primary key is name - after all, you are going to search this on name 
> arent
> you? or is there some advantage in doing it your way?

Kenneth,

You appear to be misunderstanding the purpose of a primary key. A 
primary key is used to ensure there is a way to identify each row 
uniquely. It is quite independent of which columns you may or may not 
want to search on. If name is not going to be necessarily unique in the 
table, it isn't a primary key.

Michael Glaesemann
grzm myrealbox com



pgsql-sql by date:

Previous
From: Kenneth Gonsalves
Date:
Subject: Re: surrogate key or not?
Next
From: Kenneth Gonsalves
Date:
Subject: Re: surrogate key or not?