Re: A situation with one parent table and 3 child tables

From: Gareth Evans <donotspam(at)fastmail(dot)fm>
To: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: A situation with one parent table and 3 child tables
Date: 2023-10-02 21:46:00
Message-ID: 0C0B8C3D-D729-4916-B105-0FF998D4D2D4@fastmail.fm
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Jorge,

Several 1:m relationships may be appropriate where the number of corresponding 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 different “types”, a single 1:m might suffice with “type” as an attribute at the many end, and suitable indexes, and filtering at the application level.

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

Kind regards,
Gareth

> On 2 Oct 2023, at 21:59, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> wrote:
>
> 
> Hi,
>
> I have one parent table (table_p) with 3 child tables (table_ch1, table_ch2 and table_ch3). Each record of the parent table can be associated with 1 and only 1 child table records. This means that:
>
> * 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
>
> At first look, this does not make very much sense to me. I thought about considering 3 parent tables, one for each child table. However, the 3 parent tables would have the same exact structure and I would like to know if there is a workaround for this issue.
>
> Thanks in advance.
>
> Jorge Maldonado

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2023-10-03 02:53:54 Re: A situation with one parent table and 3 child tables
Previous Message JORGE MALDONADO 2023-10-02 20:57:32 A situation with one parent table and 3 child tables