...
 
Commits (5)
#!/bin/bash
USER=postgres
PW=postgres
DB=trippydb
PGPASSWORD=$PW psql -h localhost -U $USER -d $DB -q -f schema.sql
PGPASSWORD=$PW psql -h localhost -U $USER -d $DB -q -f emt_stops.sql
PGPASSWORD=$PW psql -h localhost -U $USER -d $DB -q -f emt_lines.sql
PGPASSWORD=$PW psql -h localhost -U $USER -d $DB -q -f emt_linestops.sql
PGPASSWORD=$PW psql -h localhost -U $USER -d $DB -q -f emt_journeys.sql
unzip -p emt_stages.zip | PGPASSWORD=$PW psql -h localhost -U $USER -d $DB -q
This diff is collapsed.
DROP TABLE IF EXISTS stop CASCADE;
CREATE TABLE stop
(
id varchar primary key,
ctr_id integer unique,
name varchar,
lat float,
lon float
);
DROP TABLE IF EXISTS line CASCADE;
CREATE TABLE line
(
id varchar primary key,
short_name varchar,
long_name varchar
);
DROP TABLE IF EXISTS line_stop CASCADE;
CREATE TABLE line_stop
(
line_id varchar references line (id) on delete cascade,
stop_id varchar references stop (id) on delete cascade,
seq integer,
primary key (line_id, stop_id)
);
DROP TABLE IF EXISTS journey CASCADE;
CREATE TABLE journey
(
line_id varchar references line (id) on delete cascade,
journey_id integer,
start_time timestamp without time zone,
primary key (line_id, journey_id)
);
--skipping stop_time
DROP TABLE IF EXISTS stage CASCADE;
CREATE TABLE stage
(
trip_id integer,
num_stage integer,
line_id varchar,
journey_id integer,
board_stop varchar,
alight_stop varchar,
primary key (trip_id, num_stage),
foreign key (line_id, journey_id) references journey on delete cascade,
foreign key (line_id, board_stop) references line_stop on delete cascade,
foreign key (line_id, alight_stop) references line_stop on delete cascade
);