]> git.sesse.net Git - ccbs/blobdiff - sql/ccbs.sql
Add a (dummy) do-edit-scores.pl backend. (Nevermind, it crept into the previous commi...
[ccbs] / sql / ccbs.sql
index c13c666774d872d199351fe59b01ba43fa468f3d..d7d461fa205aa7eb8a54e97f5b9c912721132932 100644 (file)
@@ -24,7 +24,12 @@ CREATE TABLE songs (
        UNIQUE ( title )
 );
 
--- CREATE TABLE machinesongs etc.
+CREATE TABLE machinesongs (
+       song INTEGER NOT NULL REFERENCES songs,
+       machine INTEGER NOT NULL REFERENCES machines,
+
+       PRIMARY KEY ( song, machine )
+);
 
 CREATE TABLE scoringsystems (
        scoringsystem SERIAL PRIMARY KEY,
@@ -136,16 +141,18 @@ 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)
+);
+
+CREATE TABLE randomsongsused (
+       song INTEGER NOT NULL PRIMARY KEY REFERENCES songs
 );