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 1s2Wcq-003kN1-Rd for pgsql-sql@arkaria.postgresql.org; Thu, 02 May 2024 13:37:28 +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 1s2Wco-000cZb-A4 for pgsql-sql@arkaria.postgresql.org; Thu, 02 May 2024 13:37:27 +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 1s2Wco-000cYw-1E for pgsql-sql@lists.postgresql.org; Thu, 02 May 2024 13:37:26 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s2Wcj-0015Zn-87 for pgsql-sql@postgresql.org; Thu, 02 May 2024 13:37:25 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ecd3867556so9310075ad.0 for ; Thu, 02 May 2024 06:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714657040; x=1715261840; darn=postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=doQ9wVrXNM9w0ryRg9GjvfCBkQTOfgLBxGlgIirM9/8=; b=d0kMMJunxKV1Ok6BEl99RuNBW/7s9cohMGA2Up3sttyxVzkv99L5EqsTMOkcxYpCQ+ xM5GHd7H74e+hOjfDl8Quwa89MuZ0oVkDrREm7JpDpGs3DfKIvaG9Pd6PvMXflkFtIoV oxpPe5p7Hq9BzjLbaiivmSA2n5NtAiAw3OSg74+hdPGMBOCM3eQJ2bELAIySvOerjCs9 pBgJKmT0oRMJLtOstFXDrbr3mhWMMcsXT5BmvDL0vtLWalTyZ8zO36MKgDqRSGKrcGTA tb0n1n7GMpFxRGkptwBCjCyG//HGaKOxyMA1cElEyGxo/7W7BE2tUjrSXt3EPkotHZRT CpwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714657040; x=1715261840; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=doQ9wVrXNM9w0ryRg9GjvfCBkQTOfgLBxGlgIirM9/8=; b=GhkcIdIqCW4TPJbLJs2uY8uTcMx3aBUJnWwJSz0mJct68XnwD4Q9noblnbInexoZMK M95nqgtAk+ShRgQQhkZsrgv48kgeERAKqwRMkDe2dJfCwTMdlj5qygalRANKoIziksVp FtfmbC4wSd0bJdViAabWou1nvwAJqouY/q8eRNHfm28LUdOn0qr0YbsCedy9KBhnpwUv liPxgJIfXkvmQ8tufmXigPVRiM73grDocmoWbgIy8RRVeMrrLSR417oMgh1kXZnZkJvw Mk4woOHMgFi1xmW/wjQP9vnzPkrvr8WNUA2+xIzmAAzZoSwIUlIClorxzEDGRLsbDe2X I2jw== X-Forwarded-Encrypted: i=1; AJvYcCUmFnGrmkysfYknK23zqrxlpZ2LcIA9XqrtOUxlPmUeYqB5uka6IHnAvuj5kTRvPuwceGAtPHxFrHdouhTrptXl6i2bgLe4LZI= X-Gm-Message-State: AOJu0YzcCM4uvjBrPAhoFN/zh5SuJdPtV7ruCVPMon61KZyvNVCytFgJ oJKim3Cl7tEl8Ocws/Fz8Og7pEgf/PaEnjvJkdjQWwgtCXUq4rCU X-Google-Smtp-Source: AGHT+IH2hn7ZU2bhpqKOq2G6dhRs3weCuTkSsRKdiB1nu3iYpGhms1ygItH/Z0jTlqngmOqWvHyQrw== X-Received: by 2002:a17:902:f643:b0:1ea:ca03:5d8e with SMTP id m3-20020a170902f64300b001eaca035d8emr7208355plg.44.1714657040190; Thu, 02 May 2024 06:37:20 -0700 (PDT) Received: from smtpclient.apple (c-76-140-27-218.hsd1.ut.comcast.net. [76.140.27.218]) by smtp.gmail.com with ESMTPSA id kf5-20020a17090305c500b001ea2838fa5dsm1267623plb.76.2024.05.02.06.37.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2024 06:37:19 -0700 (PDT) From: Rob Sargent Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_48B61037-B5F1-47A3-9DE2-F6BC9844C35D" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Subject: Re: One parent record with 3 possible child records Date: Thu, 2 May 2024 07:37:14 -0600 In-Reply-To: Cc: JORGE MALDONADO To: "David G. Johnston" , "pgsql-sql@postgresql.org" References: X-Mailer: Apple Mail (2.3654.120.0.1.15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_48B61037-B5F1-47A3-9DE2-F6BC9844C35D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On May 1, 2024, at 5:24 PM, David G. Johnston = wrote: >=20 > On Wednesday, May 1, 2024, JORGE MALDONADO > wrote: >=20 > Let's say that tableMain has a string field called "type" with the = following possible values: "residential", "industrial" and "energy".=20 >=20 > This, and have the same column in the other tables, but add a check = constraint ensuring only the correct enum value can be specified. Then = your foreign key from the child tables to main is both the ID and the = type field. > =20 > David J. Presuming the id is unique in parent and child, what=E2=80=99s the value = of the type field in the foreign key? Are you saying the PK on = tableMain is (type,id), perhaps for clustering purposes? --Apple-Mail=_48B61037-B5F1-47A3-9DE2-F6BC9844C35D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On May 1, 2024, at 5:24 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:

On Wednesday, May 1, = 2024, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:

Let's say that tableMain has a string = field called "type" with the following possible values: "residential", = "industrial" and = "energy". 

This, and have the same column in the = other tables, but add a check constraint ensuring only the correct enum = value can be specified.  Then your foreign key from the child = tables to main is both the ID and the type field.
 
David J.
Presuming the id is unique in parent and child, = what=E2=80=99s the value of the type field in the foreign key?  Are = you saying the PK on tableMain is (type,id), perhaps for clustering = purposes?

= --Apple-Mail=_48B61037-B5F1-47A3-9DE2-F6BC9844C35D--