-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
41 lines (38 loc) · 1.12 KB
/
schema.sql
File metadata and controls
41 lines (38 loc) · 1.12 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
-- -- Create table competition
CREATE TABLE competition
(
id BIGINT NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
location varchar(255) NOT NULL,
date date NOT NULL,
PRIMARY KEY (id)
);
-- Create table competitor
CREATE TABLE competitor
(
id BIGINT NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
club varchar(255) NOT NULL,
birth_date date NOT NULL,
PRIMARY KEY (id)
);
-- Create table leaderboard
CREATE TABLE leaderboard
(
id BIGINT NOT NULL AUTO_INCREMENT,
competition_id BIGINT NOT NULL,
competitor_id BIGINT NOT NULL,
placement int NOT NULL,
PRIMARY KEY (id),
foreign key (competition_id) references competition (id) on delete cascade on update cascade,
foreign key (competitor_id) references competitor (id) on delete cascade on update cascade
);
-- Create table users
CREATE TABLE users
(
id BIGINT NOT NULL AUTO_INCREMENT,
role varchar(255) NOT NULL,
username varchar(255) NOT NULL,
password varchar(255) NOT NULL,
PRIMARY KEY (id)
);