X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=ccbs.sql;h=95ed22ee51b02c1e5b888ceeafbb3af43775c13d;hp=3b3c4e73e1c3360a85fe1690761bc2c50422e27c;hb=6e071023ea8f9715cb58602675ef305994f298c8;hpb=974ede0dbdba3bfc93204798ef2a6641a46b8a88 diff --git a/ccbs.sql b/ccbs.sql index 3b3c4e7..95ed22e 100644 --- a/ccbs.sql +++ b/ccbs.sql @@ -1,3 +1,4 @@ +-- vim:set tw=0: CREATE TABLE songs ( song SERIAL PRIMARY KEY, @@ -7,9 +8,9 @@ CREATE TABLE songs ( CREATE TABLE songratings ( 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'), - feetrating INTEGER NOT NULL CHECK (feetrating >= 0 AND feetrating <= 10) + playmode VARCHAR NOT NULL CHECK (playmode IN ('single','double')), + difficulty VARCHAR NOT NULL CHECK (difficulty IN ('beginner','standard','difficult','expert','challenge')), + feetrating INTEGER NOT NULL CHECK (feetrating >= 0 AND feetrating <= 10), PRIMARY KEY (song, playmode, difficulty) ); @@ -76,12 +77,14 @@ CREATE TABLE scores ( 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'), + 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), + FOREIGN KEY (song) REFERENCES songs (song), 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) -); + FOREIGN KEY (tournament, round, parallel, player) REFERENCES roundparticipation (tournament, round, parallel, player), + PRIMARY KEY (tournament, round, parallel, player, song) +);