Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUT0Q-0008NQ-Uj for pgsql-general@arkaria.postgresql.org; Thu, 08 Apr 2021 11:39:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUT0P-00005n-Tt for pgsql-general@arkaria.postgresql.org; Thu, 08 Apr 2021 11:39:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUT0P-0008Rg-Lz for pgsql-general@lists.postgresql.org; Thu, 08 Apr 2021 11:39:25 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUT0F-0004Ea-QX for pgsql-general@lists.postgresql.org; Thu, 08 Apr 2021 11:39:23 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 8C81348BF; Thu, 8 Apr 2021 13:39:11 +0200 (CEST) Date: Thu, 8 Apr 2021 13:39:11 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Primary keys and composite unique keys(basic question) Message-ID: <20210408113911.GA6440@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <3fcf7329-378d-6982-89d9-a3f28ada0d47@gmail.com> <9FFB0361-5256-4175-9C51-5D9F6E6969D9@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline In-Reply-To: <9FFB0361-5256-4175-9C51-5D9F6E6969D9@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-04-07 10:35:55 -0600, Rob Sargent wrote: > On Apr 7, 2021, at 10:17 AM, Ron wrote: >=20 > On 4/5/21 9:37 PM, Rob Sargent wrote: >=20 > 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 cl= ues to > its age (of course, in security contexts this can be a downsi= de). >=20 >=20 > I take the above as a definite plus. Spent too much of my life > correcting others=E2=80=99 use of =E2=80=9Cremembered=E2=80=9D id= =E2=80=99s that just happened to > perfectly match the wrong thing. >=20 >=20 > People seem to have stopped appending check digits to identifiers abo= ut 20 > years ago, and I'm not sure why. >=20 >=20 > No the problem is =E2=80=9Cstart from one=E2=80=9D. User has item/I=E2=80= =99d 10875 in hand and types > in 10785 which of course in a sequence supplied ID steam is perfectly val= id and > wrong. Really hard to track down.=20 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --yrj/dFKFPuw6o+aM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmBu61oACgkQ8g5IURL+ KF3wbRAAo44v/qLHl38bkJh25lzwvPKwxx6OmapMSrlAlkTRgcVISEbCQ8ETq9TY btogv4+4EQrjDVE3ssTHygYShX+90z60XCusqDVdxl0v5jmBZunpciUcHWxDs4pm jf6E7JlSL2V6BApypLhd7WIQ9xKi49bDiZP3Q2qMikrXBUVDj9SSPl3kmZzieA0N wcflO2iZeVRJT1PmSlCzBGqbolWGNZpllJzHXQxz/aBPaLtPjKSYyEfSxdOB9MOA SHbLakt5x5SII+CE9EjW+XKMqcYndQC8aeI63eMge7gfhJGbqoxQZS4FS53TiuT/ l9rfDN/Uf657bnbKEB/59V2vzr82H2z6r3AICyBicJgxMMDYAAS/r3+kXt/VMt3N s4mXZUFUOc+I2ntzE0PIGFFZ7Le2ukZ/85h3RAc7OMoPYKb4K2lBwKUrYWZ6BETJ ZtXtMLA7ezQu8SWFwWWGocHsihuKYTfRHMcCpqu2DOMoW8JaUgbqAU+ZyWfydYbd M6UvIYZbw2HZxX32fx1IHCA86fplblUMkrk2ojh89JVWHHHTzFkCRUoujHU4nVjC mwPQ/b9rYK0WztYY55pGYHCRXQnA7pBfXaYxlvfJkiD5IRQ86Tvvwjoc/8Xj9U2X Q3NaX4wcQ03s921QiSqNMhamZ08TYwldApuRBCBS0g516xA6XYQ= =2p/W -----END PGP SIGNATURE----- --yrj/dFKFPuw6o+aM--