: hi!
: i have a problem with making the database in pascal,
: i dont have a clue how it's supposed to look and how i shold make it...
: could someone help me by sending some example database made in pascal so i can start to find out how my database is supposed to look like
: my email is heigo2@hot.ee
:
:
In the simplest form A database is an array of a certain data record type. Thus a database of names can be create like this:
var
Names: array[0..49] of string;
This names database will hold 50 names. If you need more information than this, you can use a 2D-array or records. Example:
type
TAddress = record
Name: string;
Street: string;
Number: integer;
Telephone: string[15];
end;
var
Addresses: array[0..49] of TAddress;
More complex forms of databases in Pascal use so called linked-lists. This is a list, in which only the location of the first record is known. Each record then holds the location of the next record. An example of this:
type
PAddress = ^TAddress;
TAddress = record
Name: string;
Street: string;
Number: integer;
Telephone: string[15];
Next: PAddress;
end;
var
FirstAddress: PAddress;
As you might know each variable can only be 64kB in size. In case of an array, this means that the entire database can only be 64kB in size. In case of the address database, each record is 530b big, thus only 123 records can be contained within the database.
Linked-lists allow you to exceed this limit, since all the variables are just 1 record big or are pointers. Navigating such a database however is more complex. I won't cover that in this post, because there is a third database option.
The third option uses an open file which holds the data. All the additions, insertions, deletions and sorting is done on that file. This increases the possible database size to the current free disk-space (which is several hundreds of MB). This however makes the database sluggish, especially during a sort. In Pascal there is an added danger, since if the program fails you loose all the data. This option nearly always uses typed files, because they are easier to handle than untyped. Text files cannot be used, due to the read/write nature of the database file.
I know this wasn't exactly what you had in mind for an answer, but given the general nature of yoru question, I thought it was best than to give some general example. You need to specify, which option you would like to see and what your database needs to hold, before you can be given meaningful examples.