DatabaseEngines and programming language Foundation
For a complete understanding of DatabaseEngines, an explanation of the internal mechanisms which create the relationship between the programming language and the database model is required. As an example, the command USE and the function DbUseArea() open one or more files in a work area. The actual file opening is performed by a DatabaseEngine, in this case by the DATA component of the DBE. The command INDEX ON creates an index for a file open in the work area. This operation is also performed by a DBE, but the DBE uses the ORDER component.
Certain commands and functions exist within the confines of the programming language and can only be executed by a specific component of a DatabaseEngine. With these commands and functions, the request must be routed to the proper DBE capable of executing the command or function. This task is performed by an internal mechanism called the "Database Management Language Broker", abbreviated as DMLB. The DMLB routes requests from the program to a specific component of a DBE.
The DatabaseEngine DBFDBE, for example, is not capable of creating an index. To accomplish this, the DatabaseEngine NTXDBE must be loaded. Likewise, this DBE cannot open a DBF file. In order for the command USE and the command INDEX ON to be executed, a compound DBE must be available that contains all components required by the program. The task of the DMLB is to direct requests from the program to the components of a compound DBE that are able to perform the required task. If no corresponding component is available, the DMLB attempts to perform the task itself based on its own abilities. If this is not successful, a runtime error occurs. This model provides the ability to exclude components that are not needed. For example, it is possible to write a program that does not use an index. In this case, the DatabaseEngine NTXDBE (more precisely, the ORDER component) does not need to be loaded.
The distribution of specific functionalities to component DBEs and the ability to make all functionalities dynamically available using a compound DBE offers much flexibility in data and file management. For example, an index can be created for a file that exists in SDF format (System Data Format). The NTXDBE (ORDER component) merely needs to be combined with the SDF DatabaseEngine (DATA component). The result is an SDFNTX DatabaseEngine that allows logical sorting of ASCII files that are in SDF format. The following program code illustrate this.
The fact that DATA components can be combined with ORDER components to create a compound DBE allows the functionality of various file operations to be available for different file formats. In the example a TXT file (ASCII file) is opened using the same command (USE) previously used to open a DBF file. Also database operations, like DbAppend() and DbSeek(), can now be performed on the TXT file. The addition of a new data record using DbAppend() is accomplished via the SDF component and the search for data in the TXT file using DbSeek() occurs via the NTX component.
There is, however, the limitation that it must be possible to perform the particular file operation with files of the file format. In the case of the SDF DatabaseEngine, deleting data records using the function DbDelete() is not possible. This function flags a record for deletion and there is no provision in the SDF file format for deletion flags. Consequently, calling the function DbDelete() for a file managed by the SDF DatabaseEngine would lead to a runtime error because this operation is not supported.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.