The document contains SQL code to create four database tables: Carriers, Aircraft, Airports, and Flights. It then provides sample data to populate these tables with records about airlines, planes, airports, and flight details.
here is the SQL. PLEASE ONLY START FROM # 6 TO #10 AS I DID #1 TO #5.docx
1. here is the SQL. PLEASE ONLY START FROM # 6 TO #10 AS
I DID #1 TO #5
# Code to create Airlines_2175 database for DATA 620
# Contains updated data line as follows:
# Updated 5/17/2017 by Carrie Beam (rolled forward to 2017)
Drop Database if exists airlines;
CREATE DATABASE Airlines;
USE Airlines;
# USE Airlines ; # this is the old one also
-- A carrier is a commercial company offering flights to the
public
CREATE TABLE Carriers (
Carrier_ID INTEGER PRIMARY KEY AUTO_INCREMENT,
Carrier_Name VARCHAR(20)
);
2. -- One carrier can fly many types of aircraft
CREATE TABLE Aircraft (
Plane_ID INTEGER PRIMARY KEY AUTO_INCREMENT,
Manufacturer VARCHAR(10),
Model_Num VARCHAR(20),
Original_Purchase_Date DATE,
Last_Service DATE,
Carrier_ID INTEGER,
Number_of_Seats INTEGER,
FOREIGN KEY (Carrier_ID) REFERENCES
Carriers(Carrier_ID)
);
-- One airport facilitates many flights
CREATE TABLE Airports (
Airport_Code VARCHAR(3) PRIMARY KEY,
Airport_Location VARCHAR(25),
22. Alter Table Flights drop column Carrier_ID;
-- Append Update section to populate number of seats column in
aircraft table
Update airlines.aircraft set number_of_seats=500 where
plane_id in (1,3,5,7,11);
Update airlines.aircraft set number_of_seats=100 where
plane_id in (12,13,14,15);
Update airlines.aircraft set number_of_seats=250 where
plane_id in (2,4,6,8,10);
Update airlines.aircraft set number_of_seats=550 where
plane_id in (16,18,20,22);
Update airlines.aircraft set number_of_seats=300 where
plane_id in (17,19,21,23);
Update airlines.aircraft set number_of_seats=400 where
plane_id in (24,25,26,27);