The SourcePro DB Solution
To insulate your applications from the details of diverse data types, SourcePro DB uses a data model that automatically normalizes data types. By
normalizing data types, we mean that SourcePro DB converts data from database-dependent data types to DB Interface Module classes that represent the data in a standard, vendor-neutral way.
Figure 4 shows how this data model works within the SourcePro DB architecture:
As
Figure 4 shows, SourcePro DB consists of the DB Interface Module and a vendor-specific DB Access Module that bridge your application and the database. The SourcePro DB data model consists of three layers: the
database layer, the
value layer, and the
pointer layer.
The
database layer resides in the various DB Access Modules, and provides an interface to each database vendor's API. DB Interface Module code with any reference to database-dependent data types is restricted to this layer. The function of this code is to move data between the Open SQL class
RWDBTBuffer<T> and the native database API.
The
value layer consists of the DB Interface Module classes that pass data by value. C++ types, like
int,
float, and so on, are used directly by this layer. They are augmented by a small number of concrete classes used for storage and manipulation of structured data:
RWCString,
RWWString,
RWBasicUString,
RWDBMBString,
RWDecimalPortable,
RWDBBlob,
RWDateTime, and
RWDBDuration. Additionally, class
RWDBValue is used for datatype neutral data access and for datatype conversion. The value layer spans the DB Interface Module and your application program.
In the
pointer layer of the DB Interface Module, pointers to all data are encapsulated in instances of class
RWDBTBuffer<T>. Data moving to or from a database is stored here by pointer. The pointer layer spans the DB Interface Module and the various DB Access Modules, and your application program as well, depending on the classes of the DB Interface Module that you use. When your application passes pointers to the value-based classes or uses Open SQL, you use the pointer layer directly.
NOTE: You can write applications with the DB Interface Module using pass-by-value semantics alone. This design avoids the memory-management concerns of pointer-based interfaces.
All classes of the DB Interface Module produced from an
RWDBDatabase or
RWDBTable instance, such as
RWDBSelector,
RWDBInserter, and so on, can accept input from, or deliver output to, the C++ types and concrete classes listed above. Insulation from the datatype and data transport peculiarities of various databases makes SourcePro DB applications portable and reusable. The remainder of this chapter describes each layer of the data model in detail.