DB Interface Module User’s Guide : PART I Introduction : Chapter 1 Introduction : Features and Benefits
Features and Benefits
You can use SourcePro DB for virtually any programming task involving interaction with a relational database management system (RDBMS). Its object-oriented architecture results in code that is shorter, cleaner, and more maintainable than code written to specific databases. Its dual-module design supports portability among databases and operating systems, yet allows direct calls to the underlying API. The unique design of SourcePro DB supports comprehensive functionality, consistency across multiple databases, and numerous performance enhancements.
Comprehensive Functionality
SourcePro DB encapsulates the basic abstractions you need for database programming, as well as the special features required by individual applications. Some of these features include:
Support for internationalization. You can use SourcePro DB with virtually all known character sets and locales. SourcePro DB provides proper formatting of strings, dates, times, numbers, and currency. See Chapter 13, “Internationalization.”
Options for database connections. Class RWDBConnection encapsulates connections to databases. You can let SourcePro DB manage connections invisibly, or control these resources yourself. Specifying an optimum number of default connections can significantly boost the performance of an application. See “Managing Connections” and the entry for RWDBDatabase in the SourcePro API Reference Guide for details on defaultConnections() and totalConnections().
Class RWDBEnvironmentHandle lets you set certain connect time and configuration parameters before connecting to a database. See your Access Module guide.
You can also initiate a connection when an RWDBDatabase is produced by the RWDBManager. See RWDBDatabase::connect() in the SourcePro API Reference Guide.
Open SQL. You can control SQL statements directly using this alternative interface that encapsulates the semantics for statement execution, parameter binding, and results fetching. See Chapter 15, “Using the Open SQL Classes.”
Primary and foreign key support. You can get direct access to schema information, including datatype, precision, scale, and storage length, and primary and foreign key information. The direct mechanism for the creation of tables also supports primary and foreign keys. See the class descriptions for RWDBForeignKey, and the description of primaryKey() under RWDBSchema and RWDBTable.
Outer joins. You can construct SQL outer join syntaxes for SQL 92-compliant syntax and the noncompliant syntaxes supported by some database vendor APIs. See “Outer Joins” in the DB Interface Module User’s Guide, the class description for RWDBJoinExpr, and the section on outer joins in each Access Module guide.
Full exception safety. SourcePro DB is exception-safe even in environments where C callback routines are used.
Transaction processing model. SourcePro DB supplies a uniform, ANSI-compliant interface for all supported databases. See “Transaction Processing with RWDBConnection.”
Consistency Across Different Databases
If you currently work with several different databases, you will find that SourcePro DB promotes consistency through its processes and procedures. Features that promote consistency include:
Automatic normalization of data types. You don’t have to adapt to the different ways database vendors represent data; SourcePro DB does it for you. Class RWDBValue converts database-dependent types to C++ types, and vice-versa. See Chapter 7, “The Data Model.”
A uniform method for processing results. Some RDBMSs can produce multiple result sets from a single query, or completely unexpected result sets if stored procedures or triggers are involved. Class RWDBResult allows your application to handle these events easily, or to ignore them. No more flushing your data stream. See “Getting Results from an Inserter.”
A uniform view of tabular data. With class RWDBTable, you can use the same interface to deal with tables in a relational database, derived tables representing a SQL query as a table, tables in program memory, and tables that result from a join. See “Tables.”
Consistent error handling. Whatever databases you are using, the same error model applies. And SourcePro DB is exception safe in environments using C callback routines.
Support for stored procedures. Class RWDBStoredProc encapsulates the functionality of a database stored procedure, including creation, deletion, and execution of stored procedures, and passing parameters by value or by reference. It can handle multiple result sets. See “Stored Procedures.”
Enhanced Performance
Our goal for SourcePro DB is to bring performance as close as possible to native API performance benchmarks. Product features that specifically enhance performance include:
Optimized database access. To save overhead, SourcePro DB accesses the database only when necessary or when specifically requested. See “Database Tables.”
Bulk reads and writes. Your SourcePro DB applications can read arrays of values at once, rather than simply scalar values one at a time. If your underlying database supports this feature, processing data is dramatically faster. See Chapter 8, “Bulk Reading and Writing.”
Caching. You can significantly enhance performance by explicitly setting cache size in RWDBReader and RWDBInserter, or by using schema caching through RWDBEnvironmentHandle. See their respective class descriptions, and Chapter 9, “Caching,” of this User’s Guide.
Asynchronous processing. Your SourcePro DB applications can continue processing while waiting for I/O, if this feature is also supported by your database vendor API. See Chapter 12, “Asynchronous Usage.”
Dynamic SQL. You can enhance transaction-level performance by binding variables to SQL statements using the class RWDBBoundExpr. This eliminates costly rebinding and reparsing from recurring executions, and enhances the performance of inserting, deleting, and updating. See the class description for RWDBBoundExpr in the Reference Guide.
Multithreading. Applications that share objects of SourcePro DB across threads can use the internal mutex of objects to control database access with member functions acquire() and release(). A technique involving a user-supplied guard class ensures that acquire() and release()are called in pairs. See “The Guard Class with Templates.”
SourcePro DB is multithread-safe.