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 1tfKCN-001QSD-FL for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 14:46:47 +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 1tfKCM-003y9R-IC for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 14:46:46 +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 1tfKCM-003y9I-7c for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 14:46:46 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tfKCJ-0038TJ-2j for pgsql-general@postgresql.org; Tue, 04 Feb 2025 14:46:45 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 807A22A14D6 for ; Tue, 4 Feb 2025 06:46:41 -0800 (PST) Date: Tue, 4 Feb 2025 06:46:41 -0800 (PST) From: Rich Shepard To: pgsql-general@postgresql.org Subject: Re: Lookup tables In-Reply-To: <0def87f9-6fa6-49a7-b0bc-f313c066d387@gmail.com> Message-ID: References: <4e7a338-c7d3-e944-20bd-a6e346e175c7@appl-ecosys.com> <0def87f9-6fa6-49a7-b0bc-f313c066d387@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 4 Feb 2025, Rob Sargent wrote: > I would definitely add an Id for each of the looked up values. The code > can use the Id (for the join or lookup) and the string value can safely be > changed (think typo) without ripple effect.  It also prevents other tables > from referencing the lookup witrh bogus values (those not in the lookup > table) > > Unless your lookup tables are huge I would create a new table matching > your current table but with an identity column and load from you original > table. > https://www.postgresql.org/docs/current/ddl-identity-columns.html Thanks, Rob. Each lookup table has only a very few rows, I'll make new tables today. Regards, Rich