-
Notifications
You must be signed in to change notification settings - Fork 402
/
Copy pathcreate.sql
224 lines (206 loc) · 5.71 KB
/
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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
CREATE DATABASE flightdb2;
CREATE USER openflights@localhost;
GRANT ALL PRIVILEGES ON flightdb2.* TO openflights@localhost;
CONNECT flightdb2;
DROP TABLE IF EXISTS `airlines`;
CREATE TABLE `airlines` (
`name` text,
`iata` varchar(2) default NULL,
`icao` varchar(3) default NULL,
`callsign` text,
`country` text,
`country_code` varchar(2),
`alid` int(11) NOT NULL auto_increment,
`uid` int(11) default NULL,
`alias` text,
`mode` char(1) default 'F',
`active` varchar(1) default 'N',
`source` text,
PRIMARY KEY (`alid`),
KEY `iata` (`iata`),
KEY `icao` (`icao`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `airports`;
CREATE TABLE `airports` (
`name` text NOT NULL,
`city` text,
`country` text,
`country_code` varchar(2),
`iata` varchar(3) default NULL,
`icao` varchar(4) default NULL,
`x` double NOT NULL,
`y` double NOT NULL,
`elevation` int(11) default NULL,
`apid` int(11) NOT NULL auto_increment,
`uid` int(11) default NULL,
`timezone` float default NULL,
`dst` char(1) default NULL,
`tz_id` text,
`type` text,
`source` text,
PRIMARY KEY (`apid`),
KEY `x` (`x`),
KEY `y` (`y`),
KEY `iata` (`iata`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE UNIQUE INDEX `iata_idx` ON airports(iata);
CREATE UNIQUE INDEX `icao_idx` ON airports(icao);
DROP TABLE IF EXISTS `airports_dafif`;
CREATE TABLE `airports_dafif` (
`name` text NOT NULL,
`city` text,
`code` text,
`iata` varchar(3) default NULL,
`icao` varchar(4) NOT NULL,
`x` double NOT NULL,
`y` double NOT NULL,
`elevation` int(11) default NULL,
PRIMARY KEY (`icao`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `airports_gad`;
CREATE TABLE `airports_gad` (
`name` text NOT NULL,
`city` text,
`country` text,
`iata` varchar(3) default NULL,
`icao` varchar(4) NOT NULL,
`x` double NOT NULL,
`y` double NOT NULL,
`elevation` int(11) default NULL,
PRIMARY KEY (`icao`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `airports_oa`;
CREATE TABLE `airports_oa` (
`oaid` int(11) NOT NULL,
`ident` text,
`type` text,
`name` text NOT NULL,
`x` double NOT NULL,
`y` double NOT NULL,
`elevation` int(11) default NULL,
`continent` text,
`country` text,
`region` text,
`city` text,
`service` text,
`icao` varchar(4) default NULL,
`iata` varchar(3) default NULL,
`local` varchar(3) default NULL,
`home_link` text,
`wp_link` text,
`keywords` text,
PRIMARY KEY (`oaid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `countries`;
CREATE TABLE `countries` (
`name` text,
`iso_code` varchar(2) default NULL,
`dafif_code` varchar(2) NOT NULL,
PRIMARY KEY (`dafif_code`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `countries_oa`;
CREATE TABLE `countries_oa` (
`oacode` text,
`country` text,
`continent` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `flights`;
CREATE TABLE `flights` (
`uid` int(11) default NULL,
`src_apid` int(11) default NULL,
`src_time` time default NULL,
`dst_apid` int(11) default NULL,
`distance` int(11) default NULL,
`code` text,
`seat` text,
`seat_type` text,
`class` text,
`reason` text,
`plid` int(11) default NULL,
`alid` int(11) default NULL,
`trid` int(11) default NULL,
`fid` int(11) NOT NULL auto_increment,
`duration` time default NULL,
`registration` text,
`note` text,
`upd_time` datetime default NULL,
`opp` char(1) default 'N',
`src_date` date default NULL,
`mode` char(1) default 'F',
PRIMARY KEY (`fid`),
KEY `src_apid` (`src_apid`),
KEY `dst_apid` (`dst_apid`),
KEY `plid` (`plid`),
KEY `alid` (`alid`),
KEY `trid` (`trid`),
KEY `uid` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `locales`;
CREATE TABLE `locales` (
`locale` varchar(5) NOT NULL,
`name` text,
PRIMARY KEY (`locale`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `planes`;
CREATE TABLE `planes` (
`name` text,
`abbr` text,
`speed` double default NULL,
`plid` int(11) NOT NULL auto_increment,
`public` char(1) default NULL,
PRIMARY KEY (`plid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `routes`;
CREATE TABLE `routes` (
`airline` varchar(3) default NULL,
`alid` int(11) default NULL,
`src_ap` varchar(4) default NULL,
`src_apid` int(11) default NULL,
`dst_ap` varchar(4) default NULL,
`dst_apid` int(11) default NULL,
`codeshare` text,
`stops` text,
`equipment` text,
`added` varchar(1) default NULL,
`rid` int(11) NOT NULL auto_increment,
PRIMARY KEY (`rid`),
UNIQUE KEY `alid` (`alid`,`src_apid`,`dst_apid`),
KEY `src_apid` (`src_apid`),
KEY `dst_apid` (`dst_apid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `trips`;
CREATE TABLE `trips` (
`name` text,
`url` text,
`uid` int(11) default NULL,
`trid` int(11) NOT NULL auto_increment,
`public` text,
PRIMARY KEY (`trid`),
KEY `uid` (`uid`)
) ENGINE=MyISAM AUTO_INCREMENT=84 DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`name` text,
`password` text,
`uid` int(11) NOT NULL auto_increment,
`public` text,
`email` text,
`count` int(11) default '0',
`editor` varchar(1) default 'B',
`elite` varchar(1) default '',
`validity` date default NULL,
`guestpw` text,
`startpane` varchar(1) default 'H',
`locale` varchar(5) default 'en_US',
`units` varchar(1) default 'M',
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `tripit_tokens`;
CREATE TABLE `tripit_tokens` (
`uid` int(11) NOT NULL,
`auth_token` char(40) NOT NULL,
`auth_token_secret` char(40) NOT NULL,
`active` enum('N','Y') NOT NULL DEFAULT 'Y',
KEY `uid_idx` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
\! echo Done, next run sql/load-data.sql