-
Notifications
You must be signed in to change notification settings - Fork 3
/
database.sql
124 lines (116 loc) · 4.47 KB
/
database.sql
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
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0 */;
CREATE TABLE `chatlog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userId` int(11) NOT NULL,
`date` datetime NOT NULL,
`message` text NOT NULL,
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
CONSTRAINT `chatlog_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `garages` (
`id` int(11) NOT NULL,
`userId` int(11) NOT NULL,
`price` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
CONSTRAINT `garages_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = latin1;
CREATE TABLE `hiddenpackages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userId` int(11) NOT NULL,
`packageId` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `userId_packageId` (`userId`, `packageId`),
KEY `userId` (`userId`),
CONSTRAINT `hiddenpackages_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(24) NOT NULL,
`password` varchar(300) NOT NULL,
`language` enum ('de', 'en') NOT NULL,
`isAdmin` tinyint(1) NOT NULL DEFAULT '0',
`posX` float DEFAULT NULL,
`posY` float DEFAULT NULL,
`posZ` float DEFAULT NULL,
`angle` float DEFAULT NULL,
`interior` int(11) DEFAULT NULL,
`skin` int(11) DEFAULT '0',
`money` int(11) NOT NULL DEFAULT '0',
`level` int(11) NOT NULL DEFAULT '1',
`registerDate` datetime NOT NULL,
`lastLogin` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `vehiclecomponents` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`vehicleId` int(11) NOT NULL,
`slot` int(11) NOT NULL,
`componentId` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `vehicleId_slot` (`vehicleId`, `slot`),
KEY `vehicleId` (`vehicleId`),
CONSTRAINT `vehiclecomponents_vehicleId` FOREIGN KEY (`vehicleId`) REFERENCES `vehicles` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `vehicletuningparts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`vehicleId` int(11) NOT NULL,
`type` ENUM ('frontBumber', 'hood', 'lights', 'neon', 'rearBumber', 'roof', 'spoiler') NOT NULL,
`value` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `vehicleId_type` (`vehicleId`, `type`),
KEY `vehicleId` (`vehicleId`),
CONSTRAINT `vehicletuningparts_vehicleId` FOREIGN KEY (`vehicleId`) REFERENCES `vehicles` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `vehicles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`modelId` int(11) NOT NULL,
`userId` int(11) NOT NULL,
`garageId` int(11) DEFAULT NULL,
`posX` float NOT NULL DEFAULT '0',
`posY` float NOT NULL DEFAULT '0',
`posZ` float NOT NULL DEFAULT '0',
`angle` float NOT NULL DEFAULT '0',
`health` float NOT NULL DEFAULT '1000',
`mileage` int(11) NOT NULL DEFAULT '0',
`numberPlate` varchar(32) NOT NULL DEFAULT '',
`color1` int(11) NOT NULL DEFAULT '0',
`color2` int(11) NOT NULL DEFAULT '0',
`paintjobId` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
KEY `garageId` (`garageId`),
CONSTRAINT `vehicles_garageId` FOREIGN KEY (`garageId`) REFERENCES `garages` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `vehicles_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
/*!40014 SET FOREIGN_KEY_CHECKS = @OLD_FOREIGN_KEY_CHECKS */;