Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

16.4 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.


Before using the tutorials, you should verify that there won't be any conflicts with existing tables within your database.

Table 16: The customer table

Column RWDBValue Type
name String
ID UnsignedLong
address String
city String
state String
zip String
phone String

Table 17: The videos table

Column RWDBValue Type
title String
ID UnsignedLong
yr UnsignedInt
category String
quantity UnsignedInt
numOnHand UnsignedInt
synopsis String

Table 18: The supplier table

Column RWDBValue Type
name String
ID UnsignedLong
address String
city String
state String
zip String
phone String

Table 19: The rentals table

Column Type
customerID UnsignedLong
videoID UnsignedLong
invoiceNum UnsignedLong
rentalDate DateTime
dueDate DateTime
returnDate DateTime

Table 20: 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 21: 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.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.