X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4F62CD1B4C4 for ; Wed, 7 Jan 2004 00:05:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 08556-05 for ; Tue, 6 Jan 2004 20:04:44 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id BD4DCD1B478 for ; Tue, 6 Jan 2004 20:04:39 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i0704dU8085537 for ; Wed, 7 Jan 2004 00:04:39 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i06NcKos069424 for pgsql-sql@postgresql.org; Tue, 6 Jan 2004 23:38:20 GMT From: "Loeke" X-Newsgroups: comp.databases.postgresql.sql Subject: question : the choice of the primary key. Date: Wed, 7 Jan 2004 00:38:08 +0100 Organization: KULeuvenNet Lines: 30 Message-ID: <1073432278.456150@seven.kulnet.kuleuven.ac.be> X-Complaints-To: abuse@belnet.be X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Cache-Post-Path: seven.kulnet.kuleuven.ac.be!unknown@10-4-148-255.kotnet.org X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/) To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=BAYES_30, PRIORITY_NO_NAME, SEMIFORGED_HOTMAIL_RCVD X-Spam-Level: X-Archive-Number: 200401/53 X-Sequence-Number: 16446 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.