Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write several SQL queries on a relational flights database. Questions For each question below, write a SQL query to find the answer. 1. F ind

Write several SQL queries on a relational flights database.

Questions For each question below, write a SQL query to find the answer.

1. F ind the distinct flight numbers of all flights from Seattle to Boston by Alaska Airlines Inc. on Mondays. Also notice that, in the database, the city names include the state. So Seattle appears as Seattle WA.

2. Find all flights from Seattle to B oston on July 15th 2015. Search only for itineraries that have one stop. Both legs of the flight must have occurred on the same day and must be with the same carrier. The total flight time (actual_time) of the entire itinerary should be less than 7 hours ( but notice that actual_time is in minutes). For each itinerary, the query should return the name of the carrier, the first flight number, the origin and destination of that first flight, the flight time, the second flight number, the origin and destination of the second flight, the second flight time, and finally the total flight time.

3. Find the day of the week with the longest average arrival delay. Return the na me of the da y and the average delay.

4. Find the names of all airlines that ever flew more than 1000 flights in one day. Return only the names. Do not return any duplicates. 5. Find all airlines that had more than 0.5 percent of their fli ghts out of Seattle be canceled. Return the name of the airline and the percentage of canceled flight out of Seattle. Order the results by the percentage of canceled flig hts in ascending order.

This is the table I used for the problem

CREATE TABLE Carriers(cid INT PRIMARY KEY, name VARCHAR); CREATE TABLE Months(mid INT PRIMARY KEY, month VARCHAR); CREATE TABLE Weekday(did INT PRIMARY KEY, day_of_week VARCHAR); CREATE TABLE Flights(fid INT PRIMARY KEY, year VARCHAR, month_id INT, day_of_month INT, day_of_week_id INT, carrier_id VARCHAR, flight_num INT, origin_city VARCHAR, origin_state VARCHAR,dest_city VARCHAR, dest_state VARCHAR, deperture_delay VARCHAR, taxi_out VARCHAR, arrival_delay VARCHAR, canceled INT, actual_time INT, distance INT, FOREIGN KEY(month_id) REFERENCES Months(mid), FOREIGN KEY(day_of_week_id) REFERENCES Weekday(did), FOREIGN KEY(carrier_id) REFERENCES Carriers(cid));

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

Do you currently have a team agreement?

Answered: 1 week ago

Question

How will the members be held accountable?

Answered: 1 week ago