The Tutorial Model
The video store modeled in the tutorials has a database containing only five tables. Three of these tables represent the pool of customers, videos, and video suppliers, and the remaining two represent the transactions of customers renting videos and suppliers providing the videos that the store purchases. The schema of these tables are shown below.
NOTE: Before using the tutorials, you should verify that there won’t be any conflicts with existing tables within your database.
Table 17 – The customer table
Column | RWDBValue Type |
---|
name | String |
ID | UnsignedLong |
address | String |
city | String |
state | String |
zip | String |
phone | String |
Table 18 – The videos table
Column | RWDBValue Type |
---|
title | String |
ID | UnsignedLong |
yr | UnsignedInt |
category | String |
quantity | UnsignedInt |
numOnHand | UnsignedInt |
synopsis | String |
Table 19 – The supplier table
Column | RWDBValue Type |
---|
name | String |
ID | UnsignedLong |
address | String |
city | String |
state | String |
zip | String |
phone | String |
Table 20 – The rentals table
Column | Type |
---|
customerID | UnsignedLong |
videoID | UnsignedLong |
invoiceNum | UnsignedLong |
rentalDate | DateTime |
dueDate | DateTime |
returnDate | DateTime |
Table 21 – The purchase table
Column | Type |
---|
videoID | UnsignedLong |
supplierID | UnsignedLong |
orderNum | UnsignedLong |
unitPrice | Decimal |
quantity | UnsignedInt |
purchDate | Date |
The tutorial model provides a separate class for each table in the video store’s database, as well as a class representing a single row in each table. For example, the table containing the library of video titles is represented by a class called VVVideoRepository. This class encapsulates the table in the database, as well as the basic operations on that table. As a companion to the VVVideoRepository class, there is a class representing one video entry in the table. This class, called VVVideo, has one instance variable for each of the columns in the table. This class also includes member functions appropriate for a representation of a single video.
Each of the five tables in the video store’s database uses this model of a pairing of two classes. One class encapsulates the table, and the other class represents one row of the table.
The table below illustrates the associations of tables, classes, and files.
Table 22 – Associations of tables, classes, and files
Table | Class | File |
---|
customer | VVContactRepositoryVVContact | conrep.cpp contact.cpp |
videos | VVVideoRepositoryVVVideo | vidrep.cpp video.cpp |
supplier | VVContactRepositoryVVContact | conrep.cpp contact.cpp |
rentals | VVRentalTransactionRepositoryVVRentalTransaction | rentrep.cpp renttran.cpp |
purchase | VVPurchaseRepositoryVVPurchase | purchrep.cpp purchase.cpp |
We developed each of these classes more completely than necessary for use with the tutorials. The tutorials do not exploit all the functionality of these classes. You will find many useful routines implemented in the classes that can be used as example code.
All the classes that represent one row of a given table are implemented as collectable, persistable objects according to the method defined by the Essential Tools Module. The SourcePro DB tutorials do not use persistence.
Exploring the source code of these classes beyond what is used in the tutorials can help you learn both the DB Interface Module and the Essential Tools Module.