-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql_create.sql
118 lines (95 loc) · 4.1 KB
/
mysql_create.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
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Table `registrations`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `registrations` (
`unique_id` INT NOT NULL AUTO_INCREMENT,
`icao_hex` CHAR(6) NOT NULL,
`registration` VARCHAR(20) NOT NULL,
`data` JSON NOT NULL,
`hash` CHAR(32) NOT NULL,
`source` INT NOT NULL,
`created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`unique_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
CREATE UNIQUE INDEX `unique_id_UNIQUE` ON `registrations` (`unique_id` ASC) VISIBLE;
CREATE UNIQUE INDEX `icao_hex_hash` ON `registrations` (`icao_hex` ASC, `hash` ASC) VISIBLE;
CREATE INDEX `icao_hex` ON `registrations` (`icao_hex` ASC) VISIBLE;
CREATE INDEX `hash` ON `registrations` (`hash` ASC) VISIBLE;
CREATE INDEX `registration` ON `registrations` (`registration` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `simple`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `simple` (
`unique_id` INT NOT NULL AUTO_INCREMENT,
`icao_hex` CHAR(6) NOT NULL,
`registration` VARCHAR(20) NOT NULL,
`data` JSON NOT NULL,
`hash` CHAR(32) NOT NULL,
`source` INT NOT NULL,
`created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`unique_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
CREATE UNIQUE INDEX `unique_id_UNIQUE` ON `simple` (`unique_id` ASC) VISIBLE;
CREATE UNIQUE INDEX `icao_hex_hash` ON `simple` (`icao_hex` ASC, `hash` ASC) VISIBLE;
CREATE INDEX `icao_hex` ON `simple` (`icao_hex` ASC) VISIBLE;
CREATE INDEX `hash` ON `simple` (`hash` ASC) VISIBLE;
CREATE INDEX `registration` ON `simple` (`registration` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `sources`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sources` (
`unique_id` INT NOT NULL AUTO_INCREMENT,
`agency` VARCHAR(50) NOT NULL,
PRIMARY KEY (`unique_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- -----------------------------------------------------
-- Table `operators`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `operators` (
`unique_id` int NOT NULL AUTO_INCREMENT,
`airline_designator` varchar(10) NOT NULL,
`name` varchar(255) NOT NULL,
`callsign` varchar(45) NOT NULL,
`country` varchar(45) NOT NULL,
`hash` char(32) NOT NULL,
`source` INT NOT NULL,
`created` datetime DEFAULT CURRENT_TIMESTAMP,
`deleted` datetime DEFAULT NULL,
PRIMARY KEY (`unique_id`),
UNIQUE KEY `unique_id_UNIQUE` (`unique_id`),
UNIQUE KEY `airline_designator_hash` (`airline_designator`,`hash`),
KEY `airline_designator` (`airline_designator`),
KEY `hash` (`hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- -----------------------------------------------------
-- Table `flight_numbers`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flight_numbers` (
`unique_id` int NOT NULL AUTO_INCREMENT,
`airline_designator` char(3) DEFAULT NULL,
`flight_number` varchar(10) DEFAULT NULL,
`ident` varchar(10) DEFAULT NULL,
`origin` char(4) DEFAULT NULL,
`destination` char(4) DEFAULT NULL,
`expires` datetime DEFAULT NULL,
`source` int DEFAULT NULL,
`hash` char(32) DEFAULT NULL,
PRIMARY KEY (`unique_id`),
UNIQUE KEY `unique_id_UNIQUE` (`unique_id`),
UNIQUE KEY `hash` (`hash`,`ident`),
KEY `operating_flight_ident` (`ident`)
) ENGINE=InnoDB AUTO_INCREMENT=593 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;