create view BaggageDetails (PassengerId, Name, Surname, DateOfBirth, TicketId, FlightId, FlightNumber, Origin, Destination, BaggageID,
    BaggageType, StatusType, Timestamp, StatusAirport) as
    select passenger.id, passenger.name, passenger.surname, passenger.dateofbirth,
           ticket.id, flight.id, flight.flightnumber, departureAirport.code, arrivalAirport.code,
           baggage.id, baggagetype.name, baggagestatustype.name,
           baggagestatus.timestamp,statusAirport.code
    from ticket
    join baggage on baggage.ticketid = ticket.id
    join baggagestatus on baggage.id = baggagestatus.baggageid
    join baggagestatustype on baggagestatus.baggagestatustypeid = baggagestatustype.id
    join baggagetype on baggage.baggagetypeid = baggagetype.id
    join flight on ticket.flightid = flight.id
    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 airport as statusAirport on statusAirport.id = baggagestatus.airportid
    join passenger on ticket.passengerid = passenger.id;



