
CREATE TABLE tcg.public.TCG_MTG_Game_Player (
	  player_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
    , game_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Player_game_id
        FOREIGN KEY (game_id)
        REFERENCES tcg.public.TCG_MTG_Game(game_id)
    , user_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Player_user_id
        FOREIGN KEY (user_id)
        REFERENCES tcg.public.TCG_User(user_id)
    , deck_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Player_deck_id
        FOREIGN KEY (deck_id)
        REFERENCES tcg.public.TCG_MTG_Deck(deck_id)
    , name TEXT
    , notes TEXT
    , display_order INT NOT NULL
    , active BOOLEAN NOT NULL DEFAULT TRUE
	, created_on TIMESTAMP NOT NULL
	, created_by_user_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Player_created_by_user_id
        FOREIGN KEY (created_by_user_id)
        REFERENCES tcg.public.TCG_User(user_id)
	, updated_last_on TIMESTAMP NOT NULL
	, updated_last_by_user_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Player_updated_last_by_user_id
        FOREIGN KEY (updated_last_by_user_id)
        REFERENCES tcg.public.TCG_User(user_id)
    , change_set_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Player_change_set_id
		FOREIGN KEY (change_set_id)
        REFERENCES tcg.public.TCG_Change_Set(change_set_id)
);
