TMF Application Programmer's Guide (G06.26+)

TMF Programming Environment
HP NonStop TMF Application Programmer’s Guide522419-005
1-11
Consistency and Concurrency
Consistency and Concurrency
In the OLTP environment, there are three fundamental criteria that you can use to
judge the integrity of a business database:
The data must accurately reflect the results of all business operations performed
against the database. In particular, all related data items must be accurate with
regard to one another. Every total field, for example, must always equal the sum of
all the detail items that it represents.
The data must not violate the fundamental operating precepts of the particular
business. Within the context of a financial institution, for example, the accrued
debt against a line of credit must not exceed the customer’s limit.
Access to the same data by different program modules must result in the same
view of that data.
When a database satisfies all of these criteria, it is said to be in a consistent state.
The job of maintaining database consistency can be divided into three tasks.
First, each application program module must be coded to properly change all pertinent
data values and must be designed to do so in accordance with the rules of the
applicable business environment. As an application designer or programmer, this is
your responsibility.
Second, if a hardware or software failure occurs in the middle of a transaction, all of
the items in the database that have been altered by the aborted transaction must be
restored to their prior values. TMF does this for you. All you must do is properly group
related database operations into TMF transactions.
Finally, when different processes are accessing the same database concurrently, they
must be prevented from performing conflicting operations that distort one anothers
interpretation of the data. This is accomplished through the use of various types of
locks on the data. For NonStop SQL/MP objects, you merely specify appropriate
access options and NonStop SQL/MP obtains and releases the locks for you. For
Enscribe files, you obtain and release locks, either explicitly or implicitly, through the
use of file-system procedure calls.
Achieving Maximum Consistency
To achieve the highest degree of database consistency, do as follows:
1. If you have the choice of creating your database files as either NonStop SQL/MP
objects or Enscribe files, choose NonStop SQL/MP because it provides the more
effective (ANSI standard) concurrency control.
2. Design your TMF transactions so that all reads, updates, insertions, and deletions
related to a particular business operation are within the bounds of a single TMF
transaction.