Regards, Igor From: pgsql-general-owner@xxxxxxxxxxxxxx [mailto:pgsql-general-owner@xxxxxxxxxxxxxx]
On Behalf Of Alexander Farber Good evening,
This has worked well for me (when a user connects to the game server, I send her all games she is taking part in), but then I have decided to add another table to act as a "logging journal" for player moves: DROP TABLE IF EXISTS words_moves; DROP TYPE IF EXISTS words_action; CREATE TABLE words_moves ( mid SERIAL PRIMARY KEY, action words_action NOT NULL, gid integer NOT NULL REFERENCES words_games ON DELETE CASCADE, uid integer NOT NULL REFERENCES words_users ON DELETE CASCADE, played timestamptz NOT NULL, tiles jsonb, score integer CHECK(score > 0) ); Also, in the former table words_games I wanted to add references to the latest moves performed by players: -- mid1 integer REFERENCES words_moves(mid) ON DELETE CASCADE, -- mid2 integer REFERENCES words_moves(mid) ON DELETE CASCADE, The intention is: whenever a player connects to the server, sent her all active games and status updates on the recent opponent moves.
So my question is if I can somehow "forward declare" the words_moves table? Thank you Alex Alex, I think, you’ve got this reference “backwards”.
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 Am right/wrong? Regards, Igor |