pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kenneth Gonsalves <lawgon@thenilgiris.com>
To: Michael Glaesemann <grzm@myrealbox.com>
Cc: Karsten Hilbert <Karsten.Hilbert@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: surrogate key or not?
Date: Fri, 23 Jul 2004 15:32:53 +0530
Message-ID: <0407231532531I.01150@thenilgiris.com> (raw)
In-Reply-To: <E7829CAA-DC99-11D8-AA48-000A95C88220@myrealbox.com>
References: <1090325769.3241.27.camel@dicaprio.akademie1.de>
	<0407231430101G.01150@thenilgiris.com>
	<E7829CAA-DC99-11D8-AA48-000A95C88220@myrealbox.com>

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



view thread (44+ messages)  latest in thread

Message-ID: <0407231532531I.01150@thenilgiris.com>
Permalink:  ../0407231532531I.01150@thenilgiris.com/
Also on:    postgresql.org/message-id/0407231532531I.01150@thenilgiris.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lawgon@thenilgiris.com, grzm@myrealbox.com, Karsten.Hilbert@gmx.net
  Subject: Re: surrogate key or not?
  In-Reply-To: <0407231532531I.01150@thenilgiris.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox