create table employee (id integer, name varchar(255));
create table schedule (weekday varchar(20), employee_id integer, schedule_time_range_id integer, payload varchar(255));
create table schedule_time_range(id integer, start_time time, end_time time);
insert INTO employee values (1, 'Sergei');
insert INTO employee values (2, 'Andrey');
insert into schedule_time_range values (1, '10:30', '11:30');
insert into schedule_time_range values (2, '11:30', '12:30');
insert into schedule values ('MONDAY', 1, 1, '---/---');
insert into schedule values ('MONDAY', 1, 2, '---/---');
insert into schedule values ('TUESDAY', 1, 2, '901/504');
insert into schedule values ('TUESDAY', 1, 1, '555/111');
insert into schedule values ('MONDAY', 2, 1, '---/---');
insert into schedule values ('MONDAY', 2, 2, '111/111');
insert into schedule values ('TUESDAY', 2, 2, '901/222');
insert into schedule values ('TUESDAY', 2, 1, '901/222');
select employee.name, schedule.weekday, schedule.payload, schedule_time_range.start_time, schedule_time_range.end_time from schedule
inner join employee on schedule.employee_id = employee.id
inner join schedule_time_range on schedule_time_range.id = schedule.schedule_time_range_id
where schedule.employee_id = 1 order by schedule.weekday, schedule.schedule_time_range_id;
select employee.name, schedule.weekday, schedule.payload, schedule_time_range.start_time, schedule_time_range.end_time from schedule
inner join employee on schedule.employee_id = employee.id
inner join schedule_time_range on schedule_time_range.id = schedule.schedule_time_range_id
order by employee.name, schedule.weekday, schedule.schedule_time_range_id;