5 tables with 3 different relation cases

Поиск
Список
Период
Сортировка
От JORGE MALDONADO
Тема 5 tables with 3 different relation cases
Дата
Msg-id CAAY=A7-gS0O_+g_dnnB-NhHOpDEys+WoW=meU38dhuDFuopYiA@mail.gmail.com
обсуждение исходный текст
Ответы Re: 5 tables with 3 different relation cases  (Rob Sargent <robjsargent@gmail.com>)
Список pgsql-sql
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
Вложения

В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Memory exhaustion on large query
Следующее
От: Brice André
Дата:
Сообщение: Re: Memory exhaustion on large query