Question: SQL PROGRAMMING: Write two SQL queries on a relational flights database specified below. The database contains one table called Flights , whose scheme is as
SQL PROGRAMMING:
Write two SQL queries on a relational flights database specified below. The database contains one table called Flights, whose scheme is as follows:
Flights (fid, year, month_id, day_of_month, day_of_week_id, carrier_id, flight_num, origin_city, origin_state, dest_city, dest_state, departure_delay, taxi_out, arrival_delay, canceled, actual_time, distance)
Suppose that the following table has been created successfully (so you don't need to worry about creating the table but just focus on writing the queries. However, you probably need to pay attention to the data type defined for each attribute):
CREATE TABLE Flights (
fid integer PRIMARY KEY,
year varchar(4),
month_id integer,
day_of_month integer,
day_of_week_id integer,
carrier_id varchar(10),
flight_num integer,
origin_city varchar(30),
origin_state varchar(20),
dest_city varchar(30),
dest_state varchar(20),
departure_delay integer,
taxi_out integer,
arrival_delay integer,
canceled integer,
actual_time integer,
distance integer
);
Query 1: List all cities that cannot be reached from Seattle though a direct flight but can be reached with one stop (i.e., with two flights). Do not include Seattle as one of these destinations (even though you could get back with two flights). Order results alphabetically.
Query 2: List all cities that cannot be reached from Seattle though a direct flight nor with one stop (i.e., with two flights). Do not forget to consider all cities that appear in a flight as an origin_city. Order results alphabetically.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
