X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=ccbs.sql;h=74fa4394c2f77028a0b940ad765f43f696674a5b;hp=b4622ced491fc60480ed54c258da6805261dd65a;hb=52fe6d6e5996a5d8270dc524a776b45dbf11ce2c;hpb=6cd729c49f65aa293358b3ec14fa13f0f04c7daf diff --git a/ccbs.sql b/ccbs.sql index b4622ce..74fa439 100644 --- a/ccbs.sql +++ b/ccbs.sql @@ -1,3 +1,4 @@ +-- vim:set tw=0: CREATE TABLE songs ( song SERIAL PRIMARY KEY, @@ -24,7 +25,7 @@ CREATE TABLE seasons ( name VARCHAR NOT NULL ); -CREATE TABLE tournament ( +CREATE TABLE tournaments ( tournament SERIAL PRIMARY KEY, season INTEGER NOT NULL REFERENCES seasons, name VARCHAR NOT NULL @@ -76,14 +77,14 @@ CREATE TABLE scores ( player INTEGER NOT NULL REFERENCES players, song INTEGER NOT NULL 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'), + 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 (song, playmode, difficulty) REFERENCES songratings (song, playmode, difficulty), FOREIGN KEY (tournament, round, parallel, player) REFERENCES roundparticipation (tournament, round, parallel, player), PRIMARY KEY (tournament, round, parallel, player, song) );