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 1qnQkC-00AuL2-QF for pgsql-sql@arkaria.postgresql.org; Mon, 02 Oct 2023 21:46:26 +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 1qnQkB-00HP8M-E7 for pgsql-sql@arkaria.postgresql.org; Mon, 02 Oct 2023 21:46:23 +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 1qnQk9-00HP8A-Of for pgsql-sql@lists.postgresql.org; Mon, 02 Oct 2023 21:46:23 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qnQk6-007rMx-Ec for pgsql-sql@postgresql.org; Mon, 02 Oct 2023 21:46:20 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 1263432009A3; Mon, 2 Oct 2023 17:46:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 02 Oct 2023 17:46:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1696283174; x=1696369574; bh=3dPAUzzEVG7B9BwfOLDMR2jWKGKxzjti7jL Q+0ozX4U=; b=IDvLeiggUbp6I8LlIfyFhqk2PCZFyiMAg+gGgMEcivpNdmh1DLX YihBWape08bosYRibGrY12UFOfoD60RVco3jPRac81nBpD9neuKkca2FLlJTkjvn EFMEyO59msG1bydfNdol8flBXzwIdWmpTmu1wVO9XEvWOr+YTeSddEr90VfWQk2O yWiO3XxQSc2SK8wL+VlgDHKczA7DqVNtOOfgZH/6Zu5dzUCyM8aImgXkK1M9fpsF LWj0WveIGU0vAB40sGtDEawtw5nLpE5fCFVUw2R51G/Z41bkg59X5vdmpWXBC/ir QLLcx87sBSjO7Xn0XSql6s8FrMGnZh8KmRA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1696283174; x=1696369574; bh=3dPAUzzEVG7B9BwfOLDMR2jWKGKxzjti7jL Q+0ozX4U=; b=Lf+WlEsA/MK0SGPvT3MxX0wHMSIXt27OKXF2TSoe/xjG2ByLrfo pTQlnv0H7BCNANGiITRj3gdAJAaiXgqkE/dR6vejDpiUitfWwzZTialAClUoXzPp Q6bJBJusj5CVRXAkw+3fXHjcyMc/12iXbIXse4Y21wFSOy/+kQsP4ATaG2JAuUrv sAjr0cNruLH5CSDZdVOKeY8loQJ7rnc245t0SMdqt/aA7iAKQcRJuEZoaEgtFvvP CS2XATNGq7+Pa7LpThO6Wh+DhHyAvRPLsDgjZfdWveIHSRLsYs2H7OGeKTLfF/Of LDkTZ+B9x3e3yFj56C6NU6cGoy3hQfUv/nw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfeduucetufdoteggodetrfdotffvucfrrh hofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh eptgfghfggufffkfhfvegjvffosegrjehmrehhtdejnecuhfhrohhmpefirghrvghthhcu gfhvrghnshcuoeguohhnohhtshhprghmsehfrghsthhmrghilhdrfhhmqeenucggtffrrg htthgvrhhnpeegffdvkefgveeifeejfeevvefhheekkeejtefgfeeljedvgeduleetjeek geeuueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe guohhnohhtshhprghmsehfrghsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: i7f644093:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 2 Oct 2023 17:46:14 -0400 (EDT) Content-Type: multipart/alternative; boundary=Apple-Mail-EE6B509C-D61D-4CAC-AADB-8A8E1FC0B135 Content-Transfer-Encoding: 7bit From: Gareth Evans Mime-Version: 1.0 (1.0) Subject: Re: A situation with one parent table and 3 child tables Date: Mon, 2 Oct 2023 22:46:00 +0100 Message-Id: <0C0B8C3D-D729-4916-B105-0FF998D4D2D4@fastmail.fm> References: Cc: pgsql-sql@postgresql.org In-Reply-To: To: JORGE MALDONADO X-Mailer: iPad Mail (20G75) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-EE6B509C-D61D-4CAC-AADB-8A8E1FC0B135 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Jorge, Several 1:m relationships may be appropriate where the number of correspondi= ng records on the m side can be 0, 1 or more. If the child entities vary little or not at all in structure, but represent d= ifferent =E2=80=9Ctypes=E2=80=9D, a single 1:m might suffice with =E2=80=9Ct= ype=E2=80=9D as an attribute at the many end, and suitable indexes, and filt= ering at the application level. It's difficult to generalise. If you can give more information on the scena= rio, better advice may be forthcoming. Kind regards, Gareth > On 2 Oct 2023, at 21:59, JORGE MALDONADO wrote: >=20 > =EF=BB=BF > Hi, >=20 > I have one parent table (table_p) with 3 child tables (table_ch1, table_ch= 2 and table_ch3). Each record of the parent table can be associated with 1 a= nd only 1 child table records. This means that: >=20 > * Some records of the table_p will link to records of table_ch1 > * Some records of the table_p will link to records of table_ch2 > * Some records of the table_p will link to records of table_ch3 >=20 > At first look, this does not make very much sense to me. I thought about c= onsidering 3 parent tables, one for each child table. However, the 3 parent t= ables would have the same exact structure and I would like to know if there i= s a workaround for this issue. >=20 > Thanks in advance. >=20 > Jorge Maldonado --Apple-Mail-EE6B509C-D61D-4CAC-AADB-8A8E1FC0B135 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi J= orge,

Several 1:m relations= hips may be appropriate where the number of corresponding records on the m s= ide can be 0, 1 or more.

If= the child entities vary little or not at all in structure, but represent di= fferent =E2=80=9Ctypes=E2=80=9D, a single 1:m might suffice with =E2=80=9Cty= pe=E2=80=9D as an attribute at the many end, and suitable indexes, and filte= ring at the application level.

It's difficult to generalise.  If you can give more information on t= he scenario, better advice may be forthcoming.

Kind regards,
Gareth


On 2 Oct 2023, at 21:59, JORGE MALDONADO <jorgemal1960@gmail= .com> wrote:

=EF=BB=BF
Hi,
I have one parent table (table_p) with 3 child tables= (table_ch1, table_ch2 and table_ch3). Each record of t= he parent table can be associated with 1 and only 1 child table records. Thi= s means that:

* Some records of the table_p w= ill link to records of table_ch1
* Some records of the t= able_p will link to records of table_ch2
* Some rec= ords of the table_p will link to records of table_ch3

At first look, this does not make very much sense to me= . I thought about considering 3 parent tables, one for each child table. How= ever, the 3 parent tables would have the same exact structure and I would li= ke to know if there is a workaround for this issue.

Thanks in advance.

Jorge Maldonado
= --Apple-Mail-EE6B509C-D61D-4CAC-AADB-8A8E1FC0B135--