pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Primary keys and composite unique keys(basic question)
Date: Thu, 8 Apr 2021 13:39:11 +0200
Message-ID: <20210408113911.GA6440@hjp.at> (raw)
In-Reply-To: <9FFB0361-5256-4175-9C51-5D9F6E6969D9@gmail.com>
References: <3fcf7329-378d-6982-89d9-a3f28ada0d47@gmail.com>
	<9FFB0361-5256-4175-9C51-5D9F6E6969D9@gmail.com>

On 2021-04-07 10:35:55 -0600, Rob Sargent wrote:
>     On Apr 7, 2021, at 10:17 AM, Ron <ronljohnsonjr@gmail.com> wrote:
> 
>     On 4/5/21 9:37 PM, Rob Sargent wrote:
> 
>             It's a small thing, but UUIDs are absolutely not memorizable by
>             humans; they have zero semantic value.  Sequential numeric
>             identifiers
>             are generally easier to transpose and the value gives some clues to
>             its age (of course, in security contexts this can be a downside).
> 
> 
>         I take the above as a definite plus.  Spent too much of my life
>         correcting others’ use of “remembered” id’s that just happened to
>         perfectly match the wrong thing.
> 
> 
>     People seem to have stopped appending check digits to identifiers about 20
>     years ago, and I'm not sure why.
> 
> 
> No the problem is “start from one”. User has item/I’d 10875 in hand and types
> in 10785 which of course in a sequence supplied ID steam is perfectly valid and
> wrong.  Really hard to track down. 

What I've often done when writing software for an Oracle RDBMS is to use
a global sequence instead of one sequence per table (Oracle didn't have
a SERIAL type, so you had to use an explicit sequence and write trigger
anyway). That caught wrong joins (an id value used in one table is never
used in another table) as well as most typos (since ids in a single
table were not dense).

With PostgreSQL I've stopped doing this since the SERIAL type makes it
much more convenient to have a separate sequence per table. But of
course that means that almost any table will have a row with id 10785
and one with 10875.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (19+ messages)

Message-ID: <20210408113911.GA6440@hjp.at>
Permalink:  ../20210408113911.GA6440@hjp.at/
Also on:    postgresql.org/message-id/20210408113911.GA6440@hjp.at

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: Primary keys and composite unique keys(basic question)
  In-Reply-To: <20210408113911.GA6440@hjp.at>
  References: <3fcf7329-378d-6982-89d9-a3f28ada0d47@gmail.com> <9FFB0361-5256-4175-9C51-5D9F6E6969D9@gmail.com> <20210408113911.GA6440@hjp.at>

* 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