-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatescriptplusvalues.txt
160 lines (129 loc) · 4.44 KB
/
createscriptplusvalues.txt
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
CREATE TABLE GameModes (
gameModeId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
gameModeName VARCHAR(45) NOT NULL ,
PRIMARY KEY(gameModeId));
CREATE TABLE Maps (
mapId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
mapName VARCHAR(45) NOT NULL ,
mapSize INTEGER UNSIGNED NULL ,
PRIMARY KEY(mapId));
CREATE TABLE Players (
playerId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
playername VARCHAR(45) NOT NULL ,
PRIMARY KEY(playerId));
CREATE TABLE AccessLevels (
accessLevel INTEGER UNSIGNED NOT NULL ,
accessName VARCHAR(45) NOT NULL ,
PRIMARY KEY(accessLevel));
CREATE TABLE Users (
userId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
AccessLevels_accessLevel INTEGER UNSIGNED NOT NULL ,
username VARCHAR(20) NOT NULL ,
email VARCHAR(255) NOT NULL ,
upassword VARCHAR(255) NOT NULL ,
PRIMARY KEY(userId) ,
INDEX Users_AccessLevel(AccessLevels_accessLevel),
FOREIGN KEY(AccessLevels_accessLevel)
REFERENCES AccessLevels(accessLevel)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE TABLE Replays (
replayId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
GameModes_gameModeId INTEGER UNSIGNED NOT NULL ,
Users_userId INTEGER UNSIGNED NOT NULL ,
Maps_mapId INTEGER UNSIGNED NOT NULL ,
title VARCHAR(255) NOT NULL ,
description TEXT NOT NULL ,
factionTeam1 VARCHAR(20) NOT NULL ,
factionTeam2 VARCHAR(20) NOT NULL ,
nrOfPlayersTeam1 INTEGER UNSIGNED NOT NULL ,
nrOfPlayersTeam2 INTEGER UNSIGNED NOT NULL ,
replayData MEDIUMBLOB NOT NULL ,
uploadDate DATETIME NOT NULL ,
downloadCounter INTEGER UNSIGNED NOT NULL DEFAULT 0 ,
isDeleted TINYINT UNSIGNED NOT NULL DEFAULT 0 ,
PRIMARY KEY(replayId) ,
INDEX Replays_UserId(Users_userId) ,
INDEX Replays_MapId(Maps_mapId) ,
INDEX Replays_GameModeId(GameModes_gameModeId),
FOREIGN KEY(Users_userId)
REFERENCES Users(userId)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY(Maps_mapId)
REFERENCES Maps(mapId)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY(GameModes_gameModeId)
REFERENCES GameModes(gameModeId)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE TABLE FeaturedReplays (
featuredId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Replays_replayId INTEGER UNSIGNED NOT NULL ,
PRIMARY KEY(featuredId) ,
INDEX FeaturedReplays_FKIndex1(Replays_replayId),
FOREIGN KEY(Replays_replayId)
REFERENCES Replays(replayId)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE TABLE Ratings (
ratingId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Users_userId INTEGER UNSIGNED NOT NULL ,
Replays_replayId INTEGER UNSIGNED NOT NULL ,
rating INTEGER UNSIGNED NULL ,
PRIMARY KEY(ratingId) ,
INDEX ReplayRatings_FKIndex1(Users_userId) ,
INDEX ReplayRatings_FKIndex2(Replays_replayId),
FOREIGN KEY(Users_userId)
REFERENCES Users(userId)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY(Replays_replayId)
REFERENCES Replays(replayId)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE TABLE Comments (
commentId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Users_userId INTEGER UNSIGNED NOT NULL ,
Replays_replayId INTEGER UNSIGNED NOT NULL ,
comment MEDIUMTEXT NOT NULL ,
title INTEGER UNSIGNED NULL ,
PRIMARY KEY(commentId) ,
INDEX Comments_FKIndex1(Replays_replayId) ,
INDEX Comments_FKIndex2(Users_userId),
FOREIGN KEY(Replays_replayId)
REFERENCES Replays(replayId)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY(Users_userId)
REFERENCES Users(userId)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE TABLE Players_has_Replays (
Players_playerId INTEGER UNSIGNED NOT NULL ,
Replays_replayId INTEGER UNSIGNED NOT NULL ,
playerTeam INT NOT NULL ,
PRIMARY KEY(Players_playerId, Replays_replayId) ,
INDEX Players_has_Replays_FKIndex1(Players_playerId) ,
INDEX Players_has_Replays_FKIndex2(Replays_replayId),
FOREIGN KEY(Players_playerId)
REFERENCES Players(playerId)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY(Replays_replayId)
REFERENCES Replays(replayId)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
INSERT into AccessLevels VALUES
('5', 'User'),
('10', 'Moderator'),
('20', 'Administrator');
INSERT into Maps VALUES
('', 'Hell\'s Highway', '1'),
('', 'Airfield', '2'),
('', 'Joint Strike', '3'),
('', 'Three Mile Island', '4');
INSERT into GameModes VALUES
('', 'Destruction'),
('', 'Time');