Checking seat availability

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:
  1. Read the flight table to find the aircraft type (At).
  2. Read the aircraft table to find a seat number (Se) in the required class.
  3. Read the passenger number field (Pn) in the seat table to find whether that seat has already been booked.
  4. If that seat number is already booked, read the aircraft table again to find the next seat in the required class.
  5. 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
Alternative text description not available.

Figure 2 shows how the tables have been changed.

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
Alternative text description not available.

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.

Table 1. Seat table (revised)
Date Flight number Seat number Class Passenger number
Da1 Fl1 Se1 Cl2 Pn1
Da1 Fl1 Se2 Cl2 Pn2
Da1 Fl1 Se3 Cl2 Pn3
Da1 Fl1 Se4 Cl3 Pn4