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,
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
);