grade 11 - file organisation and file access new

Upload: renardovanhorne

Post on 03-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 Grade 11 - File Organisation and File Access New

    1/2

    FILE ORGANISATION AND FILE ACCESS

    Review:

    Storage devices can be categorized according the manner

    in which they access data. There are two types of access:

    1. Sequential access (the retrieval of data in the order in

    which it was stored). Example of sequential access

    storage media - MAGNETIC TAPE. The data stored

    on magnetic tapes have to be read in sequence. It isimpossible to jump the middle of the tape to find a

    particular data item.

    Random access (the ability of the computer to go

    directly to a specific piece of data on the storage

    media without having to access any other data).

    Examples of direct access storage mediaMost other

    secondary storage media such as floppy disk and hard

    disk that allow software medium without having to

    access any other data.

    Files of RecordsIn any computer system data is stored in files. There are

    different types of files:

    Text files contain just the characters that you

    include in them.

    Word Processing files contain text but they also

    contain how the document should be laid out.

    Files of records.

    A file of records is the simplest form of database. A

    record is a collection of all the data about a single item in afile. For example, the details of the members of a club may

    be held in a file. Each record would contain the data about

    just one club member. The file would hold a record for

    each member of the club.

    The data about each member would fall under a series of

    headings known as fields. The fields could include

    surname, first name, and the date when they joined the

    club.

    Each row is a record in a file. Each record will have data

    in one or more of the fields. Files of records are used by

    many different software applications. For example, the

    phone directory on a cell phone is a file of records.

    File Organisation

    Three main methods of file organisation are:

    1. Sequential

    2. Indexed-Sequential

    3. Random

    Sequential files can be used with sequential access or direc

    access media. Indexed-sequential and random files can

    only be used with direct access media.

    Sequential File Organisation

    In a sequential file, all the records are stored in order. Thatmeans that the records have been sorted in some way. One

    of the fields will be used for ordering, that is sorting the

    file. This field is known as a key or key field.

    Sequential files are searched using sequential access. That

    means that if you want to find a record in a sequential file

    you have to start at the beginning and work your way

    through until you find it. (N.B. Serial files are files with

    unordered records stored in a sequential manner while

    sequential files are files with ordered records stored in a

    sequential manner.)

    Indexed-Sequential File Organisation

    If a file is quite large you may have to wait a long time

    while the system searches through the records if a

    sequential search is used. An indexed-sequential file is

    also a file that has been sorted in some order. Another file

    is also set up to act as an index.

    Letter Position

    A 1

    B 20

    C 49

    W 437

    X 468

    Y 469

    Z 475

    The Indexed file

    Position Surname First Name Date Joined

    437 Waldron Pauline 14 Apr 1990

    438 Walker George 23 Aug 1985

    439 Walsh Joel 1 Sep 1989

    Etc.

    The Sequential file

    Supposed the club file mentioned above has very many

    records. An index file could be set up (see first table). The

    letter field refers to the first letter of the names in the

    sequential file. The position field states where the first

    surname beginning with the letter is to be found. So if you

    wanted to search for the surname Williams, the system

    would first search through the index file to find the letter

  • 8/11/2019 Grade 11 - File Organisation and File Access New

    2/2

    W. It would jump to that position in the main sequential

    file. It would then search though all the surnames

    beginning with W until it found Williams. The indexed-

    sequential file method makes it possible to search large

    sequential files very quickly.

    Indexed-sequential file organisation cannot be used with

    sequential access media such as magnetic tape. It can only

    be used with direct access media such as disks. The main

    sequential files containing all the records could be stored

    on a hard disk.

    Random File Organisation

    Like indexed-sequential files, random files can only be

    used on direct access media, such as disks. Random file

    organization is the most efficient way of storing extremely

    large files, such as national databases. Random files use a

    rather clever method of providing direct access to records.

    Each record will have its own specific position (or address)

    on the disk but the records may not be stored in sorted

    order at all. The position allocated to each record will be

    calculated by a special formula called a hash formula. This

    formula will use some of the data in the record and then

    convert it into the address of a position on the disk.

    When a new record is added to the file, the formula works

    out the address where it should be stored on disk. When

    someone wants to search for a record, once again the

    formula will work out where to find it.

    This method means no time is wasted when searching for a

    record since the system can go directly to the right record.

    Choosing appropriate file organisationWhen new application software is being developed, the software engineers and programmers have to decide on the

    method of file organization that they will use. There is rarely one way of solving the problem, but here are some typical

    examples.

    A payroll is a list of all the employees in an organization, together with their pay details. Every month a payroll

    application will calculate how much each person should be paid. It will print payslips and it may send the details of

    payments directly to the companys bank. The payroll file would normally be stored sequentially by surname. When

    the application is run each month it will access the record for each employee one at a time, so a simple sequential file

    is needed.

    A shop uses a computerized stock system. The stock records hold details of all the items for sale in the shop. Each

    item is identified by a stock code. The stock record for each item also holds the price of the item and the number in

    stock. When a customer wants to buy an item the sales assistant enters the stock code at a point of sale terminal. (A

    barcode reader can be used to scan in the stock code from a label on the item.) The stock system then finds the record

    for the item and sends the price to the point of sale terminal. It also updates the stock record to show that the number

    in stock has gone down. There will be a large number of records in the stock file, and each item has to be retrieved

    quickly, so the best way to organize the file would be as a random file.

    A library has a computer-based catalogue of all its books. The catalogue is sorted by the ISBN (International Standard

    Book Number) which you can find on the back of any book that has been published. There is usually a barcode that

    gives the ISBN as well. When someone borrows the book the librarian scans the ISBN barcode and this brings up the

    details of the book on screen. The catalogue file is large but is stored sequentially. Index-sequential file organization

    will give fairly quick access to any record.

    (From Heinemann Information Technology)