| От | Andreas Kretschmer |
|---|---|
| Тема | Re: Two relations from parent table to child table |
| Дата | |
| Msg-id | dd0abaca-fa0c-2a08-b7ef-a84e46146033@a-kretschmer.de обсуждение исходный текст |
| Ответ на | Two relations from parent table to child table (JORGE MALDONADO <jorgemal1960@gmail.com>) |
| Список | pgsql-novice |
Am 22.01.19 um 02:07 schrieb JORGE MALDONADO: > Hi, > > I have a table of games and a catalog of teams where each game is > always played by 2 teams. How should I design these tables? Please > refer to the image below. > > I suppose that option #2 is the correct one but I want to make sure it is. > I have never seen 2 relations from a parent table to a child table. solution 1 is the correct one. you have to use 2 joins to select that, and you have to use 2 aliases for the 2 joins to distinct the team-table. Something like select ... from ... left join teams t1 on game.team1 = t1.id left join teams t2 on game.team2=t2.id ... Andreas -- 2ndQuadrant - The PostgreSQL Support Company. www.2ndQuadrant.com
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера