Skip site navigation (1) Skip section navigation (2)

Re: surrogate key or not?

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Kenneth Gonsalves <lawgon(at)thenilgiris(dot)com>
Cc: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>,pgsql-sql(at)postgresql(dot)org
Subject: Re: surrogate key or not?
Date: 2004-07-23 11:17:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Jul 23, 2004, at 6:00 PM, Kenneth Gonsalves wrote:

> On Friday 23 July 2004 03:29 pm, Michael Glaesemann wrote:
>> 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.
> ive not misunderstood anything. this is one of the tables in question:
> address_type
> id serial PRIMARY KEY
> name text UNIQUE NOT NULL
> i think it is self explanatory

In the example you originally gave, there is no indication of name 
being a primary key:

On Friday 23 July 2004 12:27 pm, Karsten Hilbert wrote:

> 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?

Also, your explanation "after all, you are going to search..." did not 
mention row uniqueness at all. Sorry if this is not what you meant, but 
I can only go by what you've written.

Michael Glaesemann
grzm myrealbox com

In response to


pgsql-sql by date

Next:From: Achilleus MantziosDate: 2004-07-23 12:25:05
Subject: Re: surrogate key or not?
Previous:From: Kenneth GonsalvesDate: 2004-07-23 10:02:53
Subject: Re: surrogate key or not?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group