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 1s2JJJ-001wad-RC for pgsql-sql@arkaria.postgresql.org; Wed, 01 May 2024 23:24:25 +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 1s2JJH-00En4L-DM for pgsql-sql@arkaria.postgresql.org; Wed, 01 May 2024 23:24:24 +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 1s2JJH-00En4C-4V for pgsql-sql@lists.postgresql.org; Wed, 01 May 2024 23:24:24 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s2JJB-000zvd-3A for pgsql-sql@postgresql.org; Wed, 01 May 2024 23:24:22 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5aa2551d33dso4811306eaf.0 for ; Wed, 01 May 2024 16:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714605856; x=1715210656; darn=postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lo2nnvwEu9oVJ2+6fBVdZZQnYhiw+zKVOzKWT0ggnJI=; b=Z1Q+qRFbdvqN0yJYoOTGv2gILADeBTJhkHadB/kTrs8WbqScw+LfqJai8lOW/Pw3n0 oCZd2Vc63yDoeeDWS1glF2ltFnXwrWwL+nnIm6TzYvOpM8qxI2IBkK6JPE0vGJcgFIrd DDZ1FHhOi3WT55VFHxj12i0b4usteiQcH3cK1B0AOAAg0K9dl69QNo8pAnq8Eq8Ys/tG AXovFeDfAtfwdQ5P84gc4jQlGEbieeEBoDmX6ZxlN22ZvNMA2lWjH6MH9r04vzwYlYqc mG1JjOIWih5L/SktsI78pk8zZCSl+SBRqCHofm5UYVx5RA5meHB1feKDnNj3pku6nHDE 7LNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714605856; x=1715210656; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lo2nnvwEu9oVJ2+6fBVdZZQnYhiw+zKVOzKWT0ggnJI=; b=TQCv1NX1SS3bm0/bJnfF/MofZA1TXkm8ggQpcFQAcsBksTRgKApJRdFbO0/ZnMHtN9 hzfFiKLdUxEfz5fY3Q/tRY/0jywnzJ8Gt3UG5K4haeSZ4Qcxjcf6cR2djKsgVuWV8F0C x7eCx3FbIXuPtWpD3CzJVdX4H+XQzzHeWWjkCRshDDnoCN1XmqMXP1zX/Zu2kK+at6Sw mFFPJD16fCCA5q5XWUcMeNotfOF5clKH8uNt5ivfFDFV0Xua2T5BVuGWw5B8dNGP8hvl Ow32g3Ml3Kv/EN/zw16hosaAFVFR6rALp2kHK/1nzR4Imo8Niq0+9EpB6YWNiLCO9x1W lBWg== X-Gm-Message-State: AOJu0Yzf2EGj7fpzz0skZOAogOA8rnWJ//pqLrWdLnGHaEQWfO0pN+WL ARIxhj5mszxrZKIWQ0MCxaXKr18Q8ia+ebOEX0fvCUKVCnwRCyM03vv1uVqsMfUxBwlSyUxEpFi aXbBasMd2/YGhBskxZP/jssSQ6EE= X-Google-Smtp-Source: AGHT+IEKXUMvm+hbiqGgc75+vhnn5oJwZ/wkJnP+q83M9TAHOPqXNPfMqZZCZe81z2dQvWEuFKppAfMcUBTry5SyeHQ= X-Received: by 2002:a4a:e5d7:0:b0:5b1:b8a4:f9ea with SMTP id r23-20020a4ae5d7000000b005b1b8a4f9eamr2011044oov.7.1714605856294; Wed, 01 May 2024 16:24:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5f0a:0:b0:52a:9016:8503 with HTTP; Wed, 1 May 2024 16:24:15 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Wed, 1 May 2024 16:24:15 -0700 Message-ID: Subject: Re: One parent record with 3 possible child records To: JORGE MALDONADO Cc: "pgsql-sql@postgresql.org" Content-Type: multipart/alternative; boundary="000000000000fe8e8106176cc8fb" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000fe8e8106176cc8fb Content-Type: text/plain; charset="UTF-8" On Wednesday, May 1, 2024, JORGE MALDONADO 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. --000000000000fe8e8106176cc8fb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wednesday, May 1, 2024, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:

Let's say that tableMain has a string field called "type&qu= ot; with the following possible values: "residential", "indu= strial" and "energy".=C2=A0

This, and have the same column in the other tables,= but add a check constraint ensuring only the correct enum value can be spe= cified.=C2=A0 Then your foreign key from the child tables to main is both t= he ID and the type field.
=C2=A0
David J.
--000000000000fe8e8106176cc8fb--