X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B891BD1B269 for ; Fri, 23 Jul 2004 11:08:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45336-10 for ; Fri, 23 Jul 2004 14:08:17 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B8D69D1B18A for ; Fri, 23 Jul 2004 11:08:07 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6NE7mfP019814; Fri, 23 Jul 2004 10:07:48 -0400 (EDT) To: Michael Glaesemann Cc: Kenneth Gonsalves , Karsten Hilbert , pgsql-sql@postgresql.org Subject: Re: surrogate key or not? In-reply-to: References: <1090325769.3241.27.camel@dicaprio.akademie1.de> <200407221005.59482.josh@agliodbs.com> <20040723085721.C728@hermes.hilbert.loc> <0407231327461F.01150@thenilgiris.com> Comments: In-reply-to Michael Glaesemann message dated "Fri, 23 Jul 2004 18:59:33 +0900" Date: Fri, 23 Jul 2004 10:07:48 -0400 Message-ID: <19813.1090591668@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/201 X-Sequence-Number: 18453 Michael Glaesemann 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 to be necessarily unique in the > table, it isn't a primary key. The other standard reason for using a made-up value as primary key is that it's under your control and you can guarantee it isn't going to change: one record will have the same primary key for its entire life, which vastly simplifies handling of foreign keys and so forth. If you use any real-world datum as primary key you necessarily buy into tracking changes in that real-world value. And handling duplicates. Names are certainly not unique, and they do change (marriage, etc) and people do miskey them and then expect to be able to fix the error later. As Achilleus' nearby story shows, you can have these problems (certainly the misentry part) even with imported data that is allegedly someone else's primary key; part numbers, USA social-security numbers, etc. regards, tom lane