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

From Bill Moran
Subject Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?
Date
Msg-id 20160131121700.8ec04a895aa447315cf35eb6@potentialtech.com
Whole thread Raw
In response to Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
On Sun, 31 Jan 2016 18:02:38 +0100
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Harald Fuchs <hari.fuchs@gmail.com> writes:
> > Ben Leslie <benno@benno.id.au> writes:
> >> "Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT NULL"
> >>
> >> I wanted to clarify if that was, technically, true.
>
> > Yes, but see below.
>
> >> "identifying a set of columns as primary key also provides metadata
> >> about the design of the schema, as a primary key implies that other
> >> tables can rely on this set of columns as a unique identifier for
> >> rows."
>
> Yeah.  The extra metadata has several other effects.  Perhaps it would be
> better to reword this sentence to make it clear that PRIMARY KEY is
> equivalent to UNIQUE+NOTNULL in terms of the data constraint that it
> enforces, without implying that there is no other difference.  I'm not
> sure about a short and clear expression of that though ...

How about:

"PRIMARY KEY is merly a combination of UNIQUE and NOT NULL with regard
to data consistency behavior."

"identifying a set of columns as primary key also provides metadata about
the design of the schema, as a primary key implies that other tables can
rely on this set of columns as a unique identifier for rows. This
metadata may be used by external programs, but is also utilized interally
by the server in some cases."

--
Bill Moran


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Is PRIMARY KEY the same as UNIQUE NOT NULL?