03 database project ‘05 - uvabackground of the project, the context and the requirements will be...

23
DATABASE PROJECT ‘05 MAGNIFICO TRAVELS Nicole Archangel, Harmen Hofstra, Sander Kouwenhoven, Marian Moenadi, Lotte de Rooij University of Amsterdam, Faculty of Science {Nicole.Archangel, Harmen.Hofstra, Sander.Kouwenhoven, MarianMoenadi, Lisse-Lotte.de Rooij}@student.uva.nl For this project a travel agency database and graphical user interface (GUI) has been developed. The project started off with the rough idea that a travel agency database had to be created. How the database would function and how it would look like (the conceptual logical, the physical and the usage design) was up to the developers. The first step was to create an Entity Relationship Diagram (ERD), from which a database and a GUI would be developed. First the functional requirements for the database were discussed. The main criterion was that the travel agency should be able to offer flexible packages to its customers. A flexible package gives a customer the opportunity to put together a vacation anyway the customer pleases. The next step was the development of the ERD and from there on the development of the database and the GUI. Along the way several new possibilities for the database and the GUI were encountered. This meant changing the ERD. This was a process of iterations which still has not ended. This process and the results will be discussed in detail in this document. 1. INTRODUCTION Magnifico Travels is a travel agency that offers its customers a full service for their vacation. The system is created to provide a full range of possibilities for the customers of Magnifico Travels. A Magnifico Travels clerk should be able to book vacation packages for one or groups of customers in the Magnifico Travels system. Customers should be able to choose freely how to travel, where to stay and what to do. Of course the system is capable of offering the customers all the options they prefer, like a broad selection of accommodations and activities. To be able to give the best service, the clerks must be able to interact with the system easily. It is important to fulfill the wishes of customers, without interference of problems occurring with the system. This is why the system is designed for easy interaction. System errors are made are explicit for the clerk, so that the clerk can 03

Upload: others

Post on 27-Jan-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

DATABASE PROJECT ‘05 MAGNIFICO TRAVELS

Nicole Archangel, Harmen Hofstra, Sander Kouwenhoven, Marian Moenadi,

Lotte de Rooij

University of Amsterdam, Faculty of Science {Nicole.Archangel, Harmen.Hofstra, Sander.Kouwenhoven, MarianMoenadi, Lisse-Lotte.de

Rooij}@student.uva.nl

For this project a travel agency database and graphical user interface (GUI) has been developed. The project started off with the rough idea that a travel agency database had to be created. How the database would function and how it would look like (the conceptual logical, the physical and the usage design) was up to the developers. The first step was to create an Entity Relationship Diagram (ERD), from which a database and a GUI would be developed. First the functional requirements for the database were discussed. The main criterion was that the travel agency should be able to offer flexible packages to its customers. A flexible package gives a customer the opportunity to put together a vacation anyway the customer pleases. The next step was the development of the ERD and from there on the development of the database and the GUI. Along the way several new possibilities for the database and the GUI were encountered. This meant changing the ERD. This was a process of iterations which still has not ended. This process and the results will be discussed in detail in this document.

1. INTRODUCTION Magnifico Travels is a travel agency that offers its customers a full service for their vacation. The system is created to provide a full range of possibilities for the customers of Magnifico Travels. A Magnifico Travels clerk should be able to book vacation packages for one or groups of customers in the Magnifico Travels system. Customers should be able to choose freely how to travel, where to stay and what to do. Of course the system is capable of offering the customers all the options they prefer, like a broad selection of accommodations and activities. To be able to give the best service, the clerks must be able to interact with the system easily. It is important to fulfill the wishes of customers, without interference of problems occurring with the system. This is why the system is designed for easy interaction. System errors are made are explicit for the clerk, so that the clerk can

03

Page 2: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

2

understand what has gone wrong. A lot of attention has been paid to the look and feel of the system, so working with the system feels natural and nice. In this document the process of development of the system is explained. Firstly, the background of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas and the undertaken steps. Thirdly, the final ERD and database schema, as well as the GUI outline, are presented in the presentation of the program. Then the end results will be shown, followed by a scenario through the system, to show all of its functionalities. Finally, some conclusions about the project will be given 2. BACKGROUND OF THE PROJECT Overview of the travel agency database application: Database server is a computer responsible for database storage access and processing, constituting a 2-tier client/server architecture. Two tier communication of the client and the database a direct connection with small data, which do not use a lot of space. The connection with the database is a direct connection, which improves the connectivity and reduces the chance of faults. In the travel agency, the database application (see fig.1) will consist of several levels. The lowest level in the application is the holiday package database, which will contain all the tables and information in the database. On top of the database there is the application itself which is the JDBC language, which communicates with the database and performs basic functionalities. The top layer of the application is the GUI (graphical user interface) this is for the user and built on top of the application. The GUI enables the clerk and the manager to interact with the database on more interactive matter but using a simple interface.

Page 3: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

3

Figure 1 – Travel agency database application

To make the travel agency application we start by choosing a data model. Then we will use the data model to translate the requirements into a DB schema. After this, we will then choose the DBMS using the model we designed for our travel agency. The next step is then to Design the storage (physical) structure considering the DB requirements and implement the physical structure using the DBMS. Designing the access constraints / facilities considering the DB requirements (e.g. views / access rights / constraints, etc.) and implement the usage facilities are the last steps that take place. Validation & modification are the very last steps in the application development in which the DB administration will ensure that the database is kept up to date.

Page 4: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

4

Figure 2 – Standard (ANSI/SPARC) 3-level Architecture for a DBMS

User Interface Design is a complicated process, which includes aspects from software engineering, aesthetics, ergonomics, psychology etc. The conceptual level design involves analyzing users’ needs in terms of the activities that need to be accomplished using a system and the objects and operations, which a user has to employ to accomplish the tasks. The physical level design concerns embedding the conceptual model of the system in a physical structure. The GUI graphical user interface is based on the JDBC java language. The GUI is built on top of the database and through JDBC you can access and manipulate the SQL database to perform different functionalities. The GUI is the physical level where the conceptual database model of a system is transferred into a physical structure. The different operations and object activities, which have to be performed by the user in the conceptual mode on interfaces. These interfaces help to automatically enter data into the database. The GUI is also where the look and feel of the interface will be defined. JDBC is linked with the conceptual level of an application using the Java API for communicating with database systems supporting SQL. With JDBC you can do a variety of functionalities like in our case: ask queries, add data, see a list, update a list and delete data and JDBC also supports metadata retrieval, such as querying about relations present in the database and the names and types of relation attributes. JDBC uses a really simple connection model, which consists of: opening a connection, creating a “statement” object, executing queries using the Statement object to send queries and fetch results and exception mechanism to handle errors.

Page 5: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

5

3. DISCRIPTION OF WORK The process of developing and implementing a travel agency consists of several steps; 1. Database Design and Development; 2. Database GUI Design; 3. Database User Interface Development; The first step, Database Design and Development, is coming up with an idea of how the travel agency should look like. In this phase it is all about design at the conceptual level and this includes the development of the ERD and the development of the diagrams which have been done in MySql. The database application has the capability to store, search and retrieve information related to holiday packages. On conceptual level, the purpose of the travel agency is to offer different options, which can be chosen by a customer and made into a complete holiday package. These options are the entities used in the ERD: • Transportation including type and number • Stay (hotel choice) including type • Location including name and number • Group including: name, number • Activities including name, number and description • Customer including: name, number, address, telephone number, zip code and • Package including name and number • Amenities including name and number All of the entities in the ERD database are optional except for the location, which is obligatory in every package. With this in mind, a rough sketch was first made of how the ERD would look like.( See for the end ERD the results page.) Development of the database, the logical design, was done using the data definition language (DDL) MySql which is also a data manipulation language. Every entity is inserted into the database which is represented in the ERD and related to customers, transportation etc. The database GUI Design, is used by the clerk and the manager of the travel agency. This means that they have to be able to perform certain basic functionalities with the data. The functionalities add, update, delete, list, clear and search. This enables the user to find data and insert new data. A JDBC application was used to perform error checking and to insert data into the database. The Database, User Interface Development, is more at the physical level of the design in which was decided how the actual design would look like for the user. This is what the user will work with.

Page 6: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

6

4. PRESENTATION OF THE APPLICATIONREFERENCES The GUI uses different commands to communicate with the database. The action interface defines required methods for the Java Swing implementation for the command design pattern. The command design pattern enables designers to define a functionality which is reusable class and works on the command of the user. This class can then be used in buttons, menu items, context menu items, and so on. Behavior includes the text in the label, the enabled or disabled state, and the code that is executed when the button, for example, is pushed. The Action UI (user interface) class in the package extends Swing's AbstractAction class. It implements the Command design pattern through several execute methods that are called when the button is pushed. The functionalities and their listeners will be explained by introducing the java code that was used in the Magnifico travels interface. For every entity an abstract class was designed, because the functionalities of the entities were basically the same and were inherited from one abstract class. In this example the amenities code is used to show how the swing action options work. The basic functionalities used are: Create, add, delete, previous, next and clear.

This part of the code shows the creation of the functionality button components

showAction(); } public Component createComponents() { creation of the texfield to add text into the database

int textfieldLength = 20; String[] strSearchColumnsLabels = {"Amenity ID","Name"}; tfID = new JTextField(textfieldLength); tfID.setEditable(false ); tfName = new JTextField(textfieldLength); cbSearch = new JComboBox(strSearchColumnsLabels); cbSearch.addActionListener(this); JLabel lBeginsWith = new JLabel(" begins with:"); tfBeginsWith = new JTextField(20); tfBeginsWith.addActionListener(this); }

Page 7: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

7

In this part of code all the action commands of the functionalities are shown.

public void actionPerformed(ActionEvent e) { if(e.getActionCommand().toString() == "Update") editAction(); else if(e.getActionCommand().toString() == "Create") createAction(); else if(e.getActionCommand().toString() == "Delete") deleteAction(); else if(e.getActionCommand().toString() == "Clear") clearAction(); else if(e.getActionCommand().toString() == "Previous") previousAction(); else if(e.getActionCommand().toString() == "Next") showAction(); else if(e.getSource() == tfBeginsWith) searchAction(); else if(e.getSource() == cbSearch) searchAction(); else System.out.println("Not found: "+ e.getSource()); }

This part of code shows the search function .with it’s error message when no result is found

private void searchAction() {

try { showAction(amenity.search(strSearchColumns[cbSearch.getSelectedIndex()],tfBeginsWith.getText()));

} catch (SQLException e) { if(!e.getMessage().equals("No results found")) e.printStackTrace(); else lMessage.setForeground(Color.RED); lMessage.setText("No results found"); return; } lMessage.setText(""); }

Page 8: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

8

This part of code shows the clear function private void clearAction() { tfName.setText(""); tfID.setText(""); tfBeginsWith.setText(""); }

This is the show for the next function so you can see the results depending on whether you search on name or ID.

private void showAction() { try {

showAction(amenity.getNext(strSearchColumns[cbSearch.getSelectedIndex()],Amenity_id));

} catch (SQLException e) { e.printStackTrace(); } } private void showAction(String inAmenity_id) { try { ResultSet rs = amenity.getInfo(inAmenity_id); Amenity_id = inAmenity_id; if(rs.next()) { tfID.setText(rs.getString("Amenity_ID")); tfName.setText(rs.getString("A_name")); } else { showAction(); } } catch (SQLException e) { e.printStackTrace(); } }

Page 9: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

9

This part of code shows the previous function to go back while browsing the available information.

private void previousAction() { try {

showAction(amenity.getPrevious(strSearchColumns[cbSearch.getSelectedIndex()],Amenity_id));

} catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }

This part of code does error checking on unique identifiers private boolean checkInput() { if(amenity.isUnique("A_name",tfName.getText()) > 0) { lMessage.setText("The chosen Amenity name already exists"); lMessage.setForeground(Color.RED); return false; } return true; }

This part of code shows the edit function to edit information into the database

private void editAction() { boolean success = true; if(!checkInput()) return; try { String[] inValues = {tfName.getText()}; amenity.update(tfID.getText(),inValues); } catch (SQLException e) { lMessage.setText("Error updating Amenity"); lMessage.setForeground(Color.RED); e.printStackTrace(); success = false; } if(success) { lMessage.setText("Amenity updated");

Page 10: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

10

lMessage.setForeground(Color.BLUE); } }

This part of code shows the delete function to delete entered data from the database.

private void deleteAction() { Object[] options = {"Yes", "No"}; int n = JOptionPane.showOptionDialog(this, "Are you sure you wish to delete this Amenity from the system?", "Confirm Amenity removal", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, //don't use a custom Icon options, //the titles of buttons options[0]); //default button title if(n == 1) return; boolean success = true; try { amenity.delete(tfID.getText()); } catch (SQLException e) { lMessage.setText("Error deleting Amenity"); lMessage.setForeground(Color.RED); e.printStackTrace(); success = false; } if(success) { lMessage.setText("Amenity deleted"); lMessage.setForeground(Color.BLUE); } showAction(); }

Page 11: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

11

This part of code shows the create function to create entered data from the database.

Private void createAction() { if(!checkInput()) return; boolean success = true; try { String[] inValues = {tfName.getText()}; amenity.create(inValues); } catch (SQLException e) { lMessage.setText("Error creating Amenity"); lMessage.setForeground(Color.RED); e.printStackTrace(); success = false; } if(success) { lMessage.setText("Amenity created"); lMessage.setForeground(Color.BLUE); } } }

Page 12: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

12

5. RESULTS

Figure 3 – ER diagram

Page 13: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

13

The following code creates the GUI look and feel for the interface in combination with the former code of Amenities in combination with this final code the look and feel is created. private void createAndShowGUI() { //Set the look and feel. initLookAndFeel(); //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); Component contents = this.createComponents(); this.getContentPane().add(contents, BorderLayout.CENTER); //Image img = Toolkit.getDefaultToolkit().getIcon("users1.gif"); this.setFrameIcon( new ImageIcon("images/amenities.png"));

Figure 4 –

Page 14: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

14

The above image (see Fig.4) is the main user interface representing the portal to a vacation. The different icons (see Fig.5) represent the entities which have been used in the ER-diagram (see page 12). The icons can be invoked by clicking once on them. Data can be manipulated by inserting, drag and drop and also with he buttons create, delete, update, previous, next and clear for every entity (see Fig 6). Fig 7 is an example of the drag and drop function. The kind of accommodation can be dragged and dropt into the accommodation time line.

Figure 5 – Figure 6 –

Page 15: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

15

Figure 7 –

Page 16: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

16

6. SCENARIO DESCRIPTION Here follows the description of a typical scenario for booking a package with Magnifico travel agency. A customer wants to go on vacation and comes by the travel agency to book a package, which he puts together with help from the agency clerk.

Figure 8 – Main Interface The clerk opens the travel form and asks the customer on what date he wants to leave and for how many days he plans to go on vacation. The clerk inserts a date and the amount of days the customer is planning to go on vacation, according to the customers wishes.

Figure 9 – Travel Planner

Page 17: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

17

The clerk then searches together with the customer the location according to the selected minimum and maximum price the customer is willing to pay. After selecting the location, the customer wants to go. The clerk then gives the customer information about the different hotels and bungalows he can choose from depending on the location the customer chooses.

Figure 10 – Accommodation

Page 18: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

18

If the customer desires more information about a certain type of accommodation the clerk can give him information more detailed by clicking on the accommodations icons on the main interface. He can then find more information about the accommodation form the customer wants to choose whether it is hotel, camping or a bungalow.

Figure 11 – Information Accommodation

Page 19: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

19

The clerk then clicks on the type of accommodation the customer has chosen, drags, and drops this into the travel planner timeline. Then the clerk inserts the amount of days the customer is planning to stay in that location, if the customer pleases to go to several locations during the time he is on vacation he also has the possibility to do this. If he chooses to stay in only one location the entire time, he also has the option to do this.

Figure 12– Drag and drop type and duration

After choosing the location and amount of days, the customer wants to go on vacation; he can then choose the way he wants to travel to the location. He can choose to travel by boat, train, plain, bus or car.

Page 20: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

20

Figure 13– Choose Transportation

Figure 14 – Package with name

Page 21: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

21

After choosing the desired location and way of travel, the clerk then gives the package a name and saves the package. The clerk then fills all the information of the customer in the customer form giving the customer his own unique number. The customer can also choose to go with a group of people on vacation. A group form can also be chosen, each group can consist of several people and one person who is the main booker. In a group, each person can have his own way of travel and place of accommodation. After saving all the information, the customer has his own number linked to his own unique package.

Figure 15 –

Page 22: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

PROJECT DATABASE MAGNIFICO TRAVELS

22

7. CONCLUSION The process of development of the database and the GUI in a four week long project has had its ups and downs. The first step in the process, the development of conceptual and logical design (the requirements and the ERD) went very well. There were a lot of positive discussions and through good cooperation the requirements, the initial ERD and the overall conceptual idea of the database and GUI were acquired. The man criterion was the flexibility of packages. This was kept in mind throughout the development. The next step was the creation of the physical database. Here the first iterations in the design of the ERD took place. It was decided to first create the tables of the database that would provide the minimal functionality for the system. These were the tables customer, location, stay, transportation and package. These entities and their relations would give the minimal functionality for the system. After the creation of the database and adding some data into it, the usage design began. For every entity an abstract class was designed, because the functionalities of the entities were basically the same and could be inherited from one abstract class. The basic functionalities were adding, updating and deleting. Later on finding ‘previous’ and ‘next’ and ‘clearing’ were added. In this stage of the project some problems occurred with the database and the Java code. The usage of prepared statements in Java gave some problems with the database interaction. The problems were fixed and after a few days the project was back on track. Since there was still time it was possible to add some extra features to the system. This meant once again changing the ERD and changing the database. The system was extended with the possibility for groups to book packages, a number of accommodations, adding amenities to accommodations and the possibility to book activities. This also meant a lot of more work for the GUI design, but by using abstract classes, the amount of work was lessened. What still is missing and which could be further developed in the future is the possibility of adding customers to groups by dragging and dropping the names in the group box. Each group would then show all the customers which are part of a group also a checkbox could have been added which then would show the main booker, the person who will be paying and should be contacted about the payment. Finally the look and feel of the system was optimized. The interface was made user friendly by giving the users the ability to drag and drop entities to create a package. The end results of the project suffice the requirements and more.

Page 23: 03 DATABASE PROJECT ‘05 - UvAbackground of the project, the context and the requirements will be discussed. Secondly, the description of work will be given, meaning the project ideas

Project Database Magnifico Travels

23

8. ACKNOWLEDGEMENTS This has been an enormous project that would not have been possible without the guidance and assistance of university professors and instructors Dr. Irina Neaga, Dr. Hamideh Afsarmanesh and assistants Gerben de Vries and Reinier Zevenhuijzen. Special thanks goes out to these people. 9. REFERENCES 1. http://staff.science.uva.nl/~netpeer/teaching/db-ik-2005/. Project Database 2005 2.Deitel H.M., Deitel P.J.. Java, How to program, fourth edition. Prentice Hall Inc., New Jersey

2002,1999,1997, 1995 3.Silberschatz A., Korth H.F., Sudarshan S. Database System Consepts. Mc Graw Hill companies, Inc.,

NY 2002, 1999, 1991, 1986.