CREATE TABLE tcg.public.TCG_Statistic (
	  statistic_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
    , entity_type_code TEXT NOT NULL
    , entity_record_id TEXT NOT NULL
    , name TEXT NOT NULL
    , value_bool BOOLEAN
    , value_float DOUBLE PRECISION
    , value_interval INTERVAL
    , value_text TEXT
    , value_timestamp TIMESTAMP
    , is_bool BOOLEAN
    , is_float BOOLEAN
    , is_interval BOOLEAN
    , is_text BOOLEAN
    , is_timestamp BOOLEAN
    , 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_Statistic_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_Statistic_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_Statistic_change_set_id
		FOREIGN KEY (change_set_id)
        REFERENCES tcg.public.TCG_Change_Set(change_set_id)
);
