database in pascal - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

database in pascal

heigo2heigo2 Posts: 4Member
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 [email protected]

Comments

  • zibadianzibadian Posts: 6,349Member
    : 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 [email protected]
    :
    :
    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:
    [code]
    var
    Names: array[0..49] of string;
    [/code]
    This names database will hold 50 names. If you need more information than this, you can use a 2D-array or records. Example:
    [code]
    type
    TAddress = record
    Name: string;
    Street: string;
    Number: integer;
    Telephone: string[15];
    end;

    var
    Addresses: array[0..49] of TAddress;
    [/code]
    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:
    [code]
    type
    PAddress = ^TAddress;
    TAddress = record
    Name: string;
    Street: string;
    Number: integer;
    Telephone: string[15];
    Next: PAddress;
    end;

    var
    FirstAddress: PAddress;
    [/code]
    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.
  • heigo2heigo2 Posts: 4Member
    ok, that helped a little bit...
    ok, then....here is how the exact database should contain, and which queries must be made in that...
    its a student database(a student has graduated high school and now entering univercity, and he has points, which shous how will get in and who not)
    the field are
    studet's name(name),the high school he finised(school), 11 digit id code (idcode), city where he lives (city), points for competition (points), and date when he gave the documents to school)

    it should be possible to make queries, delete the records in to steps (logical and physically).
    and that all is to complecated to me :(
  • bpajkbpajk Posts: 156Member
    : ok, that helped a little bit...
    : ok, then....here is how the exact database should contain, and which queries must be made in that...
    : its a student database(a student has graduated high school and now entering univercity, and he has points, which shous how will get in and who not)
    : the field are
    : studet's name(name),the high school he finised(school), 11 digit id code (idcode), city where he lives (city), points for competition (points), and date when he gave the documents to school)
    :
    : it should be possible to make queries, delete the records in to steps (logical and physically).
    : and that all is to complecated to me :(
    :
    I think for your need you should use a table of records like so:
    [CODE]
    type tPerson=record name,
    HighSchool: string[10];
    id: longint;
    city: string[10];
    points: longint;
    date: array [1..3] of word
    end;
    var person: array[1..1000] of tPerson;
    [/CODE]
Sign In or Register to comment.