В простейшей форме вам нужны три таблицы: одна для ваших автобусов, одна для их остановок и одна для расписаний.
create table bus (
bus_id int -- primary key
, route_name varchar(64)
)
create table stop (
stop_id int -- primary key
, bus_id int references bus(bus_id)
, address_or_intersection varchar(128)
)
create table timetable (
time_entry_id int -- primary key
, stop_id int references stop(stop_id)
, run_id int
, stop_time time
)
Первые две таблицы говорят сами за себя.Вот пример третьей таблицы для маршрута с тремя остановками, по которым один рейс выполняется утром, а другой - вечером:
bus:
bus_id route_name
------ ----------
1 red arrow
stop:
stop_id bus_id address
------- ------ ---------
1 1 Market St
2 1 North Point
3 1 Stockton
timetable:
time_entry_id stop_id run_id stop_time
------------- ------- ------ ---------
1 1 1 06:15
2 2 1 06:39
3 3 1 07:05
4 1 2 19:03
5 2 2 19:30
6 3 2 19:51