Re: surrogate key or not?

From: Kenneth Gonsalves <lawgon(at)thenilgiris(dot)com>
To: Michael Glaesemann <grzm(at)myrealbox(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 10:02:53
Message-ID: 0407231532531I.01150@thenilgiris.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Friday 23 July 2004 04:47 pm, Michael Glaesemann 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.

ok, i'll rephrase the whole thing:

i have a master table with two fields:
id serial unique
name varchar not null (and will be unique)

i always make 'name' the primary key, and since it is the primary key, i dont
explicitly specify it as unique, and after postgres 7.3 came out, i have
added the 'unique' constraint to the 'id'

on looking at the gnumed schema, i saw that although 'name' was unique, the
serial key, 'id' was made the primary key. So i wondered why and whether
there were advantages in doing it this way.
--
regards
kg

http://www.onlineindianhotels.net - hotel bookings reservations in over 4600
hotels in India
http://www.ootygolfclub.org

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Glaesemann 2004-07-23 11:17:37 Re: surrogate key or not?
Previous Message Michael Glaesemann 2004-07-23 09:59:33 Re: surrogate key or not?