agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Rob Sargent <robjsargent@gmail.com>
To: pgsql-sql@lists.postgresql.org
Subject: Re: 5 tables with 3 different relation cases
Date: Mon, 13 Dec 2021 20:47:16 -0700
Message-ID: <66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com> (raw)
In-Reply-To: <CAAY=A7-gS0O_+g_dnnB-NhHOpDEys+WoW=meU38dhuDFuopYiA@mail.gmail.com>
References: <CAAY=A7-gS0O_+g_dnnB-NhHOpDEys+WoW=meU38dhuDFuopYiA@mail.gmail.com>
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?
Attachments:
[image/png] image.png (1.8K, ../66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com/3-image.png)
download | view image
[image/png] image.png (1.7K, ../66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com/4-image.png)
download | view image
[image/png] image.png (1.3K, ../66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com/5-image.png)
download | view image
view thread (3+ messages) latest in thread
Message-ID: <66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com>
Permalink: ../66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com/
Also on: postgresql.org/message-id/66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: robjsargent@gmail.com, pgsql-sql@lists.postgresql.org
Subject: Re: 5 tables with 3 different relation cases
In-Reply-To: <66d7f649-fef5-0df2-f485-7a9eb3ee832e@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox