]> git.sesse.net Git - ccbs/blobdiff - sql/ccbs.sql
Added a machinesongs table, and a small snippet to insert all songs as EM2 machine...
[ccbs] / sql / ccbs.sql
index 374af67217eac9e62c9f1e9142320d6a52b07977..19eeb0e98ae55e5d70a941f8327fd0a2409e6640 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,
@@ -143,9 +148,7 @@ CREATE TABLE scores (
        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)
 );