X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=sql%2Fccbs.sql;h=e8045a0046ee21b8f52219c73f2bac3f061c8898;hb=95cf63732aee7601870ff706a20ac3f3f77c7114;hp=b8660671f1a89548a8788da21a267f0bb8599f2e;hpb=e6217cf647a58ad25f62dd37f7dc58c6a617807e;p=ccbs diff --git a/sql/ccbs.sql b/sql/ccbs.sql index b866067..e8045a0 100644 --- a/sql/ccbs.sql +++ b/sql/ccbs.sql @@ -53,7 +53,7 @@ CREATE TABLE seasons ( season SERIAL PRIMARY KEY, name VARCHAR NOT NULL, - UNIQUE ( season ) + UNIQUE ( name ) ); CREATE TABLE tournaments ( @@ -102,8 +102,10 @@ CREATE TABLE roundparticipation ( round INTEGER NOT NULL, parallel INTEGER NOT NULL, player INTEGER NOT NULL REFERENCES players, + position INTEGER NOT NULL, UNIQUE (tournament, round, player), + UNIQUE (tournament, round, parallel, position), FOREIGN KEY (tournament, round, parallel) REFERENCES groups (tournament, round, parallel), PRIMARY KEY (tournament, round, parallel, player) ); @@ -113,6 +115,7 @@ CREATE TABLE scores ( round INTEGER NOT NULL, parallel INTEGER NOT NULL, player INTEGER NOT NULL REFERENCES players, + songnumber INTEGER NOT NULL, song INTEGER NOT NULL REFERENCES songs, playmode VARCHAR CHECK (playmode IS NULL OR playmode IN ('single','double')), @@ -124,5 +127,6 @@ CREATE TABLE scores ( 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) );