pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: BigSmoke <bigsmoke@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: unique constraint instead of primary key? what disadvantage(ODBC usage)?
Date: 9 Feb 2006 08:22:59 -0800
Message-ID: <1139502179.764894.35960@o13g2000cwo.googlegroups.com> (raw)
In-Reply-To: <20060208210455.5d6f5bf9.gry@ll.mit.edu>
References: <20060208210455.5d6f5bf9.gry@ll.mit.edu>

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




view thread (9+ messages)  latest in thread

Message-ID: <1139502179.764894.35960@o13g2000cwo.googlegroups.com>
Permalink:  ../1139502179.764894.35960@o13g2000cwo.googlegroups.com/
Also on:    postgresql.org/message-id/1139502179.764894.35960@o13g2000cwo.googlegroups.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bigsmoke@gmail.com
  Subject: Re: unique constraint instead of primary key? what disadvantage(ODBC usage)?
  In-Reply-To: <1139502179.764894.35960@o13g2000cwo.googlegroups.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox