Re: 5 tables with 3 different relation cases

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: 5 tables with 3 different relation cases
Date: 2021-12-14 03:47:16
Message-ID: 66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 12/13/21 7:32 PM, JORGE MALDONADO wrote:
> Hi,
>
> I have 5 tables related among them so that:
>
> * T1 is parent of T2
> * T2 is parent of T3
> * T3 is parent of T4
> * T4 is parent of T5
>
> image.png
>
> However, in some cases one table is missing so that:
>
> * T1 is parent of T3
> * T3 is parent of T4
> * T4 is parent of T5
> image.png
>
> 3 relations in total.
>
> And yet, in some cases an additional table is missing so that:
>
> * T1 is parent of T4,
> * T4 is parent of T5
>
> image.png
> The 5 tables always have the exact same fields but, of course, the
> relations are different among each case.
>
> Is there a way to design the schema so that I always have 5 tables and
> make T2 and T3 "invisible" for cases #1 and #2?
>
> Or should I consider 12 tables: 5 for case #1, 4 for case #2 and 3 for
> case #3.
>
> I will very much appreciate your feedback.
>
> Respectfully,
> Jorge Maldonado
Have you rejected using a single table with exactly the same columns +
parent_id?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Midgley 2021-12-14 04:19:09 Re: 5 tables with 3 different relation cases
Previous Message Brice André 2021-12-14 03:31:19 Re: Memory exhaustion on large query