create table if not exists sales_managers ( id serial primary key not null, name varchar(250) not null, languages varchar(100)[], products varchar(100)[], customer_ratings varchar(100)[] ); create table if not exists slots ( id serial primary key not null, start_date timestamptz not null, end_date timestamptz not null, booked boolean not null default false, sales_manager_id int not null references sales_managers(Id) ); create index slots_manager_booked_start_date_idx on slots(sales_manager_id, booked, start_date); create index slots_manager_booked_end_date_idx on slots(sales_manager_id, booked, end_date); insert into sales_managers (name, languages, products, customer_ratings) values ('Seller 1', '{"German"}', '{"SolarPanels"}', '{"Bronze"}'); insert into sales_managers (name, languages, products, customer_ratings) values ('Seller 2', '{"German", "English"}', '{"SolarPanels", "Heatpumps"}', '{"Gold","Silver","Bronze"}'); insert into sales_managers (name, languages, products, customer_ratings) values ('Seller 3', '{"German", "English"}', '{"Heatpumps"}', '{"Gold","Silver","Bronze"}'); insert into slots (sales_manager_id, booked, start_date, end_date) values (1, false, '2024-05-03T10:30Z', '2024-05-03T11:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (1, true, '2024-05-03T11:00Z', '2024-05-03T12:00Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (1, false, '2024-05-03T11:30Z', '2024-05-03T12:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (2, false, '2024-05-03T10:30Z', '2024-05-03T11:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (2, false, '2024-05-03T11:00Z', '2024-05-03T12:00Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (2, false, '2024-05-03T11:30Z', '2024-05-03T12:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (3, true, '2024-05-03T10:30Z', '2024-05-03T11:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (3, false, '2024-05-03T11:00Z', '2024-05-03T12:00Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (3, false, '2024-05-03T11:30Z', '2024-05-03T12:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (1, false, '2024-05-04T10:30Z', '2024-05-04T11:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (1, false, '2024-05-04T11:00Z', '2024-05-04T12:00Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (1, true, '2024-05-04T11:30Z', '2024-05-04T12:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (2, true, '2024-05-04T10:30Z', '2024-05-04T11:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (2, false, '2024-05-04T11:00Z', '2024-05-04T12:00Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (2, true, '2024-05-04T11:30Z', '2024-05-04T12:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (3, true, '2024-05-04T10:30Z', '2024-05-04T11:30Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (3, false, '2024-05-04T11:00Z', '2024-05-04T12:00Z'); insert into slots (sales_manager_id, booked, start_date, end_date) values (3, false, '2024-05-04T11:30Z', '2024-05-04T12:30Z');