
CREATE TABLE tcg.public.TCG_MTG_Game_Round_Player_Damage (
	  damage_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
    , round_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Round_Player_Damage_round_id
        FOREIGN KEY (round_id)
        REFERENCES tcg.public.TCG_MTG_Game_Round(round_id)
    , player_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Round_Player_Damage_player_id
        FOREIGN KEY (player_id)
        REFERENCES tcg.public.TCG_MTG_Game_Player(player_id)
    , received_from_commander_player_id INT
    , CONSTRAINT FK_TCG_MTG_Game_Round_Player_Damage_received_from_commander_player_id
        FOREIGN KEY (received_from_commander_player_id)
        REFERENCES tcg.public.TCG_MTG_Game_Player(player_id)
    , life_gain INT NOT NULL
    , life_loss INT NOT NULL
    , commander_deaths INT NOT NULL
    , is_eliminated BOOLEAN NOT NULL DEFAULT FALSE
    , active BOOLEAN NOT NULL DEFAULT TRUE
	, created_on TIMESTAMP NOT NULL
	, created_by_user_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Game_Round_Player_Damage_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_Round_Player_Damage_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_Round_Player_Damage_change_set_id
		FOREIGN KEY (change_set_id)
        REFERENCES tcg.public.TCG_Change_Set(change_set_id)
);
