Re: [SQL] surrogate key or not?

2004-07-23 Thread Josh Berkus
Karsten, > Because there is no information to be had on this fact. The > patient IS afflicted by such or she is not. There is no why. I begin to see why I spent $2000 this spring to have a doctor tell me what I *didn't* have ... > http://www.hherb.com/gnumed/schema/ > > Lot's of it isn't in t

Re: [SQL] surrogate key or not?

2004-07-23 Thread Josh Berkus
Achilleus, > In other words, with surrogate keys, you eliminate the chance > that your original design was flawed due to lack of important > initial knowledge. Well, you don't *eliminate* it, but you do decrease it. I'd say, yes, this is an important 4th reason: 4) Your spec may be incorr

Re: [SQL] surrogate key or not?

2004-07-23 Thread Tom Lane
Michael Glaesemann <[EMAIL PROTECTED]> writes: > 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

Re: [SQL] surrogate key or not?

2004-07-23 Thread Janning Vygen
Am Freitag, 23. Juli 2004 12:02 schrieb Kenneth Gonsalves: > 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 s

Re: [SQL] surrogate key or not?

2004-07-23 Thread Achilleus Mantzios
Regarding natural or surrogate keys... It is often possible that a table definition does not depict reality, meaning that the specification given at table design phase was wrong, (or was later proved wrong). I had a table "parts" like \d parts Table "public.

Re: [SQL] surrogate key or not?

2004-07-23 Thread Kenneth Gonsalves
On Friday 23 July 2004 04:47 pm, Michael Glaesemann wrote: > > id serial unique > > namevarchar(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,

Re: [SQL] surrogate key or not?

2004-07-23 Thread Michael Glaesemann
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

Re: [SQL] surrogate key or not?

2004-07-23 Thread Kenneth Gonsalves
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

Re: [SQL] surrogate key or not?

2004-07-23 Thread Michael Glaesemann
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 primar

Re: [SQL] surrogate key or not?

2004-07-23 Thread Kenneth Gonsalves
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 uniqu

Re: [SQL] surrogate key or not?

2004-07-23 Thread Karsten Hilbert
Josh, sad, > create table diagnosis ( > pk serial primary key, > fk_patient integer > not null > references patient(pk) > on update cascade > on delete cascade, > narrative text > not null, > unique(fk_patient, narrative) > ); > > This was o