-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdb.sql
More file actions
33 lines (30 loc) · 953 Bytes
/
db.sql
File metadata and controls
33 lines (30 loc) · 953 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
26
27
28
29
30
31
32
33
DROP DATABASE IF EXISTS assassins;
CREATE DATABASE IF NOT EXISTS assassins;
USE assassins;
CREATE TABLE games (
roomCode VARCHAR(4) NOT NULL UNIQUE,
active TINYINT(1) DEFAULT 0 NOT NULL,
PRIMARY KEY (roomCode)
);
CREATE TABLE players(
username VARCHAR(100) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
longitude VARCHAR(255) DEFAULT '' NOT NULL,
latitude VARCHAR(255) DEFAULT '' NOT NULL,
alive VARCHAR(5) DEFAULT 'false',
target VARCHAR(100) DEFAULT '',
hireable VARCHAR(5) DEFAULT 'false',
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
lastUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (username)
);
CREATE TABLE playersToGames (
roomCode VARCHAR(4) NOT NULL,
username VARCHAR(100) NOT NULL UNIQUE,
admin VARCHAR(5) DEFAULT 'false' NOT NULL,
FOREIGN KEY (roomCode)
REFERENCES games(roomCode),
FOREIGN KEY (username)
REFERENCES players(username)
);