Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tfKbX-001TsN-TZ for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 15:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tfKbX-004WXV-0S for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 15:12:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tfKbW-004WXN-ML for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 15:12:46 +0000 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tfKbU-0038id-1n for pgsql-general@postgresql.org; Tue, 04 Feb 2025 15:12:45 +0000 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2a3939a758dso1768804fac.1 for ; Tue, 04 Feb 2025 07:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738681964; x=1739286764; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=84H1wt9N8ssUEccBGaYWYVty+palMXeYerYL1Qc8Uts=; b=ZsD6EsMos9baR4zaYYzXADqB36rQZW14Qa52suokof+sLUjbjQSYENp8lvcur3y8sF l5HwmCOkJS5IvA6VFGTtTp2heZzZLG2KNsfFNw5gBsIsss8UD6scYV06SMKQwLpQMZyr ccr3PfbPzSBHDng2TJDmZL18/OtMlBWCIG+PWWSRbK9jNAV3ITSAeBlu32N8tojVHQHP w+QMbMwxZXGDk1C3CCZoLVhJGRo7OAR5meMInJGurduA+vbyG1wkazRRVtD3sR3oa0We 9VSAPhPExKdn5yhlVg5ZCuK8N2WHSjR8I+ZD8//sPc5yioABlSYMehqlI6gvtVgucf4j pvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738681964; x=1739286764; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=84H1wt9N8ssUEccBGaYWYVty+palMXeYerYL1Qc8Uts=; b=U8PmKxBTirW+S/fHvbFubZhQ6Ibn/ApGyApZnymQrvwZMrrXfJvVwBeUalH/HqH+fl HOmO6/OnYfpIdIAcBA+eGnVZnuN+1CL0x/S2BoQJqGpoiWr4AlhLsflZY3os8nbhd+K7 j/yJLBM6SQAXV5YXXoD77+TFoBT2syvQ8lj/1ZjPCvaPrUqK/xqdrmjm/ofCKaOmsLPf +/PuqPk6cQq9xVBMnY6dkD8gofxybXtvX87OrSJYFeHXbh/ye3pG99j2HCfpLn1W7vR7 XXKHQdLesM+1wc4nVedMuXhdubW53n4ZRIy/hYZPb+k7zFvYmfbhLu0F+XfYrvMiCASI hOeA== X-Gm-Message-State: AOJu0YwKjsiftbYmI7VqzVsXqBTpRujttF4hm5nN+lbpp1h2D7N3Ii1m /UNvseUgt9bQwW8PQxpun6rM5WtBN1YxkFWdnmyo0XZSV2ax6frcoUi/t817RnXnh0MbEDqFNb6 MjriaxNnT4h8oqRmogibvDHznDvZEng== X-Gm-Gg: ASbGncut73qgt/ZRx2an5OcUL37KY3bKXgtntoqTV9udbSSrvy3dY+k+LvM8DGoqRtC dLfxpUOrnxw7GZ40eOF6uTmWjun9HD/hzdlQq6jSoPNm3cVxfT3iEP9ueOksqTWKjNSDeiTmUog == X-Google-Smtp-Source: AGHT+IFe1qXOvGvznNBTN709uvmLKgV50byjxeDOfKvrVrLr6GOIPLgDyRQrQz7JsAN6SZt/dWssI8P+G2mU6jbDt60= X-Received: by 2002:a05:6871:522a:b0:29d:c870:74 with SMTP id 586e51a60fabf-2b32f2d96ffmr18288061fac.27.1738681964235; Tue, 04 Feb 2025 07:12:44 -0800 (PST) MIME-Version: 1.0 References: <4e7a338-c7d3-e944-20bd-a6e346e175c7@appl-ecosys.com> <50498443-1599-c62f-b3b7-485828c54e22@appl-ecosys.com> In-Reply-To: <50498443-1599-c62f-b3b7-485828c54e22@appl-ecosys.com> From: Ron Johnson Date: Tue, 4 Feb 2025 10:12:33 -0500 X-Gm-Features: AWEUYZkfyz4EsJo-92Y9ViOzNxRytslkxrfmxpq9bs2lT1RnXu_91OfEpMx8R_k Message-ID: Subject: Re: Lookup tables To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000db1414062d5270a8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000db1414062d5270a8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 4, 2025 at 10:05=E2=80=AFAM Rich Shepard wrote: > On Tue, 4 Feb 2025, Ron Johnson wrote: > > > Does your lookup table just have one column? (That's what your questio= n > > seems to imply, but that makes no sense, since the whole point of a > lookup > > table is to store some sort of a code in the "child" table instead of t= he > > whole text of the description.) > > Ron, > > Yes, each has a single column of type names, industrytypes and statustype= s. > I've always used the descriptive names in queries. > Yeah, that's definitely Bad Design, for the reason David enumerated. In the lookup table, the PK can be either synthetic (an integer that means nothing) or natural (a short text code, typically four characters) that is an abbreviation of the description. Synthetic keys have been the norm for the past 25+ years, but I have a soft spot for natural keys. Natural keys become unwieldy, though, when more than two columns are required to define primality. --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000db1414062d5270a8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Feb 4, 2025 at 10:05=E2=80=AFAM R= ich Shepard <rshepard@appl-e= cosys.com> wrote:
On Tue, 4 Feb 2025, R= on Johnson wrote:

> Does your lookup table just have one column?=C2=A0 (That's what yo= ur question
> seems to imply, but that makes no sense, since the whole point of a lo= okup
> table is to store some sort of a code in the "child" table i= nstead of the
> whole text of the description.)

Ron,

Yes, each has a single column of type names, industrytypes and statustypes.=
I've always used the descriptive names in queries.

Yeah, that's definitely Bad Design, fo= r the reason David enumerated.

In the lookup table= , the PK can be either=C2=A0synthetic (an integer that means nothing)=C2=A0= or natural (a short text code, typically four characters) that is an abbrev= iation of the description.

Synthetic=C2=A0keys hav= e been the norm for the past 25+ years, but I have a soft spot for natural = keys.

Natural keys become unwieldy, though, when m= ore than two columns are required to define primality.

= --
Death to <Redacted>, and butter= sauce.
Don't boil me, I'm still alive.
<Redact= ed> lobster!
--000000000000db1414062d5270a8--