Repository navigation
Expand file tree
/
Copy pathinit.sql
More file actions
48 lines (42 loc) · 1.7 KB
/
Copy pathinit.sql
File metadata and controls
48 lines (42 loc) · 1.7 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
CREATE TABLE IF NOT EXISTS User (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
language ENUM('en', 'es', 'it', 'fr') NOT NULL DEFAULT 'en',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS Currency (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
symbol VARCHAR(100) UNIQUE NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS Continent (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
name JSON NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS Region (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
name JSON NOT NULL,
continent_id INT(11) UNSIGNED NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE Region ADD CONSTRAINT fk_region_continent_continent_id FOREIGN KEY (continent_id) REFERENCES Continent (id);
CREATE INDEX idx_region_continent_id ON Region (continent_id);
CREATE TABLE IF NOT EXISTS Country (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
code VARCHAR(3) UNIQUE NOT NULL,
name JSON NOT NULL,
capital JSON NOT NULL,
official_name JSON,
region_id INT(11) UNSIGNED NOT NULL,
population INT(11) UNSIGNED NOT NULL,
google_maps_link VARCHAR(255),
flag VARCHAR(255),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE Country ADD CONSTRAINT fk_country_region_region_id FOREIGN KEY (region_id) REFERENCES Region (id);
CREATE INDEX idx_country_region_id ON Country (region_id);