2023-05-13 19:39:18 +02:00
|
|
|
DROP TABLE IF EXISTS seeds CASCADE;
|
|
|
|
CREATE TABLE seeds (
|
|
|
|
seed TEXT NOT NULL PRIMARY KEY,
|
|
|
|
num_players SMALLINT NOT NULL,
|
|
|
|
variant_id SMALLINT NOT NULL,
|
2023-05-13 23:22:36 +02:00
|
|
|
deck VARCHAR(62) NOT NULL,
|
2023-07-07 14:20:24 +02:00
|
|
|
starting_player SMALLINT NOT NULL DEFAULT 0,
|
2023-05-13 19:39:18 +02:00
|
|
|
feasible BOOLEAN DEFAULT NULL,
|
|
|
|
max_score_theoretical SMALLINT
|
|
|
|
);
|
|
|
|
CREATE INDEX seeds_variant_idx ON seeds (variant_id);
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS games CASCADE;
|
|
|
|
CREATE TABLE games (
|
2023-07-07 22:30:53 +02:00
|
|
|
id INT PRIMARY KEY,
|
|
|
|
seed TEXT NOT NULL REFERENCES seeds,
|
|
|
|
num_players SMALLINT NOT NULL,
|
|
|
|
score SMALLINT NOT NULL,
|
|
|
|
variant_id SMALLINT NOT NULL,
|
|
|
|
deck_plays BOOLEAN,
|
|
|
|
one_extra_card BOOLEAN,
|
|
|
|
one_less_card BOOLEAN,
|
|
|
|
all_or_nothing BOOLEAN,
|
|
|
|
detrimental_characters BOOLEAN,
|
|
|
|
num_turns SMALLINT,
|
|
|
|
actions TEXT
|
2023-05-13 19:39:18 +02:00
|
|
|
);
|
|
|
|
CREATE INDEX games_seed_score_idx ON games (seed, score);
|
|
|
|
CREATE INDEX games_var_seed_idx ON games (variant_id, seed);
|
2023-07-07 22:30:53 +02:00
|
|
|
CREATE INDEX games_player_idx ON games (num_players);
|
|
|
|
|
|
|
|
|
2023-07-08 09:47:57 +02:00
|
|
|
DROP TABLE IF EXISTS score_upper_bounds;
|
|
|
|
CREATE TABLE score_upper_bounds (
|
2023-07-07 22:30:53 +02:00
|
|
|
seed TEXT NOT NULL REFERENCES seeds ON DELETE CASCADE,
|
|
|
|
score_upper_bound SMALLINT NOT NULL,
|
2023-07-08 09:47:57 +02:00
|
|
|
reason SMALLINT NOT NULL,
|
|
|
|
UNIQUE (seed, reason)
|
2023-07-07 22:30:53 +02:00
|
|
|
);
|
|
|
|
|
2023-07-08 09:47:57 +02:00
|
|
|
DROP TABLE IF EXISTS score_lower_bounds;
|
|
|
|
CREATE TABLE score_lower_bounds (
|
|
|
|
seed TEXT NOT NULL REFERENCES seeds ON DELETE CASCADE,
|
|
|
|
score_lower_bound SMALLINT NOT NULL,
|
|
|
|
game_id INT REFERENCES games ON DELETE CASCADE,
|
|
|
|
actions TEXT,
|
2023-07-07 22:30:53 +02:00
|
|
|
CHECK (num_nonnulls(game_id, actions) = 1)
|
|
|
|
);
|