-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtestInitialBase.sql
More file actions
90 lines (72 loc) · 1.78 KB
/
testInitialBase.sql
File metadata and controls
90 lines (72 loc) · 1.78 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
drop database if exists testProchessDB;
create database testProchessDB;
USE testProchessDB;
DROP TABLE IF EXISTS accounts;
-- remove table if it already exists and start from scratch
-- ACCOUNTS DDL INITIALIZATION
CREATE TABLE accounts (
ID INT auto_increment,
username nvarchar(64),
pass_hash nvarchar(128),
email nvarchar(64),
primary key (ID),
unique key (username),
unique key (email)
);
CREATE TABLE validations(
ID INT auto_increment,
username nvarchar(64),
password nvarchar(128),
email nvarchar(64),
code nvarchar(64),
primary key (ID)
);
-- GAMES FOR ACCOUNTS
drop TABLE IF EXISTS account_stats;
CREATE TABLE account_stats(
acc_ID INT,
bulletRank INT,
bulletGames INT,
blitzRank INT,
blitzGames INT,
classicalRank INT,
classicalGames INT,
UNIQUE (acc_ID),
FOREIGN KEY (acc_ID) REFERENCES accounts(ID) on DELETE CASCADE
);
ALTER TABLE account_stats
ADD CONSTRAINT acc_id_fk
FOREIGN KEY (acc_ID) REFERENCES accounts(ID) on DELETE CASCADE;
-- GAME HISTORY DDL INITIALIZATION
DROP TABLE IF EXISTS games;
CREATE TABLE games (
ID int auto_increment,
player1ID int,
player2ID int,
colorOfPlayer1 boolean,
colorOfPlayer2 boolean,
primary key (ID),
foreign key (player1ID) references accounts(ID),
foreign key (player2ID) references accounts(ID)
);
DROP TABLE IF EXISTS moves;
CREATE TABLE moves(
ID INT auto_increment,
gameID int,
srcRow int,
srcCol int,
dstRow int,
dstCol int,
piece int,
primary key (ID),
foreign key (gameID) references games(ID)
);
drop table if exists search_queue;
CREATE TABLE search_queue(
username_ID INT,
timePrimary nvarchar(64),
timeBonus nvarchar(64),
foreign key (username_ID) references accounts(ID),
primary key (username_ID),
unique key (username_ID)
);