X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=sql%2Fccbs.sql;h=45897b336befe8d0435c231854eeb47b00475d9d;hb=81edbdf60931cc5343964a86e95a43a4dfd6d103;hp=b7d342a91551b4bcd9d5185031b39c7906327352;hpb=4ddc2d1937960d5cf4017644a41433eac2f6f391;p=ccbs diff --git a/sql/ccbs.sql b/sql/ccbs.sql index b7d342a..45897b3 100644 --- a/sql/ccbs.sql +++ b/sql/ccbs.sql @@ -69,6 +69,14 @@ CREATE TABLE tournaments ( UNIQUE ( season, tournamentname ) ); +CREATE TABLE tournamentparticipation ( + tournament INTEGER NOT NULL REFERENCES tournaments, + player INTEGER NOT NULL REFERENCES players, + paid BOOLEAN NOT NULL, + + PRIMARY KEY ( tournament, player ) +); + CREATE TABLE tournamentrankings ( tournament INTEGER NOT NULL REFERENCES tournaments, ranking INTEGER NOT NULL, @@ -84,6 +92,7 @@ CREATE TABLE rounds ( round INTEGER NOT NULL, randomsongs INTEGER NOT NULL, chosensongs INTEGER NOT NULL, + numqualifying INTEGER, PRIMARY KEY (tournament, round) ); @@ -127,16 +136,14 @@ CREATE TABLE scores ( player INTEGER NOT NULL REFERENCES players, songnumber INTEGER NOT NULL, - song INTEGER NOT NULL REFERENCES songs, + song INTEGER REFERENCES songs, playmode VARCHAR CHECK (playmode IS NULL OR playmode IN ('single','double')), difficulty VARCHAR CHECK (difficulty IS NULL OR difficulty IN ('beginner','standard','difficult','expert','challenge')), - chosen BOOLEAN NOT NULL, - score INTEGER NOT NULL CHECK (score >= 0 AND score <= 10000), + chosen BOOLEAN, + score INTEGER CHECK (score IS NULL OR (score >= 0 AND score <= 10000)), - FOREIGN KEY (song) REFERENCES songs (song), FOREIGN KEY (song, playmode, difficulty) REFERENCES songratings (song, playmode, difficulty), FOREIGN KEY (tournament, round, parallel, player) REFERENCES roundparticipation (tournament, round, parallel, player), - UNIQUE (tournament, round, parallel, player, songnumber), - PRIMARY KEY (tournament, round, parallel, player, song) + PRIMARY KEY (tournament, round, parallel, player, songnumber) );