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.
Column | RWDBValue Type |
name |
String |
ID |
Unsigned Long |
address |
String |
city |
String |
state |
String |
zip |
String |
phone |
String |
Column | RWDBValue Type |
title |
String |
ID |
Unsigned Long |
year |
Unsigned Int |
category |
String |
quantity |
Unsigned Int |
numOnHand |
Unsigned Int |
synopsis |
String |
Column | RWDBValue Type |
name |
String |
ID |
Unsigned Long |
address |
String |
city |
String |
state |
String |
zip |
String |
phone |
String |
Column | Type |
customer ID |
Unsigned Long |
video ID |
Unsigned Long |
invoiceNum |
Unsigned Long |
rentalDate |
Date |
dueDate |
Date |
returnDate |
Date |
Column | Type |
video ID |
Unsigned Long |
supplierID |
Unsigned Long |
orderNum |
Unsigned Long |
unitPrice |
Money |
quantity |
Unsigned Int |
date |
Date |
For maximum portability, the table names have been chosen to conform with databases that impose an 8-letter maximum on name length. Likewise, column names have been chosen with a 10-letter maximum. Notice that DBTools.h++ itself places no such restriction on name length.
The tutorial model provides a separate class for each table in the video store's databases, 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 rows 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 | Class | File |
customer |
VVContactRepository VVContact |
conrep.cpp contact.cpp |
videos |
VVVideoRepository VVVideo |
vidrep.cpp video.cpp |
supplier |
VVContactRepository VVContact |
conrep.cpp contact.cpp |
rentals |
VVRentalTransactionRepository VVRentalTransaction |
rentrep.cpp renttran.cpp |
purchase |
VVPurchaseTransactionRepository VVPurchase |
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 Rogue Wave's Tools.h++. The DBTools.h++ tutorials do not use persistence.
Exploring the source code of these classes beyond what is used in the tutorials can help you learn both DBTools.h++ and Tools.h++.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.