32 lines
759 B
SQL
32 lines
759 B
SQL
-- Schema for Super Sunday
|
|
CREATE TABLE IF NOT EXISTS tournaments (
|
|
id SERIAL PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
location TEXT,
|
|
start_date DATE,
|
|
end_date DATE,
|
|
description TEXT,
|
|
created_at TIMESTAMP DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS participants (
|
|
id SERIAL PRIMARY KEY,
|
|
tournament_id INTEGER REFERENCES tournaments(id) ON DELETE CASCADE,
|
|
name TEXT NOT NULL,
|
|
rating NUMERIC,
|
|
created_at TIMESTAMP DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS matches (
|
|
id SERIAL PRIMARY KEY,
|
|
tournament_id INTEGER REFERENCES tournaments(id) ON DELETE CASCADE,
|
|
court TEXT,
|
|
start_time TIMESTAMP,
|
|
team_a TEXT,
|
|
team_b TEXT,
|
|
score_a INTEGER,
|
|
score_b INTEGER,
|
|
finished BOOLEAN DEFAULT FALSE,
|
|
created_at TIMESTAMP DEFAULT now()
|
|
);
|