讲解:22C:4400、database、SQL、SQLProlog|Haskell

Group 722C:4400April 2, 2019Project Plan v3Functions list:1. Book Flight - Round Trip ; Book Flight - 1 way ; Book Flight - Multi City , Flight Statusa. Methods Overview:Given the inputs of date of departure and date of return from the user, lookat flight table and first query by departure date. This information must firstbe served to the user, who makes a choice for the departure flight, thenallow the user to pick the return flight. For testing, we will populate ourdatabase with test information in several tables, and add data as furthertesting of the system is needed.i. Query 1 Find flights:When the user queries the system to find a flight that matches theirneeds, we use a process of refinement to help them find the perfectflight. If multiple criteria are specified, then we pose all of thosecriteria to the server, which forms intelligent queries for thedatabase.1. First, we select all flights where the departure date, departurelocation, and arrival location criteria are met. All flight types rely onthis first query.Input: departure date (datetime), departure location (varchar),arrival location (varchar)Output: All matching flight recordsSQL: SELECT * FROM Flights WHERE DepartureDate = {user’schosen departure date, formatted} AND DepartureLocation = {user’schosen departure location, formatted};2. Next, if we want a round trip or multi-city trip, we make additionalqueries as enumerated below:a. Round Trip: find all flights with an arrival date equal to theuser’s specified return date, with an arrival location equal totheir original departure location, and with a departurelocation equal to their original arrival location.Input: return date (datetime)Output: All matching flight recordsSQL: SELECT * FROM Flights WHERE ArrivalDate = {returndate} AND ArrivalLocation = {original departure location}AND DepartureLocation = {original arrival location};a. Multi-city: find all flights where the arrival destination isequal to the user’s specified destination, where the departuredate is equal to the user’s specified departure date, andwhere the departure destination is equal to the previousflight’s arrival location..Input: departure date (datetime), arrival date (datetime),departure location (varchar), arrival location (varchar)Output: success / failureSQL: SELECT * FROM Flights WHERE Departure = {user’schosen departure date, formatted} AND Airport = {user’schosen departure location, formatted};ii. Query 2 Book a flight (create booking):For each flight that the customer boards, they will have an individualbooking. Tickets can have multiple flight bookings, such asround-trip flights or multi-city flights.Input: FlightID (int), PassengerID (int), BaggageID (int), Price (float),Seat (varchar), Class (varchar)Output: Success / failureSQL: INSERT INTO Bookings VALUES (FlightID, BaggageID, Price,Seat, Class);iii. Query 3 Remove bookingInput: BookingID (int), FlightID (int)Output: success / failureSQL: DELETE FROM Tickets WHERE BookingID = {user’s booking #}AND FlightID = {user’s flight #};iv. Query 4 Update bookings on a ticketInput: BookingID (int), update fieldOutput: Success/failureSQL: UPDATE Booking SET {field} = {new value} WHERE BookingID= {booking ID};2. Aircrafta. Createi. Input: Type of Aircraft (varchar), Number of First Class Seats (int), Numberof Economy Seats (int), Vin Number (varchar)ii. Output: Success or Failureiii. SQL: INSERT INTO Airplanes VALUES ({VIN}, {class A capacity number}, …,{class D capacity number}, {model});b. Updatei. Input: Type of Aircraft (varchar), Number of First Class Seats (int), Numberof Economy Seats (int)ii. Output: Success or Failureiii. SQL: UPDATE Airplanes SET {class A capacity number} = {new value}, …,{class D capacity number} = {new value}, {model} = {new value}) WHEREVIN = {plane’s VIN #};c. Readi. Input: Vin Numberii. Output: Type of Aircraft (varchar), Number of First Class Seats (int),Number of Economy Seats (int)iii. SQL: SELECT * FROM Airplanes WHERE VIN = {vin #};d. Deletei. Input: Vin Number (varchar)ii. Output: Success or Failureiii. SQL: DELETE FROM Airplanes WHERE VIN = {vin #};3. Flighta. Createi. Input: Date of Departure (datetime), Date of Return (datetime), Gate(varchar), Terminal (varchar), Aircraft Vin (varchar)ii. Output: 代写22C:4400作业、代做database留学生作业、SQL编程语言作业代写、代做SQL实验作业 代写留学生ProlFlight Numberiii. SQL: INSERT INTO Flights VALUES ({departure date}, {return date}, {gate},{terminal}, {aircraft VIN #});b. Updatei. Input: Flight Number (int), Changes to be made (various)ii. Output: Success or Failure Updatingiii. SQL: UPDATE Flights SET {corresponding columns} = {correspondingvalues};c. Readi. Input: Flight Number (int)ii. Output: Available First Class Seats (int), Available Economy Seats (int), Gate(varchar), Terminal (varchar), Type of Aircraft (varchar), Date of Departureand Return (datetimes)iii. SQL: SELECT * FROM Flights WHERE FlightID = {flight ID #};d. Deletei. Input: Flight Number (int)ii. Output: Success or Failureiii. SQL: DELETE FROM Flights WHERE FlightNo = {flight ID #};4. Advantage Accounta. Createi. Input: Username (varchar), Password (varchar), First Name (varchar), LastName (varchar), Email (varchar), Registration Date (datetime)ii. Output: UserID (varchar), Success or Failureiii. SQL: INSERT INTO Accounts VALUES ({username}, {hashed password}, {firstname}, {last name}, {email address}, {registration date});b. Updatei. Input: Name (varchar), Password (varchar)ii. Output: Success or Failureiii. SQL: UPDATE Accounts SET {corresponding columns} = {correspondingvalues} WHERE UserID = {userID};c. Readi. Input: UserID (varchar)ii. Output: Username (varchar), Password (varchar), First Name (varchar),Last Name (varchar), Email (varchar), Registration Date (datetime)iii. SQL: SELECT * FROM Accounts WHERE UserID = {userID};d. Deletei. Input: Name (varchar), Password (varchar)ii. Output: Success or Failureiii. SQL: DELETE FROM Accounts WHERE UserID = {userID};5. Reserve Seat/Cancel Reservationa. Addi. Input: Flight Number (int), Seat Number (varchar), Ticket Number (int)ii. Output: Success or Failureiii. SQL: INSERT INTO Flightsb. Updatei. Input: Flight Number (int), Seat Number (varchar), Ticket Number (int)ii. Output: Success or Failureiii. SQL:c. Deletei. Input: Flight Number (int), Seat Number (varchar)ii. Output: Success or Failureiii. SQL:ER DiagramAccountThese are customers who have actually made an account on our website. There can be an accountfor a passenger, but passengers don’t require an account.PassengerJust the basic info so we know who’s flying on our planes. This info is referenced in the Booking.We also store an optional foreign key to an Account in case this is a customer who has signed up foran account with us. There’s a little redundancy here, but it’s the best way to do it if we don’t want torequire people to make an account with us.BaggageSimple baggage tags. These records don’t identify individual pieces of luggage used by thecustomer, but rather the total of their baggage weight.BookingThis is what gets ties a customer to a flight. One-way tickets have one booking, round-trip ticketshave two bookings, and multi-city tickets have multiple bookings. Flights can have as manybookings as they have seats.FlightThis decides who goes on what plane, where the plane is, the prices for different seats on the plane,etc.EmployeeAn airline employee, such as pilot, copilot, or flight attendant. We have a field to assign employeesto their next flight, but not any future flights beyond their next. Realistically, we would have thembooked for multiple flights in advance and have multiple fields here to convey as much.LocationEvery airport has a code (primary key) and the full name of the location, including the city, state,and country. We’re only doing domestic flights in this phase so the country is unnecessary, but it’sgood practice for future expansion.SeatChartThis is where the status of the flight’s occupancy is kept. We have a column for each for each row ofseating in the aircraft stored as a VARCHAR. The default value for each row is ‘ABCDEFGHJK’(skipped the I on purpose because that’s what real planes do). If all seats in a row are vacant, all ofthese letters will show in that row. If one of those seats is reserved, we remove that letter from thatrow, and that signifies to the server that it is not available anymore.AircraftWe use the aircraft’s VIN number as its ID, and keep the model, maker, etc., as well as the range ofrows that belong to each class. The class rows are stored as VARCHAR, so we can input values like“1-20” as our first class seating range.转自:http://www.7daixie.com/2019041423054317.html

你可能感兴趣的:(讲解:22C:4400、database、SQL、SQLProlog|Haskell)