]> git.sesse.net Git - ccbs/blobdiff - sql/ccbs.sql
Add position to roundparticipation (so we can order by it).
[ccbs] / sql / ccbs.sql
index 0bbc0097b8f0212b58017c3bfd6adf42a7e4fdd4..11901b4e201e056b338588645b0d746d9b59451b 100644 (file)
@@ -64,7 +64,9 @@ CREATE TABLE tournaments (
        location VARCHAR NOT NULL,
        "date" DATE NOT NULL,
        machine INTEGER NOT NULL REFERENCES machines,
-       scoringsystem INTEGER NOT NULL REFERENCES scoringsystems
+       scoringsystem INTEGER NOT NULL REFERENCES scoringsystems,
+
+       UNIQUE ( season, name )
 );
 
 CREATE TABLE rounds (
@@ -100,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)
 );