Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?
Date: 2016-02-01 11:04:22
Message-ID: CAEzk6feisMA88yr4wn1JrWW_pQhPvQt_VKLg6ibULjHwp+u7Cg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 31 January 2016 at 19:53, David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> A PRIMARY KEY enforces a UNIQUE, NOT NULL constraint and additionally allows
[snip]

I would just remove the whole paragraph. A primary key does what it
does, a unique constraint does what it does. I'm not really sure why
you need to link them.

I would just start with

"A primary key indicates that a column or group of columns can be used
as a unique identifier for rows in the table."

before the examples, then remove the "Technically" and the whole
parenthesised comment about unique keys and nulls, so the next line
after the examples becomes

"Primary keys are useful both for documentation purposes and for
client applications. For example, a GUI application that allows
modifying row values probably needs to know the primary key of a table
to be able to identify rows uniquely."

I just think it's unnecessarily confusing to start suggesting that
there's some equivalency when you then need to clarify that actually
they're not really equivalent.

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kaushal Shriyan 2016-02-01 16:44:00 Re: BDR replication on Postgresql 9.5.0
Previous Message Albe Laurenz 2016-02-01 08:45:14 Re: PL/pgSQL debugger