Before booking a seat, check whether there is a seat of the required class
available on the flight specified. To check seat availability using these
tables:
Read the flight table to find the aircraft type (At).
Read the aircraft table to find a seat number (Se)
in the required class.
Read the passenger number field (Pn) in the seat table to find whether that seat has already been booked.
If that seat number is already booked, read the aircraft table again to
find the next seat in the required class.
Repeat steps 3 and 4 until an available seat is found, or until all seats
in the required class are found to be booked.
This read process is shown in Figure 1. You can see the seat
table and the aircraft table will probably have to be read many times, which
would involve a significant amount of I/O processing. Performance would be
much improved if some changes were made to these two tables.
Figure 1. Read process for checking seat availability
before optimization
In the aircraft table, the seat number (Se) attribute has been changed to seat range (Sr). The table is now more compact because you do not
have to store every seat on a separate row.
The class (Cl) attribute
has been duplicated in the seat table. Availability (Av), in the flight table, is a new attribute.
Figure 2. Altering the tables to improve availability checking
After improving these tables, the revised seat table (shown in Table 1)
contains all the data needed to check seat availability. Every flight is recorded
there, and you can see at once whether a seat has been booked or not.