X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 4F9B69DC99B for ; Thu, 9 Feb 2006 12:23:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71456-07 for ; Thu, 9 Feb 2006 12:23:07 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 439DF9DC98D for ; Thu, 9 Feb 2006 12:23:06 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 78E8F3093C; Thu, 9 Feb 2006 17:23:05 +0100 (MET) From: "BigSmoke" X-Newsgroups: pgsql.sql Subject: Re: unique constraint instead of primary key? what disadvantage(ODBC usage)? Date: 9 Feb 2006 08:22:59 -0800 Organization: http://groups.google.com Lines: 17 Message-ID: <1139502179.764894.35960@o13g2000cwo.googlegroups.com> References: <20060208210455.5d6f5bf9.gry@ll.mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Complaints-To: groups-abuse@google.com In-Reply-To: <20060208210455.5d6f5bf9.gry@ll.mit.edu> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: o13g2000cwo.googlegroups.com; posting-host=212.204.130.113; posting-account=0WN9Mw0AAAChM4mno36wWr-RrABvnbDI To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200602/102 X-Sequence-Number: 24112 If my tables have one or more UNIQUE constraints/indices, I still add a "id SERIAL PRIMARY KEY" field to most of my tables. This makes referencing easier and faster. It also improves consistency, which is never a bad thing in my opinion. As far as I know, though, PRIMARY KEY does the same thing as UNIQUE NOT NULL in PostgreSQL. The reason that PRIMARY KEY can't be NULL and _has to be_ UNIQUE is that it is the primary means of identifying a given record in a table. If you don't have PRIMARY KEY that is UNIQUE and NOT NULL, how are you going to identify (or reference) individual records? PostgreSQL won't allow you to reference more than one row for what I came to believe are very good reasons. - Rowan