]> git.sesse.net Git - ccbs/blobdiff - ccbs.sql
Even more SQL syntax fixes (the schemas import into psql now).
[ccbs] / ccbs.sql
index b4622ced491fc60480ed54c258da6805261dd65a..74fa4394c2f77028a0b940ad765f43f696674a5b 100644 (file)
--- 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)
 );