]> git.sesse.net Git - ccbs/blobdiff - sql/ccbs.sql
Add headings to the score display.
[ccbs] / sql / ccbs.sql
index b49a47e2781bc3f7717f7740630ab91581525e3f..e0b62840e2a78a63994a78038fc91d0b9aec9812 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,22 @@ 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 rounds (
 );
 
 CREATE TABLE rounds (
@@ -115,6 +115,7 @@ CREATE TABLE scores (
        round INTEGER NOT NULL,
        parallel INTEGER NOT NULL,
        player INTEGER NOT NULL REFERENCES players,
        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')),
        
        song INTEGER NOT NULL REFERENCES songs,
        playmode VARCHAR CHECK (playmode IS NULL OR playmode IN ('single','double')),
@@ -126,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),
        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, song)
 );