XBASE main concepts
General
Fields and records
Spreadsheet, spreadsheet structure and database file
Indices, index and filter expressions and index files
Writing changes to the database
Working with index files
Deleting records
Creating a database, an index or an index file
Limitations
To make this section easier to understand for readers who have no experience in database usage, we provide definitions of the terms used in the description of the XBase object of the system language that is used to work with databases.
Fields and records
If you are not familiar with the concept of a database, you can think of a database as an organized information storage, like a card register. A telephone directory for a company is a good example of a database. It contains last names, telephone numbers and room numbers for all the employees of the company. Each line of the telephone book is a record, and each column is a field. Each field has a name and attributes of the information that is stored in it: type, length and precision. The field contents for a specific record is called field value. For example, a telephone book can be organized as a table with columns (fields) Full name, Room number, Phone, where each row (record) contains information about one employee.
Spreadsheet, spreadsheet structure and database file
In the database context, the entire telephone book is called a spreadsheet. The spreadsheet fields determine its structure, and the spreadsheet records determine its contents. Each record in the table contains the same set of fields as the entire spreadsheet. Therefore we sometimes refer to this set as a record structure. A record structure is basically the same as a spreadsheet structure, although the former term is more accurate since a spreadsheet always has a structure, even if it doesn't contain any records.
Implementation of databases in the DBF format implies that each spreadsheet is stored in a separate file. Therefore, hereinafter we shall refer to a database spreadsheet file as a database file or DB file.
Indices, index and filter expressions and index files
An index system is used to organize database file contents and to search them for values of one or more fields. It has the same principle as sorting a card register based on a certain attribute (a set of attributes). However, unlike a card register, a DB file can contain several indices, and its contents can be sorted by several attributes. Each index has a name, unique attribute, expression and filter. The index name is used for identification purposes. The index expression and filter are expressions written in a special language. When values of these expressions are calculated for each record, the results are used to determine its location and the necessity for placing it into an arranged list (an index can contain information not about all spreadsheet records, but only about those that meet the requirements of the filter expression). A unique index (that has the unique attribute on) can contain only references to records with different index expression values.
Indices are stored in an index file. The index file can contain information about more than one index.
Writing changes to the database
Each object is a data structure located in the computer memory. When you change the object properties, the database files aren't immediately changed. When the autosaving mode is on, the object changes are written to the database only when you change the position (move to the next record, perform a key search, etc). When the autosaving mode is off, changes are written only when you run the appropriate object method.
Working with index files
Remember that an XBase can be linked only to one index file at once. All database changes made during a session with one index file do not influence other index files. Therefore, it is not recommended to use more than one index file for a database because otherwise you'll have to update the index file contents every time you open a database with a new index.
Deleting records
Deleting database record doesn't physically erase it on disk. If you delete records, a special deletion mark will be put into a hidden system field that cannot be accessed in the usual way. You can not switch to records that are marked as deleted unless you are running a special mode of viewing deleted records. There is a property that controls this special mode, and there are several methods that are used to determine whether the current record is deleted and to restore the deleted records.
The database compression method physically erases the database records that are marked as deleted. The database clear method physically erases all database records. If you use any of these methods, you won't be able to restore the deleted records in future.
Creating a database, an index or an index file
In addition to methods for working with existing databases, XBase objects have methods for creating new databases of an arbitrary structure, new indices and new index files. Remember that although you can use methods that change the database structure only for objects that are not linked to the existing database (i.e. for new databases), you can create new indices and index files both for new and existing databases.
Limitations
The main purpose of XBase objects is to organize the data export/import to/from external files in DBF format.
XBase objects do not support memo-type fields.
XBase objects support only exclusive access to files.
XBase objects support index files in the CDX format. However, it is not recommended to use index files created with XBase in external programs (e.g. FoxBase), and it is not recommended to use index files created with external programs in XBase objects due to the possible incompatibility of the versions.