The database for this problem will have two different types of rental, and the object design gave us the following class hierarchy:
As you learned in week 1 , you will create a database with a table for each of the different classes. The cells in each table correspond to the data members of the class. There is one area in which you will have to change your design approach. Normally the base class (Rental) would be abstract, but you will need to have a database table to indicate which of the items in the concrete tables (CondoRental and MooringRental), so the base class in this problem will have one data member to indicate the type of item and one to indicate the id of that item. This will also dictate how the abstract factory works in this problem.
The customer table is standard, and it was constructed using the table wizzard in Access. The Rental table is explained in other areas of this document. The Condo and Mooring tables have some interesting features that should be highlighted. In both cases the id for each item is not the resorts number for the item. In all cases the customerId is stored in the parent Rental table.The reason for this is that a room or mooring might be reserved for more than one time period (our simple problem doesn't allow this, but the way is paved for a more complex model).
| Customer Table
The Customer Table contains all customer information plus the customer id used as the key field. |
|
| Rental Table
The rental table is a master table for all entries. It contains the type of each rental (0 for condo and 1 for mooring. And the id of that item in the appropriate table. The type will determine the table. It also contains the customerId. This will make searches simpler. |
|
| Condo Table This table contains rental information for a condo rental including the room, length of stay and rate. |
|
| Mooring Table
The Mooring Table contains information similar to that in the Condo Table, except the requirements for a mooring. |
|
The table relationships for this database are fairly obvious, namely the customer id of the rental type is associated with the customer id in the customer record. The rentalId in the Rental table corresponds to the id in either the Condo Rental or Mooring Rental table. This does cause problems in Access, since it would require that every condo reservation record must have a corresponding mooring reservation. Because of this, the only place this correspondence will exist is in queries you build.
While you did not relate the rentalId in the Rental Table to the id of either a condo or rental unit, if you were to make a query in Access, that required that entries with rentalType 0, the relationship between rentalId and id of the condo is made for you by Access. In effect the relationship you will build into your c++ program is established automatically by Access.
Back to the problem.