-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtournament.sql
More file actions
25 lines (24 loc) · 762 Bytes
/
Copy pathtournament.sql
File metadata and controls
25 lines (24 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- Table definitions for the tournament project.
--
-- Put your SQL 'create table' statements in this file; also 'create view'
-- statements if you choose to use it.
--
-- You can write comments in this file by starting them with two dashes, like
-- these lines here.
DROP DATABASE IF EXISTS tournament;
CREATE DATABASE tournament;
\c tournament
CREATE TABLE players (
playerID serial PRIMARY KEY,
playerName text,
wins int DEFAULT 0,
loss int DEFAULT 0,
matchesPlayed int DEFAULT 0
);
CREATE TABLE matches (
matchID serial PRIMARY KEY,
winner int,
loser int,
FOREIGN KEY (winner) REFERENCES players (playerID),
FOREIGN KEY (loser) REFERENCES players (playerID)
);