-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
36 lines (27 loc) · 1011 Bytes
/
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
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
CREATE TABLE `results` (
`id` int(11) NOT NULL,
`startlist_id` int(11) NOT NULL,
`result` tinyint(3) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE `startlist` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`surname` varchar(255) NOT NULL,
`category` varchar(3) NOT NULL,
`pb` tinyint(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
ALTER TABLE `results`
ADD PRIMARY KEY (`id`),
ADD KEY `fk_startlist_id` (`startlist_id`);
ALTER TABLE `startlist`
ADD PRIMARY KEY (`id`);
ALTER TABLE `results`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
ALTER TABLE `startlist`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32;
ALTER TABLE `results`
ADD CONSTRAINT `fk_startlist_id` FOREIGN KEY (`startlist_id`) REFERENCES `startlist` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;