Re: Is PRIMARY KEY the same as UNIQUE NOT NULL? - Mailing list pgsql-general

From Geoff Winkless
Subject Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?
Date
Msg-id CAEzk6feisMA88yr4wn1JrWW_pQhPvQt_VKLg6ibULjHwp+u7Cg@mail.gmail.com
Whole thread Raw
In response to Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?
List pgsql-general
On 31 January 2016 at 19:53, David G. Johnston
<david.g.johnston@gmail.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


pgsql-general by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: PL/pgSQL debugger
Next
From: Kaushal Shriyan
Date:
Subject: Re: BDR replication on Postgresql 9.5.0