]> git.sesse.net Git - ccbs/commitdiff
First shot at writing basic SQL schemas (not finished).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 13 Feb 2005 02:57:16 +0000 (02:57 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 13 Feb 2005 02:57:16 +0000 (02:57 +0000)
03:30-04:00

ccbs.sql [new file with mode: 0644]

diff --git a/ccbs.sql b/ccbs.sql
new file mode 100644 (file)
index 0000000..0805631
--- /dev/null
+++ b/ccbs.sql
@@ -0,0 +1,49 @@
+
+CREATE TABLE songs (
+       song SERIAL PRIMARY KEY,
+       title VARCHAR NOT NULL,
+       artist VARCHAR NOT NULL
+);
+
+CREATE TABLE songratings (
+       song INTEGER NOT NULL REFERENCES songs,
+       playmode VARCHAR NOT NULL CHECK playmode IN ('single','double'),
+       difficulty VARCHAR NOT NULL CHECK difficulty IN ('beginner','standard','difficult','expert','challenge'),
+       feetrating INTEGER NOT NULL CHECK (feetrating >= 0 AND feetrating <= 10)
+
+       PRIMARY KEY (song, playmode, difficulty)
+);
+
+CREATE TABLE players (
+       player SERIAL PRIMARY KEY,
+       nick VARCHAR NOT NULL
+);
+
+CREATE TABLE seasons (
+       season SERIAL PRIMARY KEY,
+       name VARCHAR NOT NULL
+);
+
+CREATE TABLE tournament (
+       tournament SERIAL PRIMARY KEY,
+       season INTEGER NOT NULL REFERENCES seasons,
+       name VARCHAR NOT NULL
+);
+
+CREATE TABLE rounds (
+       tournament INTEGER NOT NULL REFERENCES tournaments,
+       level INTEGER NOT NULL,
+       parallel INTEGER NOT NULL
+
+       PRIMARY KEY (tournament, level, parallel)
+);
+
+CREATE TABLE roundparticipation (
+       tournament INTEGER NOT NULL,
+       level INTEGER NOT NULL,
+       parallel INTEGER NOT NULL,
+       player INTEGER NOT NULL REFERENCES players,
+
+       FOREIGN KEY ( tournament, level, parallel ) REFERENCES rounds ( tournament, level, parallel ),
+       PRIMARY KEY ( tournament, level, parallel, player )
+);