The bthash library allows you to maintain a medium sized btree or hash database on a personal computer. bthash database routines are compatible with batch, windows, curses, or sockets. They need to be single threaded in a socket program that updates a database, and their locks are not secure under NFS.
If you need a database server or you need to store more than 10 million records, you may prefer to use a more complete database management system, such as:
If you are looking for SQL with a btree database, consider the Debian package sqlite. This package uses a virtual machine like Java.
bthash doesn't understand SQL queries or have an ODBC driver. PostgreSQL and MySQL have ODBC drivers. bthash doesn't have a data dictionary, foreign keys, or referential integrity built into it. You have to provide a transaction log and referential integrity through your programs. Numeric data is treated as binary data in bthash. A null terminated string is also treated as binary data.
Every program that uses bthash is in effect like a stored procedure. Your program can also be written like a trigger, in that one event can trigger another event. In the Windows environment, your callback procedure can trigger update events to your database.
See the comparison between bthash and the Berkeley database.
Also see the comparison between the btree and hash databases,
and the comparison between the bthash and SQL databases.
Category | Limit |
---|---|
Maximum file size | 2 gigabytes |
Maximum block size | 64 kilobytes |
Minimum records per node | 3 records |
Maximum records per node | 1023 records |
Category | Limit |
---|---|
Maximum file size | 2 gigabytes |
Maximum record size | 32 thousand bytes |
Maximum key size | 32 thousand bytes |
A socket program using a bthash database has to be single threaded if it updates the database. It can be multi-threaded if it is read-only.
If you compile bthash for a PDA, you will have a small footprint for your database program. The database can be copied back and forth between the host PC and the PDA without changing the data.
PDA devices come with the Linux operating system and Windows CE. Either version of bthash should work on a PDA.
Currently bthash isn't compiled under the Palm OS.
You can create the database on one platform and use the database as a reference tool on the other platform. For example,
Creation Platform | Reference Platform |
---|---|
PC | PDA |
PDA | PC |
The installation procedure for the bthash database library offers these choices:
The choice of shared/DLL versus static library is transparent to the application program. However, the search path has to include the location of the shared/DLL library at run time.
In the case of the DLL library in Windows, the DLL and static libraries are exclusive. They can't co-exist with the same base name. The import library has the same name as the static library. Therefore you have to place the static library in a different directory than the import library. Your make file has to point to the correct directory depending on whether you want dynamic or static linkage.
In the UNIX version, you will see a setlib command in the src directory. You will have to run that command with the dot command so that the evironmental variable will be exported. For example,
. setlib
This will point you to the shared library.
In the Windows version, you will see setlib.bat in the src directory. You will have to run that command to copy bthash.dll to the local directory.