-
Notifications
You must be signed in to change notification settings - Fork 0
/
wienerlinien.sql
99 lines (90 loc) · 2.74 KB
/
wienerlinien.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
DROP TABLE IF EXISTS agency;
DROP TABLE IF EXISTS calendar;
DROP TABLE IF EXISTS calendar_dates;
DROP TABLE IF EXISTS routes;
DROP TABLE IF EXISTS shapes;
DROP TABLE IF EXISTS stop_times;
DROP TABLE IF EXISTS stops;
DROP TABLE IF EXISTS trips;
CREATE TABLE agency
(
agency_id text UNIQUE NULL,
agency_name text NOT NULL,
agency_url text NOT NULL,
agency_timezone text NOT NULL,
agency_lang text NULL,
agency_phone text NULL
);
CREATE TABLE calendar
(
service_id text PRIMARY KEY,
monday boolean NOT NULL,
tuesday boolean NOT NULL,
wednesday boolean NOT NULL,
thursday boolean NOT NULL,
friday boolean NOT NULL,
saturday boolean NOT NULL,
sunday boolean NOT NULL,
start_date date NOT NULL,
end_date date NOT NULL
);
CREATE TABLE calendar_dates
(
service_id text NOT NULL,
date date NOT NULL,
exception_type integer NOT NULL
);
CREATE TABLE routes
(
route_id text PRIMARY KEY,
agency_id text NULL,
route_short_name text NULL,
route_long_name text NULL,
route_type integer NULL,
route_color text NULL,
route_text_color text NULL
);
CREATE TABLE shapes
(
shape_id text,
shape_pt_lat double precision NOT NULL,
shape_pt_lon double precision NOT NULL,
shape_pt_sequence integer NOT NULL,
shape_dist_traveled double precision NULL
);
CREATE TABLE stop_times
(
trip_id text NOT NULL,
arrival_time interval NOT NULL,
departure_time interval NOT NULL,
stop_id text NOT NULL,
stop_sequence integer NOT NULL,
pickup_type integer NULL CHECK(pickup_type >= 0 and pickup_type <=3),
drop_off_type integer NULL CHECK(drop_off_type >= 0 and drop_off_type <=3),
shape_dist_traveled double precision NULL
);
CREATE TABLE stops
(
stop_id text PRIMARY KEY,
stop_name text NOT NULL,
stop_lat double precision NOT NULL,
stop_lon double precision NOT NULL
);
CREATE TABLE trips
(
route_id text NOT NULL,
service_id text NOT NULL,
trip_id text NOT NULL PRIMARY KEY,
shape_id text NULL,
trip_headsign text NULL,
direction_id boolean NULL,
block_id text NULL
);
\copy agency from './gtfs/agency.txt' with csv header
\copy calendar from './gtfs/calendar.txt' with csv header
\copy calendar_dates from './gtfs/calendar_dates.txt' with csv header
\copy routes from './gtfs/routes.txt' with csv header
\copy shapes from './gtfs/shapes.txt' with csv header
\copy stop_times from './gtfs/stop_times.txt' with csv header
\copy stops from './gtfs/stops.txt' with csv header
\copy trips from './gtfs/trips.txt' with csv header