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 53A3B528BD for ; Tue, 28 Jun 2005 14:47:32 -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 99818-08 for ; Tue, 28 Jun 2005 17:47:23 +0000 (GMT) Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by svr1.postgresql.org (Postfix) with ESMTP id 0EFF65281E for ; Tue, 28 Jun 2005 14:47:22 -0300 (ADT) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 28 Jun 2005 12:47:22 -0500 Subject: Re: Unique primary index? From: Scott Marlowe To: PFC Cc: orange_crush_068@hotmail.com, pgsql-sql@postgresql.org In-Reply-To: References: <1119530632.181638.4330@g49g2000cwa.googlegroups.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1119980842.8208.111.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 28 Jun 2005 12:47:22 -0500 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/342 X-Sequence-Number: 21943 On Tue, 2005-06-28 at 12:01, PFC wrote: > > > > What are the major differences between Unique, primary index & just > > plain index? > > > > When creating tables I nominate one of these, but not sure what the > > difference is? > index is... an index ! > > UNIQUE is an index which won't allow duplicate values (except for NULLS) > > PRIMARY KEY is exactly like UNIQUE NOT NULL, with the bonus that the > database knows this column is the primary key so you can use stuff like > NATURAL JOIN without telling which column you want to use. No. natural join joins on columns with the same name. However, primary keys ARE automatically referred to by fk'd columns. Personally, I think that a natural join should use the primary/fk relationship as well, but I guess that's not what the spec says.