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.


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

Table 14: The customer table 

Column RWDBValue Type

name

String

ID

UnsignedLong

address

String

city

String

state

String

zip

String

phone

String

Table 15: The videos table 

Column RWDBValue Type

title

String

ID

UnsignedLong

yr

UnsignedInt

category

String

quantity

UnsignedInt

numOnHand

UnsignedInt

synopsis

String

Table 16: The supplier table 

Column RWDBValue Type

name

String

ID

UnsignedLong

address

String

city

String

state

String

zip

String

phone

String

Table 17: The rentals table 

Column Type

customerID

UnsignedLong

videoID

UnsignedLong

invoiceNum

UnsignedLong

rentalDate

DateTime

dueDate

DateTime

returnDate

DateTime

Table 18: 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 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 19: 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

VVPurchaseRepository

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 persistable to file or stream according to the method defined by the Essential Tools Module. The SourcePro DB tutorials do not use persistence to file or stream.

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 DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.