· 7 years ago · Jan 16, 2019, 08:14 AM
1create table if not exists passangers (
2 pas_id serial not null,
3 first_name varchar(100) not null,
4 last_name varchar(100) not null,
5 birthday date not null,
6 primary key (pas_id)
7);
8create table if not exists trains (
9 train_id serial not null,
10 stations int [],
11 free_space int not null,
12 primary key (train_id)
13);
14
15create table if not exists tickets (
16 train_id int not null,
17 pas_id int not null
18);
19
20create table if not exists shed (
21 train_id int not null,
22 time_to_go time not null
23);
24
25
26create table if not exists stations (
27 station_id serial not null,
28 shedule shed [],
29 primary key (station_id)
30);
31
32select *
33from public.passangers,
34 public.shed,
35 public.stations,
36 public.tickets,
37 public.trains
38where passangers.pas_id = tickets.pas_id and
39 stations = trains.stations and
40 trains.train_id = shed.train_id and
41 trains.train_id = tickets.train_id;