Overview of the Transactional Interface
The Btrieve API is a low-level interface to the transactional database engine that embodies functional aspects of the database design that might be otherwise transparent in higher-level interfaces such as SQL, Java, or ODBC. For example, the SQL interface operates independently of how the data is physically stored. However, the transactional interface developer must consider lower level aspects such as page size, physical and logical currency, type verification, and data validation. Despite these low-level considerations, the Btrieve API provides excellent flexibility and control over the data.
The transactional database engine stores information in files, which can be up to 256 GB in size for Pervasive PSQL 9.5 and later, (128 GB for earlier 9.x versions, and 64 GB for other earlier versions). Inside each data file are records, which contain bytes of data. A file can contain up to 4 billion records.
The data in a record might represent an employee’s name, ID, address, phone number, rate of pay, and so on. However, the transactional database engine interprets a record only as a collection of bytes; it does not recognize logically discrete pieces of information within a record. To the transactional database engine, a last name, first name, employee ID, and so on do not exist inside a record.
The only discrete portions of information that the transactional interface recognizes in a record are keys. Keys provide both fast, direct access to records and a means of sorting records by key values. Because the transactional interface has no way of knowing the structure of the records in each file, you define each key by identifying the following:
You can create or drop keys at any time. For each key defined in a data file, the transactional interface builds an index. The index is stored inside the data file itself. The index maps each key value in the file to an offset in the actual data. Normally, when accessing or sorting data, the transactional interface does not search through all the records in the file. Instead, it searches the index and then manipulates only those records appropriate to the request.
You can create indexes when you create the data file, or any time thereafter. When you create a data file, you can define one or more keys for the transactional interface to use in building indexes.
You can also define external indexes after creating a file. An external index file is a standard data file that contains records sorted by the key you specify. Each record consists of the following:
Positioning rules (guidelines governing which record is current, which is next, and so on) are the same, regardless of when you create an index.
If you create an index at the same time that you create the file, the transactional interface stores duplicate key values in the chronological order in which the records are inserted into the file. If you create an index for a file that already exists, the transactional interface stores duplicate key values in the physical order of the corresponding records in the file at the time the index is created. How the transactional interface stores duplicate key values in an index also depends on whether the key is linked-duplicatable or repeating-duplicatable. For more information, refer to Duplicatability.
*Note: The chronological ordering of records can change when you update records and change their key values, when you drop and rebuild an index, or when you rebuild the file. Therefore, you should not assume that the order of records in a file always reflects the order in which the records were inserted. If you want to track the order of record insertion, use an AUTOINCREMENT key.
You can delete, or drop, an index when your application no longer needs it. The space that the index used in the file is freed for data or for other index pages. (However, this free space remains allocated to the file; you will not see a reduction in physical file size after dropping an index.)
Refer to Chapter 5, Designing a Database for specific information about defining keys.
Transactional Interface Environment
Before an end user can run your transactional interface application, a version of transactional database engine must be available to the end user’s computer. You should provide the end user with information about any prerequisite the transactional interface software versions and configurations that your application requires.
Configuration Notes
End users may need to know the following information about your transactional interface application. Include this information in the documentation you provide with your transactional interface application.
Your application may require more memory or disk space than the transactional interface requires on its own. Establish the disk space and memory requirements of your application and communicate this information to your users. For information about system requirements of the transactional interface, refer to Getting Started With Pervasive PSQL and to the Pervasive Software Web site.
For descriptions of configuration options, refer to the Advanced Operations Guide.