Relational Database Design; Embedded and Form Interfaces to Databases COSC 3480 Lab5

Last updated: November 14, 2005 Project # 5 (total score =320) Lab.# 5a (total score =80, Draft Report due Mo., Nov. 14 (electronic submission) The task is to design a relational flight reservation database; this database will be used in Lab5b to develop SQL-form/PRO*C/C# interfaces to query and update the designed database. The database to be designed has to satisfy the following information requirements: Customers that are characterized by ssn (unique), name, and address make reservations for flight connections. In this application, flight connections are limited to using (legs of) at most 2 different flights. Each flight is characterized by a unique flight number and can have up to 4 legs; each leg represents a direct connection from one airport to another airport and is characterized by a start time and arrival time. A maximum number of seats is associated with a flight, and for each leg of a flight is has to be known how many seats are currently available. Moreover, a price is associated with a flight connection. Flight connections as well as legs of flights must be connected (e.g. flying from A to B and then from C to E is not a flight connection, whereas flying from A to B and then from B to C is). Moreover, temporal constraints must hold with respect to flight connections and with respect to legs of a flight in that the arrival time has to be at least 5 minutes before the departure time of the next leg of the flight or flight connection. Customers typically request to go from city A to city B and want to find all connections that are available from city A to city and their price. The price of a flight is computed as follows: a price (in dollar) is associated with each leg of a flight; the price of a flight connection is computed by adding the prices of the legs of the flight connection; however, connections that involve 3 legs are discounted by 20%, connections that involve 4 legs are discounted by 35%, and connection that involve five or more legs are discounted by 50%. To simplify the project we are only interested in reservations for a single day, and times displayed refer to Houston time. If a customer requests a reservation for a flight connection either all legs of that connection are reserved or the request is rejected, if there is at least one leg for which no space is available. Moreover, a unique reservation number is associated with the successful reservation of a customer. Remark: You are allowed to define additional attributes for the database to facilitate programming (e.g. sequence numbers).

Project5a Tasks include: 1. Design an E/R Schema for the flight reservation database 2. Map the E/R Schema to a “good” relational schema 3. Create tables for the relational schema and fill it (preferably using the Oracle Bulk Loader (http://www- db.stanford.edu/~ullman/fcdb/oracle/or-load.html)) with useful data including all the flights and reservations that can be found on the last page of this document. 4. Write a small program that asks the user to input a start city and an end-city and returns all connections going from city1 to city2 having to change the aircraft at most once (even connections that involve booked legs of flights should be included in your answer).

Deliverables: Submit a draft report at the due date that explains the E/R diagram you designed and how the relational schema was obtained. Moreover, also briefly explain your approach to solve task4. Relational Database Design; Embedded and Form Interfaces to Databases COSC 3480 Lab5 Lab.# 5b (total score =240, Report due: We., Nov. 30, 10a, electronic submission; bring hardcopy of report to demo; program demos on Th., December 1, 2005, 8:30-11:30a) The goal of this project is to define a “user friendly”, interactive application program front end to the flight reservation database using PRO*C and Oracle forms (alternatively you can use C# or the JDBC Java interface with Oracle forms or Oracle web-interfaces, but using any of these interfaces will not be discussed in the lab; students that use the web interface successfully will receive extra credit). In summary, the interface you develop uses C/C++, embedded SQL and one of the many form tools Oracles provides. Moreover, your interface should check consistency constraints to avoid erroneous updates of the database, and provide error handling capabilities in the case of an incorrect update. The program that you develop operates on the database you created eaerlier and provides interactive support for the following 8 activities: 1. Insert a new flight (flights are limited to at most 3 stops (4 legs)) 2. List all flights that descent from a given city giving the flight number, the departure time and the cities served with arrival time; also indicate which legs of the flight are booked. 3. Insert a new customer 4. List all available1 connections (with at most 1 plane change) between city1 and city2 and their associated price 5. Select a displayed connection and reserve the associated legs (flights) of that connection 6. List all reservations of a customer; support cancellation of a listed reservation 7. Remove a flight from the database using its flight number 8. Terminate Session (should also remove all tuples from the database)

Before the user chooses one (or several) of the 8 activities from your user-interface, your program should load the database you created in Project 5a.

In general, this project is defined more openly (you have more freedom in deciding how to solve a particular problem), and might require some reading and trial-and-error on your own. Moreover, if you like to use other features of ORACLE for this project, feel free to ask for a permission to do so. You should also be prepared to demo your system shortly after the due date.

Hints: Before implementing particular queries in your embedded SQL program, it might be a good idea to test those queries using SQL*PLUS with the database you created in the previous project. Moreover, center on getting the PRO*C/C# part running first (approx. 140-150 points are allocated for this part), and then provide a “simple” or a “very fancy” user interface to your program, depending on how much time you have left. Moreover, add capabilities to your program to check integrity constraints with respect to updates of the database; provide exception handlers that raise exceptions in the case that an update of the database is incorrect. Focus on updates that are performed on the user interface that you designed earlier. Also if you have problems completing the project, make sure that your program solves at least some subtasks correctly, in which case you will get credit for those subtasks. Programs that are not running at all will receive a very low score.

Submission guidelines and deliverables: Submit a report that addresses the following: 1. E/R diagram and changes made to project#5a E/R with explanation. 2. Relational Schema and changes made to the project#5 schema with brief explanation. 3. Explain how flight 24 is represented in your database and how reservation of customer ‘222222222’ is represented in your database. 4. Code with explanation for project5a task 4. 5. Explanation on how your implementation solves project5b task 4. 6. Explanation on how your implementation solves project 5b task 5 7. Explanation on how reservations are managed by your program including deletion of reservation. 8. How does you program handle incorrect updates of the database; what kind of error handling / constraint checking capabilities does your program provide? 1 A connection is not available, if at least one leg of the connection is booked or if the departure time of a leg is not 5 or more minutes later than the arrival time of the previous leg. Relational Database Design; Embedded and Form Interfaces to Databases COSC 3480 Lab5

9. Brief description of the capabilities of your user interface 10. Mention anything additional or interesting about your program that has not been discussed yet (optional) 11. Mention any specific part of the project for which you believe that your program solves this task efficiently or “elegantly” (optional) 12. As appendix include a printout of the database and the source code. Relational Database Design; Embedded and Form Interfaces to Databases COSC 3480 Lab5

Useful Links for the Project5: http://www-db.stanford.edu/~ullman/fcdb/oracle/or-proc.html (Introduction to PRO*C Embedded SQL) http://www-db.stanford.edu/~ullman/fcdb/oracle/or-jdbc.html (Introduction to JDBC) http://www-db.stanford.edu/~ullman/fcdb/oracle/or-web.html (Web Database Programming with CGI and Java Servlets) http://www.cs.uh.edu/~ceick/3480/Oracle_Data_Block_Forms.pdf (Oracle Data Block Forms) http://www.cs.uh.edu/~ceick/3480/Customized_Oracle_Forms.pdf (Customized Data Block Forms) Relational Database Design; Embedded and Form Interfaces to Databases COSC 3480 Lab5 Database Contents for Project 5

The database you design should contain information relating to the 8 flights and 3 reservations, listed below (add information that is missing, e.g. name and address of customers). Additionally, the database you created in Project 5 should contain at least 2 more customers with ssn’s 44444444, and 555555555. However, do not include any additional flights or flight reservations in your database.

Sample Flight Information:

Flight 11 New Orleans 3:30a-4:15a Houston 1 seat $40 Flight 24 Dallas 4:30a -5:20a Houston 5:35a-7:20a El Paso 7:35a-8:35a Las Vegas 1 seat; $40-$90-$60 Flight 25 Houston 4:40a-5:10a Dallas 5:20a-7:05a El Paso 7:15a-8:20a Phoenix 9:25a-10:45a Los Angeles 2 seats $40-$60-$60-$40 Flight 27 Dallas 7:00a- 9:50a El Paso 1 seat; $180 Flight 29 Houston 5:40a- 7:40a El Paso 7:55a- 8:35a Phoenix 3 seats; $90-$40 Flight 32 El Paso 10:10a-11:05a Phoenix-11:20a- 12:25p Los Angeles 1 seat; $60-$60 Flight 34 New Orleans 7:20a-8:20a Houston 8:35a-10:20a El Paso 10:40a-11:40a Las Vegas 11:55a-12:45p Los Angeles 2 seats; $40-$90-$60-$60 Flight 86 Houston 11:00a-1:15p Las Vegas 1:30p-2:25p Los Angeles 3 seats; $170-$30 Flight 88 Houston 12:35p-4:15p Los Angeles 3 seats; $240 Flight 99 Las Vegas 8:30p-9:30p El Paso 9:55p-11:25p Houston 2 seats; $60-$90

Sample Reservation Information:

A costumer with ssn 111111111 has a reservation for flight 34 going from Houston to Las Vegas A costumer with ssn 222222222 has a reservation flying Dallas-Phoenix using flight 24 from Dallas to Houston and using flight 29 to go from Houston to Phoenix. The costumer with ssn 111111111 has another reservation going home that day (flying Las Vegas-Houston) on flight 99. The costumer with ssn 333333333 has a reservation flying from New Orleans going to Los Angeles using flight 11 from New Orleans to Houston and flight 25 from Houston to Los Angeles