question : the choice of the primary key.

From: "Loeke" <LoekeDoeLoekeDoe(at)dontlikespam(dot)hotmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: question : the choice of the primary key.
Date: 2004-01-06 23:38:08
Message-ID: 1073432278.456150@seven.kulnet.kuleuven.ac.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

U have for example something like this

create table persons(
(id..),
surename ..,
familyname ..,
street ..,
..,
birthdate,..
)

a table containing the data of persons, each persons should of course be
present only once;
and one should still define a primary key,
there are two options now,
1.many people make an extra id field and choose this id field to be the
p-key,
but then the same person can be present twice in the table (with different
id fields), the id in itself has no real meaning
2.or u can choose the "natural" key for each person, lets say a name and the
birthdate of a person make that person unique, so lets make (the whole name
en the birthdate) the primary-key; but then if another table X wants to
refer this table of persons using a foreign key, this foreign key exists out
of 3 fields, which smells redundant

u have often this choice in determining the primary keys,

plz give me your opinions, options i overlooked or usefull comments.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Kumar 2004-01-07 06:06:16 Re: Calendar Scripts - Quite a complex one
Previous Message boyd 2004-01-06 23:36:41 Re: unix time -> timestamp