Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft C# Professional Projects - Premier Press.pdf
Скачиваний:
177
Добавлен:
24.05.2014
Размер:
14.65 Mб
Скачать

PROJECT CASE STUDY AND DESIGN

Chapter 18

407

 

 

 

 

Total fare collected. Customers who have paid more than a certain amount as fare are also given discounts. The amount and the discount, in this case as well, are decided by the business manager.

The discount applicable to users is applied when they book a ticket on the airline.

Summarizing the Tasks

I have explained all the tasks that need to be performed by the airline. I will now sort each task by role, because this information is used for creating the form design.

The tasks of business managers are summarized as follows:

Add and remove flights

Request for user IDs

Generate reports

Manager frequent flier programs

The tasks of network administrators are summarized as follows:

Add and delete user accounts

Back up and archive databases

Examine Web server and database logs

The tasks of line-of-business executives are summarized as follows:

Create and cancel reservations

Query status of flights and tickets

Confirm tickets

The summarized tasks form the basis of the application. As you will see in the next section, the database structure and the application interface follow closely with the tasks summarized for each business executive.

Project Design

After having examined the requirements of the application in detail, you can now proceed with designing the application. In the project design stage, you identify the database tables and the relationships between them to finalize the database

408 Project 4 CREATING AN AIRLINE RESERVATION PORTAL

schema. It is critical to examine all the possible requirements and incorporate them in the database schema because reworking the design later means a lot of wasted effort. After you finalize the database schema, you can finalize interface of your application so that the development team has a framework on which it can work.

In this section, I examine the database schema of the SkyShark Airlines database

and the design of the forms. The design of the forms is the interface of the final application.

Database Design

 

 

Y

You arrive at the structure of the databaseLtables after creating the preliminary

structure of tables that match the application requirements and then normalizing

 

 

F

the structure to eliminate data redundancy. The process is explained in Chapter 7,

“Project Case Study,” in the section “Normalization.”

 

 

M

 

If you examine the businessArequirements stated previously, the first task per-

 

E

 

T

 

 

formed in the airline application is the creation of new user accounts. Therefore, I begin with explaining the structure of the dtUsers table, which will be used for storing the details of authorized users.Thereafter, I explain each table of the database as it is created.

The dtUsers Table

The dtUsers table has four columns.Three columns store the username, password, and role of the user, while the fourth one signifies whether or not the user has changed the password after logging on the first time.The structure of the dtUsers table is given in Table 18-1.

Table 18-1 Structure of the dtUsers Table

Column Name

Data Type

Length

Allow Nulls

Username

char

15

0

Password

char

15

0

Role

char

10

0

PasswordChanged

bit

1

1

 

 

 

 

Team-Fly®

PROJECT CASE STUDY AND DESIGN

Chapter 18

409

 

 

 

 

TIP

In the preceding table structure, the value 0 for Allow Nulls implies that it is mandatory for you to specify a value for the field when you add a new record. Similarly, the value 1 implies that the field is optional when you add a new record. For example, in the dtUsers table, the PasswordChanged field, which stores a Boolean value to specify whether or not the user has changed the password, is optional.

After network administrators create user IDs in the dtUsers table, business managers should specify flight details.

The dtFltDetails Table

The dtFltDetails table stores details of airline routes flown by the airline. The structure of the dtFltDetails table is given in Table 18-2.

Table 18-2 Structure of the dtFltDetails Table

Column Name

Data Type

Length

Allow Nulls

FltNo

char

10

0

Origin

text

16

0

Destination

text

16

0

Deptime

datetime

8

0

Arrtime

datetime

8

0

AircraftType

char

10

0

SeatsExec

int

4

0

SeatsBn

int

4

0

FareExec

int

4

0

FareBn

int

4

0

LaunchDate

datetime

8

0

 

 

 

 

410 Project 4 CREATING AN AIRLINE RESERVATION PORTAL

In the structure of the dtFltDetails table given in Table 18-2, I have added a LaunchDate field.The LaunchDate field is used to store the date on which the flight is launched. This information will be used to display details of newly launched flights on the Web site.

After flight details are added to the dtFltDetails table, line-of-business executives can make reservations on the airline. Therefore, I now move on to the table that is used for storing details of reservations, dtReservations.

The dtReservations Table

The dtReservations table is the most frequently used table of the database. The table is used to store details of passengers who have reserved a seat on the flight. The structure of the dtReservations table is given in Table 18-3.

Table 18-3 Structure of the dtReservations Table

Column Name

Data Type

Length

Allow Nulls

TicketNo

char

10

0

FltNo

char

10

0

DateOfJourney

datetime

8

0

ClassOfRes

char

4

0

Name

char

20

0

EMail

char

50

1

Fare

int

4

0

Status

int

4

0

ReservedBy

char

15

0

DateOfRes

datetime

8

0

TicketConfirmed

bit

1

1

 

 

 

 

In the dtReservations table, the TicketConfirmed and EMail fields allow null values. The TicketConfirmed field is updated when users confirm their ticket. The e-mail address, when specified by the passenger, is used for enabling the frequent flier program.

PROJECT CASE STUDY AND DESIGN

Chapter 18

411

 

 

 

 

TIP

To ensure privacy of data, only customers who specify their e-mail address can query their ticket status on the online portal of SkyShark Airlines.

As a result of a large number of flights flown by the airline, there will be a large amount of data in the dtReservations table. However, if you notice, you need to store details of passengers related to those flights that have departed only for the frequent flier programs. Therefore, a network administrator should ideally move the data related to departed flights to another table, which can be used for the frequent fliers program.This type of mechanism will have the following advantages:

Archiving database tables easily. Data that is ready for archiving is automatically moved to another table. Therefore, network administrators can archive database tables easily.

Improved performance. If you use a different database for storing data pertaining to flights that have departed, queries for analyzing data will be directed to the other database and the performance of the dtReserva-

tions table, which is critical to the online portal, will improve because redundant transactions are eliminated.

Easy access to data. For generating reports, business managers need not access dynamic data in the dtReservations table. Instead, they can use the other table to retrieve only the data that is pertinent to analysis.

To implement the logic that I have explained, I have created the dtDepartedFlights table, which follows next.

The dtDepartedFlights Table

The dtDepartedFlights table has exactly the same structure as the dtReservations table. Therefore, I do not replicate it here. You can look the structure up in Table 18-3. After a flight has departed, data pertaining to passengers who have flown the flight is moved to the dtDepartedFlights table. This data is used for generating reports and for enabling the frequent flier programs.

Having examined the tables related to flight details and reservations, you can examine the table for cancellations, dtCancellations.

412 Project 4 CREATING AN AIRLINE RESERVATION PORTAL

The dtCancellations Table

The dtCancellations table stores information related to tickets that have been cancelled. This information is required only for accountability of refunded fare and reservations. Therefore, if a passenger whose ticket has been cancelled informs the airline that the ticket should not have been cancelled, the details of the executive who processed the cancellation can be traced and the reasons of the cancellation can be determined. The structure of the dtCancellations table is given in Table 18-4.

Table 18-4 Structure of the dtCancellations Table

Column Name

Data Type

Length

Allow Nulls

TicketNo

char

10

0

Refund

int

4

0

ProcessedBy

char

15

0

CancellationDate

datetime

8

0

 

 

 

 

The dtCancellations table can be archived on a timely basis to ensure that no redundant data is stored in the database. I will now discuss the next important

table, dtFltStatus.

The dtFltStatus Table

When a passenger reserves a seat on an airline, the number of seats available for reservation should reduce by one. Similarly, if a flight is overbooked, excess passengers should be placed in queue. The updated status of a flight should be available to passengers when they reserve their seat.

To ensure that an updated status of a flight is always available, I have used the dtFltStatus table. As soon as the first ticket is booked on a flight, an entry for the flight is created in the dtFltStatus table.This table is updated as reservations and cancellations are made. The structure of the dtFltStatus table is given in Table 18-5.

dtPas-

 

PROJECT CASE STUDY AND DESIGN

Chapter 18

413

Table 18-5 Structure of the dtFltStatus Table

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Column Name

Data Type

Length

Allow Nulls

 

 

 

 

 

 

 

FltNo

char

10

0

 

 

 

StatusDate

datetime

8

0

 

 

 

StatusClass

char

10

0

 

 

 

Status

int

4

0

 

 

 

 

 

 

 

 

 

 

In the structure of the dtFltStatus table, the FltNo, StatusDate, and StatusClass

fields form a composite key. This implies that the three fields together form a unique combination that can be used to retrieve the status of a specific class of a flight on a specified date.

I will now examine the last two tables that are related to the frequent flier pro-

gram, dtPassengerDetails and dtFrequentFliers.

The dtPassengerDetails Table

To enable the frequent fliers program, the dtPassengerDetails table retrieves data

from the dtDepartedFlights table. The dtPassengerDetails table uses the e-mail

address of passengers to identify the number of times they have flown the airline and the total fare collected from them in these flights.The structure of the sengerDetails table is given in Table 18-6.

Table 18-6 Structure of the dtPassengerDetails Table

Column Name

Data Type

Length

Allow Nulls

EMail

char

50

0

FareCollected

int

4

0

TotalTimesFlown

int

4

0

 

 

 

 

Whenever a new frequent flier program is launched, data from the dtPassengerDetails table is used to determine how many passengers the program will impact. This data is used for enabling discounts to passengers. The discounts are specified in the dtFrequentFliers table.

414 Project 4 CREATING AN AIRLINE RESERVATION PORTAL

The dtFrequentFliers Table

The dtFrequentFliers table is used to specify the discount (expressed in percentage) applicable to customers. Just as in the dtPassengerDetails table, the passengers are identified by their e-mail address. The structure of the dtFrequentFliers table is given in Table 18-7.

Table 18-7 Structure of the dtFrequentFliers Table

Column Name

Data Type

Length

Allow Nulls

EMail

char

50

0

Discount

int

4

0

 

 

 

 

When a passenger reserves a ticket, the e-mail address of the passenger is checked in the dtFrequentFliers table to query if a discount is applicable to the passenger. If a discount is applicable, the fare is computed after deducting the applicable discount.

Database Schema

Having examined all the tables of the SkyShark Airlines database, you can infer the database schema by creating relationships between database tables. The schema for the SkyShark Airlines database is shown in Figure 18-1.

FIGURE 18-1 Database schema for SkyShark Airlines