]> git.sesse.net Git - ccbs/blobdiff - sql/ccbs.sql
Added a "number of people qualifying for each round" attribute to the SQL schema.
[ccbs] / sql / ccbs.sql
index e8045a0046ee21b8f52219c73f2bac3f061c8898..c13c666774d872d199351fe59b01ba43fa468f3d 100644 (file)
@@ -2,16 +2,16 @@
 
 CREATE TABLE machines (
        machine SERIAL PRIMARY KEY,
 
 CREATE TABLE machines (
        machine SERIAL PRIMARY KEY,
-       name VARCHAR NOT NULL,
+       machinename VARCHAR NOT NULL,
 
 
-       UNIQUE ( name )
+       UNIQUE ( machinename )
 );
 
 CREATE TABLE countries (
        country SERIAL PRIMARY KEY,
 );
 
 CREATE TABLE countries (
        country SERIAL PRIMARY KEY,
-       name VARCHAR NOT NULL,
+       countryname VARCHAR NOT NULL,
 
 
-       UNIQUE ( name )
+       UNIQUE ( countryname )
 );
 
 CREATE TABLE songs (
 );
 
 CREATE TABLE songs (
@@ -28,9 +28,9 @@ CREATE TABLE songs (
 
 CREATE TABLE scoringsystems (
        scoringsystem SERIAL PRIMARY KEY,
 
 CREATE TABLE scoringsystems (
        scoringsystem SERIAL PRIMARY KEY,
-       name VARCHAR NOT NULL,
+       scoringsystemname VARCHAR NOT NULL,
        
        
-       UNIQUE ( name )
+       UNIQUE ( scoringsystemname )
 );
 
 CREATE TABLE songratings (
 );
 
 CREATE TABLE songratings (
@@ -51,22 +51,40 @@ CREATE TABLE players (
 
 CREATE TABLE seasons (
        season SERIAL PRIMARY KEY,
 
 CREATE TABLE seasons (
        season SERIAL PRIMARY KEY,
-       name VARCHAR NOT NULL,
+       seasonname VARCHAR NOT NULL,
 
 
-       UNIQUE ( name )
+       UNIQUE ( seasonname )
 );
 
 CREATE TABLE tournaments (
        tournament SERIAL PRIMARY KEY,
        season INTEGER NOT NULL REFERENCES seasons,
 );
 
 CREATE TABLE tournaments (
        tournament SERIAL PRIMARY KEY,
        season INTEGER NOT NULL REFERENCES seasons,
-       name VARCHAR NOT NULL,
+       tournamentname VARCHAR NOT NULL,
        country INTEGER NOT NULL REFERENCES countries,
        location VARCHAR NOT NULL,
        "date" DATE NOT NULL,
        machine INTEGER NOT NULL REFERENCES machines,
        scoringsystem INTEGER NOT NULL REFERENCES scoringsystems,
 
        country INTEGER NOT NULL REFERENCES countries,
        location VARCHAR NOT NULL,
        "date" DATE NOT NULL,
        machine INTEGER NOT NULL REFERENCES machines,
        scoringsystem INTEGER NOT NULL REFERENCES scoringsystems,
 
-       UNIQUE ( season, name )
+       UNIQUE ( season, tournamentname )
+);
+
+CREATE TABLE tournamentparticipation (
+       tournament INTEGER NOT NULL REFERENCES tournaments,
+       player INTEGER NOT NULL REFERENCES players,
+       paid BOOLEAN NOT NULL,
+
+       PRIMARY KEY ( tournament, player )
+);
+
+CREATE TABLE tournamentrankings (
+       tournament INTEGER NOT NULL REFERENCES tournaments,
+       ranking INTEGER NOT NULL,
+       player INTEGER NOT NULL REFERENCES players,
+       points INTEGER,
+
+       UNIQUE (tournament, player),
+       PRIMARY KEY (tournament, ranking)
 );
 
 CREATE TABLE rounds (
 );
 
 CREATE TABLE rounds (
@@ -74,6 +92,7 @@ CREATE TABLE rounds (
        round INTEGER NOT NULL,
        randomsongs INTEGER NOT NULL,
        chosensongs INTEGER NOT NULL,
        round INTEGER NOT NULL,
        randomsongs INTEGER NOT NULL,
        chosensongs INTEGER NOT NULL,
+       numqualifying INTEGER,
 
        PRIMARY KEY (tournament, round)
 );
 
        PRIMARY KEY (tournament, round)
 );