forked from mauryquijada/gtfs-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gtfs-sql.sql
186 lines (174 loc) · 5.86 KB
/
gtfs-sql.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
CREATE TABLE `agency` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
agency_id VARCHAR(100),
agency_name VARCHAR(255) NOT NULL,
agency_url VARCHAR(255) NOT NULL,
agency_timezone VARCHAR(100) NOT NULL,
agency_lang VARCHAR(100),
agency_phone VARCHAR(100),
agency_fare_url VARCHAR(100),
agency_email VARCHAR(255)
);
CREATE TABLE `calendar_dates` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
service_id VARCHAR(255) NOT NULL,
`date` VARCHAR(8) NOT NULL,
exception_type TINYINT(2) NOT NULL,
KEY `service_id` (service_id),
KEY `exception_type` (exception_type)
);
CREATE TABLE `calendar` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
service_id VARCHAR(255) NOT NULL,
monday TINYINT(1) NOT NULL,
tuesday TINYINT(1) NOT NULL,
wednesday TINYINT(1) NOT NULL,
thursday TINYINT(1) NOT NULL,
friday TINYINT(1) NOT NULL,
saturday TINYINT(1) NOT NULL,
sunday TINYINT(1) NOT NULL,
start_date VARCHAR(8) NOT NULL,
end_date VARCHAR(8) NOT NULL,
KEY `service_id` (service_id)
);
CREATE TABLE `fare_attributes` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
fare_id VARCHAR(100) NOT NULL,
price VARCHAR(50) NOT NULL,
currency_type VARCHAR(50) NOT NULL,
payment_method TINYINT(1) NOT NULL,
transfers TINYINT(1) NOT NULL,
transfer_duration VARCHAR(10),
KEY `fare_id` (fare_id)
);
CREATE TABLE `fare_rules` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
fare_id VARCHAR(100) NOT NULL,
route_id VARCHAR(100),
origin_id VARCHAR(100),
destination_id VARCHAR(100),
contains_id VARCHAR(100),
KEY `fare_id` (fare_id),
KEY `route_id` (route_id)
);
CREATE TABLE `feed_info` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
feed_publisher_name VARCHAR(100) NOT NULL,
feed_publisher_url VARCHAR(255) NOT NULL,
feed_lang VARCHAR(255) NOT NULL,
feed_start_date VARCHAR(8),
feed_end_date VARCHAR(8),
feed_version VARCHAR(100)
);
CREATE TABLE `frequencies` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
trip_id VARCHAR(100) NOT NULL,
start_time VARCHAR(8) NOT NULL,
end_time VARCHAR(8) NOT NULL,
headway_secs VARCHAR(100) NOT NULL,
exact_times TINYINT(1),
KEY `trip_id` (trip_id)
);
CREATE TABLE `routes` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
route_id VARCHAR(100) NOT NULL,
agency_id VARCHAR(50),
route_short_name VARCHAR(50) NOT NULL,
route_long_name VARCHAR(255) NOT NULL,
route_desc VARCHAR(255),
route_type VARCHAR(2) NOT NULL,
route_url VARCHAR(255),
route_color VARCHAR(255),
route_text_color VARCHAR(255),
KEY `agency_id` (agency_id),
KEY `route_type` (route_type)
);
CREATE TABLE `shapes` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
shape_id VARCHAR(100) NOT NULL,
shape_pt_lat DECIMAL(8,6) NOT NULL,
shape_pt_lon DECIMAL(8,6) NOT NULL,
shape_pt_sequence TINYINT(3) NOT NULL,
shape_dist_traveled VARCHAR(50),
KEY `shape_id` (shape_id)
);
CREATE TABLE `stop_times` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
trip_id VARCHAR(100) NOT NULL,
arrival_time VARCHAR(8) NOT NULL,
departure_time VARCHAR(8) NOT NULL,
stop_id VARCHAR(100) NOT NULL,
stop_sequence VARCHAR(100) NOT NULL,
stop_headsign VARCHAR(50),
pickup_type VARCHAR(2),
drop_off_type VARCHAR(2),
shape_dist_traveled VARCHAR(50),
timepoint TINYINT(1), #null/empty for times considered exact, 0 for times
# considered approximate, 1 for times considered exact
KEY `trip_id` (trip_id),
KEY `stop_id` (stop_id),
KEY `stop_sequence` (stop_sequence),
KEY `pickup_type` (pickup_type),
KEY `drop_off_type` (drop_off_type)
);
CREATE TABLE `stops` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
stop_id VARCHAR(255),
stop_code VARCHAR(50),
stop_name VARCHAR(255) NOT NULL,
stop_desc VARCHAR(255),
stop_lat DECIMAL(10,6) NOT NULL,
stop_lon DECIMAL(10,6) NOT NULL,
zone_id VARCHAR(255),
stop_url VARCHAR(255),
location_type VARCHAR(2),
parent_station VARCHAR(100),
stop_timezone VARCHAR(50),
wheelchair_boarding TINYINT(1),
KEY `zone_id` (zone_id),
KEY `stop_lat` (stop_lat),
KEY `stop_lon` (stop_lon),
KEY `location_type` (location_type),
KEY `parent_station` (parent_station)
);
CREATE TABLE `transfers` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
from_stop_id INT(100) NOT NULL,
to_stop_id VARCHAR(8) NOT NULL,
transfer_type TINYINT(1) NOT NULL,
min_transfer_time VARCHAR(100)
);
CREATE TABLE `trips` (
id INT(12) NOT NULL PRIMARY KEY AUTO_INCREMENT,
transit_system VARCHAR(50) NOT NULL,
route_id VARCHAR(100) NOT NULL,
service_id VARCHAR(100) NOT NULL,
trip_id VARCHAR(255) NOT NULL,
trip_headsign VARCHAR(255),
trip_short_name VARCHAR(255),
direction_id TINYINT(1), #0 for one direction, 1 for another.
block_id VARCHAR(11),
shape_id VARCHAR(11),
wheelchair_accessible TINYINT(1), #0 for no information, 1 for at
# least one rider accommodated on wheel chair, 2 for no riders
# accommodated.
bikes_allowed TINYINT(1), #0 for no information, 1 for at least
# one bicycle accommodated, 2 for no bicycles accommodated
KEY `route_id` (route_id),
KEY `service_id` (service_id),
KEY `direction_id` (direction_id),
KEY `block_id` (block_id),
KEY `shape_id` (shape_id)
);