X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=ccbs.sql;h=3b3c4e73e1c3360a85fe1690761bc2c50422e27c;hp=0805631093381504ac00be70f829f1ea07916b7c;hb=974ede0dbdba3bfc93204798ef2a6641a46b8a88;hpb=8afe8aaa42f52e2a86cb08fb8bb2ee379156855f diff --git a/ccbs.sql b/ccbs.sql index 0805631..3b3c4e7 100644 --- a/ccbs.sql +++ b/ccbs.sql @@ -32,18 +32,56 @@ CREATE TABLE tournament ( CREATE TABLE rounds ( tournament INTEGER NOT NULL REFERENCES tournaments, - level INTEGER NOT NULL, - parallel INTEGER NOT NULL + round INTEGER NOT NULL, + randomsongs INTEGER NOT NULL, + chosensongs INTEGER NOT NULL, - PRIMARY KEY (tournament, level, parallel) + PRIMARY KEY (tournament, round) +); + +CREATE TABLE groups ( + tournament INTEGER NOT NULL REFERENCES tournaments, + round INTEGER NOT NULL, + parallel INTEGER NOT NULL, + + FOREIGN KEY (tournament, round) REFERENCES rounds (tournament, round), + PRIMARY KEY (tournament, round, parallel) +); + +CREATE TABLE roundrandomsongs ( + tournament INTEGER NOT NULL, + round INTEGER NOT NULL, + parallel INTEGER NOT NULL, + song INTEGER NOT NULL REFERENCES songs, + + FOREIGN KEY (tournament, round, parallel) REFERENCES groups (tournament, round, parallel), + PRIMARY KEY (tournament, round, parallel, song) ); CREATE TABLE roundparticipation ( tournament INTEGER NOT NULL, - level INTEGER NOT NULL, + round INTEGER NOT NULL, parallel INTEGER NOT NULL, player INTEGER NOT NULL REFERENCES players, - FOREIGN KEY ( tournament, level, parallel ) REFERENCES rounds ( tournament, level, parallel ), - PRIMARY KEY ( tournament, level, parallel, player ) + UNIQUE (tournament, round, player), + FOREIGN KEY (tournament, round, parallel) REFERENCES groups (tournament, round, parallel), + PRIMARY KEY (tournament, round, parallel, player) ); + +CREATE TABLE scores ( + tournament INTEGER NOT NULL, + round INTEGER NOT NULL, + parallel INTEGER NOT NULL, + player INTEGER NOT NULL REFERENCES players, + + song INTEGER NOT NULL REFERENCES songs, + playmode VARCHAR NOT NULL CHECK playmode IN ('single','double'), + difficulty VARCHAR NOT NULL CHECK difficulty IN ('beginner','standard','difficult','expert','challenge'), + + score INTEGER NOT NULL CHECK (score >= 0 AND score <= 10000), + + FOREIGN KEY (song, playmode, difficulty) REFERENCES songs (song, playmode, difficulty), + FOREIGN KEY (tournament, round, parallel) REFERENCES groups (tournament, round, parallel), + PRIMARY KEY (tournament, round, parallel, player, songs) +);