-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflogger_schema-1.0.4.sql
214 lines (178 loc) · 7.23 KB
/
flogger_schema-1.0.4.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
-- 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` ;
--
-- 20150825 Corrected schema for AUTOINCREMENT primary keys
-- 20150826 Corrected flights table: set aircraft_id, users_id, launch_type,launch_types_idlaunch_types to INT NULL DEFAULT NULL
-- 20150908 Added fields for concatenating tracks for a flight when processing a group
--
-- -----------------------------------------------------
-- Table `mydb`.`users`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `users` ;
CREATE TABLE IF NOT EXISTS users (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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);
-- -----------------------------------------------------
-- Table `mydb`.`aircraft`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `aircraft` ;
CREATE TABLE IF NOT EXISTS `aircraft` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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);
-- -----------------------------------------------------
-- Table `mydb`.`flight_log`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flight_log` ;
CREATE TABLE IF NOT EXISTS `flight_log` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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,
'flight_no' INTEGER NULL DEFAULT NULL);
-- -----------------------------------------------------
-- Table `mydb`.`flight_log2`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flight_log2` ;
CREATE TABLE IF NOT EXISTS `flight_log2` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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);
-- -----------------------------------------------------
-- Table `mydb`.`flight_group`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flight_group` ;
CREATE TABLE IF NOT EXISTS `flight_group` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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,
'flight_no' INTEGER NULL DEFAULT NULL);
-- -----------------------------------------------------
-- Table `mydb`.`launch_types`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `launch_types` ;
CREATE TABLE IF NOT EXISTS `launch_types` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`aero_tow` VARCHAR(45) NULL,
`winch` VARCHAR(45) NULL,
`self_launch` VARCHAR(45) NULL);
--ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`flights`
-- 20160907 Added tug registration and max altitude if
-- flight launched by tug
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights` ;
CREATE TABLE IF NOT EXISTS `flights` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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
`aircraft_id` INT NULL DEFAULT NULL,
`users_id` INT NULL DEFAULT NULL,
`launch_type` INT NULL DEFAULT NULL,
`launch_types_idlaunch_types` INT NULL DEFAULT NULL,
'flight_no' INTEGER NULL DEFAULT NULL,
'track_file_name' TEXT NULL DEFAULT NULL,
'tug_registration' TEXT NULL DEFAULT NULL,
'tug_altitude' TEXT NULL DEFAULT NULL,
'tug_model' TEXT NULL DEFAULT NULL);
-- -----------------------------------------------------
-- Table `mydb`.`flight_log_final`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flight_log_final` ;
CREATE TABLE IF NOT EXISTS `flight_log_final` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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,
'flight_no' INTEGER NULL DEFAULT NULL,
'land_out' TEXT NULL DEFAULT NULL);
-- -----------------------------------------------------
-- Table `mydb`.`track`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `track` ;
CREATE TABLE IF NOT EXISTS `track` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`flight_no` INT NULL DEFAULT NULL,
`track_no` INT NULL DEFAULT NULL,
`latitude` DECIMAL NULL DEFAULT NULL,
`longitude` DECIMAL NULL DEFAULT NULL,
`altitude` DECIMAL NULL DEFAULT NULL,
`course` DECIMAL NULL DEFAULT NULL,
`speed` DECIMAL NULL DEFAULT NULL,
`timeStamp` TIMESTAMP NULL DEFAULT NULL);
-- -----------------------------------------------------
-- Table `mydb`.`trackFinal`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `trackFinal` ;
CREATE TABLE IF NOT EXISTS `trackFinal` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`flight_no` INT NULL DEFAULT NULL,
`track_no` INT NULL DEFAULT NULL,
`latitude` DECIMAL NULL DEFAULT NULL,
`longitude` DECIMAL NULL DEFAULT NULL,
`altitude` DECIMAL NULL DEFAULT NULL,
`course` DECIMAL NULL DEFAULT NULL,
`speed` DECIMAL NULL DEFAULT NULL,
`timeStamp` TIMESTAMP NULL DEFAULT NULL);
-- -----------------------------------------------------
-- Table `mydb`.`flarm_db`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flarm_db` ;
CREATE TABLE IF NOT EXISTS `flarm_db`(
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`type` TEXT NULL DEFAULT NULL,
`flarm_id` TEXT NULL DEFAULT NULL,
`airport` STRING NULL DEFAULT NULL,
`aircraft_model` TEXT NULL DEFAULT NULL,
`registration` TEXT NULL DEFAULT NULL,
`radio` TEXT NULL DEFAULT NULL,
`aircraft_type` TEXT NULL DEFAULT NULL);
CREATE UNIQUE INDEX `flarm_db_idx` ON `flarm_db`(`id`, `flarm_id`);