create view TicketDetails (PassengerId, Name, Surname, DateOfBirth, Email, AssistanceRequirements,
    FlightId, FlightNumber, DepartureAirport, DepartureTerminal, DepartureGate,
        ArrivalAirport, ArrivalTerminal, ArrivalGate, DepartureTime, ArrivalTime, FlightStatus, ReservationId, TicketId,
    BasePrice, FinalPrice, TicketStatus, SeatId, SeatNumber, SeatLetter, ExitRow, SeatClass) as
    select passenger.id, passenger.name, passenger.surname, passenger.dateofbirth,
           passenger.email, passenger.assistancerequirements,
           flight.id, flight.flightnumber, dAirport.code, dTerminal.name,
           dGate.number, aAirport.code, aTerminal.name, aGate.number,
           flight.departure, flight.arrival, flightstatus.name, reservation.id,
           ticket.id, ticket.baseprice,
           ticket.finalprice, ticketstatus.name,
           seat.id, seatconfiguration.number, seatconfiguration.letter,
           seatconfiguration.exitrow,
           seatclass.name
    from ticket
    join passenger on passenger.id = ticket.passengerid
    join reservation on ticket.reservationid = reservation.id
    join flight on ticket.flightid = flight.id
    left join seat on ticket.seatid = seat.id
    left join seatconfiguration on seat.seatconfigurationid = seatconfiguration.id
    left join seatclass on seatconfiguration.seatclassid = seatclass.id
    join gate as dGate on dGate.id = flight.actualgatedepartureid
    join terminal as dTerminal on dTerminal.id = dGate.terminalid
    join airport as dAirport on dAirport.id = dTerminal.airportid
    join gate as aGate on aGate.id = flight.actualgatearrivalid
    join terminal as aTerminal on aTerminal.id = aGate.terminalid
    join airport as aAirport on aAirport.id = aTerminal.airportid
    join flightstatus on flight.statusid = flightstatus.id
    join ticketstatus on ticket.ticketstatusid = ticketstatus.id;
