Re: Forward declaration of table
От | Alexander Farber |
---|---|
Тема | Re: Forward declaration of table |
Дата | |
Msg-id | CAADeyWiLcBfWHx6r7Jshsxs3C6ewJ3xGiQ8Dd29OxYUVSFSnDg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Forward declaration of table (Igor Neyman <ineyman@perceptron.com>) |
Ответы |
Re: Forward declaration of table
|
Список | pgsql-general |
Hi Igor,
On Tue, Aug 23, 2016 at 8:15 PM, Igor Neyman <ineyman@perceptron.com> wrote:
mailto:pgsql-general-owner@
postgresql.org] On Behalf Of Alexander Farber
Certain MOVE exists only within particular GAME: no GAME -> no MOVE (on delete cascade).
So, you don’t need mid1, mid2 columns in WORD_GAMES table.
What you need is this column in WORD_MOVES table:
gid integer REFERENCES WORD_GAMES ON DELETE CASCADE
you are correct, but I need to send most recent move in each game together with the other game data.
If I don't store the recent moves in mid1, mid2 then I'd have to retrieve them every time dynamically with
If I don't store the recent moves in mid1, mid2 then I'd have to retrieve them every time dynamically with
WITH last_moves AS (SELECT *FROM words_moves wm1WHEREplayed = (SELECT max(played)FROM words_moves wm2WHERE wm1.gid = wm2.gid))SELECT *FROM words_games wgLEFT JOIN last_moves lmON (wg.gid = lm.gid)WHEREplayer1 = 1 ORplayer2 = 1;
Regards
Alex
В списке pgsql-general по дате отправления: