X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=sql%2Fccbs.sql;h=d7d461fa205aa7eb8a54e97f5b9c912721132932;hp=374af67217eac9e62c9f1e9142320d6a52b07977;hb=9181c99a0c28191b9d6049377b990a0a03e8ba4b;hpb=503f2b80dd3991ae1c49806117294a820be39e89 diff --git a/sql/ccbs.sql b/sql/ccbs.sql index 374af67..d7d461f 100644 --- a/sql/ccbs.sql +++ b/sql/ccbs.sql @@ -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,11 @@ 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) +); + +CREATE TABLE randomsongsused ( + song INTEGER NOT NULL PRIMARY KEY REFERENCES songs );