Random Access Database is an open-source implementation of an object oriented database using fixed length records. It is written in Free Pascal with Lazarus 1.4. Although random access files are rarely used these days, I felt the need to write this implementation mainly because of three reasons:
1. It is by far the simplest way to do database programming because it uses the native programming language.
2. It is by far the fastest database having only one pointer / record-id.
3. There is zero fragmentation of the database file because deleted record spaces can easily be re-used.
Of course, there is also a downside. Random Access files use fixed-length records, which means records have a fixed size thus fixed-length fields, and cannot be changed as flexibly as for example sql-records, where you can instantly add, remove or change any field you want. Random Access databases need to be converted into a new data-structure in order to accomplish any change. This is not difficult or complicated at all, but it requires more work. Still, I believe it is worth the effort because any other database implementation is much more complicated to setup, and usually requires knowledge of a specific database language, such as SQL.
Just to show you how easy it is to set up and use TRaDB in Free Pascal, consider the following example:
// setup data structure
type
TPerson = packed record
FirstName : string[30];
SurName : string[30];
Address : string[40];
Phone : string[15];
EmailAddress : string[40];
end;
var
Person: TPerson;
PersonDB: TRaDB;
..
// setup database
PersonDB := TRaDB.Create;
with PersonDB do
begin
Name := 'AddressBook';
FileName := 'addressbook.rdb';
RecordSize := SizeOf(Person);
end;
..
// open database
if not PersonDB.Open then
halt; // error
// add data
with Person do
begin
FirstName := 'John';
SurName := 'Smith';
..
end;
// add record
if PersonDB.AddRecord(@Person) then
; // record added successfully
PersonDB.Close;
Download here:
http://www.ditrianum.org/tools/TRaDB.tar.gzManual:
http://www.ditrianum.org/tools/TRaDB.pdf