forked from tobiz/OGN-Flight-Logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flogger_schema-0.0.1.sql
154 lines (131 loc) · 4.9 KB
/
flogger_schema-0.0.1.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
-- 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='TRADITIONAL,ALLOW_INVALID_DATES';
-- CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`users`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `users` ;
-- CREATE TABLE IF NOT EXISTS `mydb`.`users` (
CREATE TABLE IF NOT EXISTS users (
`id` INT NULL DEFAULT NULL,
`first_name` TEXT NULL DEFAULT NULL,
`surname` TEXT NULL DEFAULT NULL,
`phone` TEXT NULL DEFAULT NULL,
`email` TEXT NULL DEFAULT NULL,
`password` TEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`)
UNIQUE (`email` ASC));
-- -----------------------------------------------------
-- Table `mydb`.`aircraft`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `aircraft` ;
CREATE TABLE IF NOT EXISTS `aircraft` (
`id` INT NULL DEFAULT NULL,
`registration` TEXT NULL DEFAULT NULL,
`type` TEXT NULL DEFAULT NULL,
`model` TEXT NULL DEFAULT NULL,
`owner` TEXT NULL DEFAULT NULL,
`airfield` TEXT NULL DEFAULT NULL,
`flarm_id` TEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`));
-- -----------------------------------------------------
-- Table `mydb`.`flight_log`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flight_log` ;
CREATE TABLE IF NOT EXISTS `flight_log` (
`id` INT NULL DEFAULT NULL,
`sdate` TEXT NULL DEFAULT NULL,
`stime` TEXT NULL DEFAULT NULL,
`edate` TEXT NULL DEFAULT NULL,
`etime` TEXT NULL DEFAULT NULL,
`duration` TEXT NULL DEFAULT NULL,
`src_callsign` TEXT NULL DEFAULT NULL,
`max_altitude` TEXT NULL DEFAULT NULL,
`speed` TEXT NULL DEFAULT NULL,
'registration' TEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`));
-- -----------------------------------------------------
-- Table `mydb`.`flight_group`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flight_group` ;
CREATE TABLE IF NOT EXISTS `flight_group` (
`id` INT NULL DEFAULT NULL,
`groupID` TEXT NULL DEFAULT NULL,
`sdate` TEXT NULL DEFAULT NULL,
`stime` TEXT NULL DEFAULT NULL,
`edate` TEXT NULL DEFAULT NULL,
`etime` TEXT NULL DEFAULT NULL,
`duration` TEXT NULL DEFAULT NULL,
`src_callsign` TEXT NULL DEFAULT NULL,
`max_altitude` TEXT NULL DEFAULT NULL,
'registration' TEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`));
-- -----------------------------------------------------
-- Table `mydb`.`launch_types`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `launch_types` ;
CREATE TABLE IF NOT EXISTS `launch_types` (
`id` INT NOT NULL,
`aero_tow` VARCHAR(45) NULL,
`winch` VARCHAR(45) NULL,
`self_launch` VARCHAR(45) NULL,
PRIMARY KEY (`id`));
--ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`flights`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights` ;
CREATE TABLE IF NOT EXISTS `flights` (
`id` INT NULL DEFAULT NULL,
`sdate` TEXT NULL DEFAULT NULL,
`stime` TEXT NULL DEFAULT NULL,
`edate` TEXT NULL DEFAULT NULL,
`etime` TEXT NULL DEFAULT NULL,
`duration` TEXT NULL DEFAULT NULL,
`src_callsign` TEXT NULL DEFAULT NULL,
`max_altitude` TEXT NULL DEFAULT NULL,
'registration' TEXT NULL DEFAULT NULL,
`aircraft_id` INT NOT NULL,
`users_id` INT NOT NULL,
`launch_type` INT NOT NULL,
`launch_types_idlaunch_types` INT NOT NULL,
PRIMARY KEY (`id`),
-- INDEX `fk_flights_aircraft_idx` (`aircraft_id` ASC),
-- INDEX `fk_flights_users1_idx` (`users_id` ASC),
-- INDEX `fk_flights_launch_types1_idx` (`launch_types_idlaunch_types` ASC),
CONSTRAINT `fk_flights_aircraft`
FOREIGN KEY (`aircraft_id`)
REFERENCES `aircraft` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_flights_users1`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_flights_launch_types1`
FOREIGN KEY (`launch_types_idlaunch_types`)
REFERENCES `launch_types` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `mydb`.`flight_log_final`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flight_log_final` ;
CREATE TABLE IF NOT EXISTS `flight_log_final` (
`id` INT NULL DEFAULT NULL,
`sdate` TEXT NULL DEFAULT NULL,
`stime` TEXT NULL DEFAULT NULL,
`edate` TEXT NULL DEFAULT NULL,
`etime` TEXT NULL DEFAULT NULL,
`duration` TEXT NULL DEFAULT NULL,
`src_callsign` TEXT NULL DEFAULT NULL,
`max_altitude` TEXT NULL DEFAULT NULL,
`speed` TEXT NULL DEFAULT NULL,
`registration` TEXT NULL DEFAULT NULL,
PRIMARY KEY (`id`));
--SET SQL_MODE=@OLD_SQL_MODE;
--SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
--SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;