create view SeatAvailability (FlightId, FlightNumber, Origin, Destination,
    Departure, Arrival, SeatId, SeatNumber, SeatLetter, SeatPrice, SeatClass, Available) as
    select flight.id, flight.flightnumber, departureAirport.code,
           arrivalAirport.code, flight.departure, flight.arrival, seat.id,
           seatconfiguration.number, seatconfiguration.letter, seatconfiguration.price,
           seatclass.name, not seat.reserved
    from flight
    join seat on flight.id = seat.flightid
    join gate as departureGate on departureGate.id = flight.actualgatedepartureid
    join gate as arrivalGate on arrivalGate.id = flight.actualgatearrivalid
    join terminal as departureTerminal on departureTerminal.id = departureGate.terminalid
    join terminal as arrivalTerminal on arrivalTerminal.id = arrivalGate.terminalid
    join airport as departureAirport on departureAirport.id = departureTerminal.airportid
    join airport as arrivalAirport on arrivalAirport.id = arrivalTerminal.airportid
    join seatconfiguration on seat.seatconfigurationid = seatconfiguration.id
    join seatclass on seatconfiguration.seatclassid = seatclass.id;



