[use fiitpdt/postgres for this excercise] Suppose the following relational schema exists, where there are travel agents
selling flights to some destination. A flight can have multiple services from the set
{business class, lunch, drinks, priority boarding, online check-in}
.
AGENT (**a_id**, name)
FLIGHT (**destination**, pilot_name, a_id)
SERVICE (**flight**, **service**)
- Transform this schema to an object version using 2 data types
- Insert some test data
- Write query which returns services provided on a flight to London. Results should be in 1st normal form
create type t_agent as (
name text
);
create type t_flight as (
destination text,
pilot_name text,
agent t_agent,
services text array
);
create table flights of t_flight;
insert into flights values ('Brusel', 'Tomas', row('Agent 001'), array ['drinks', 'lunch']);
insert into flights values ('Paris', 'Pavol', row('Agent 002'), array ['business class', 'lunch', 'drinks', 'priority boarding', 'online check-in']);
insert into flights values ('London', 'Jozef', row('Agent 002'), array ['business class', 'lunch', 'online check-in']);
Write query which returns services provided on a flight to London. Results should be in 1st normal form
select destination, unnest(services) from flights where destination = 'London';