You are on page 1of 3

File Organisation and Access

What is serial (or sequential) access?


This is the method used by a computer program to access a record in a file
where each and
every record is checked from the beginning of the file until a match is found.
What is direct (or random) access?
This is the method used by a computer program to access a record in a file
directly without
going through each and every record starting from the beginning of the file. The
computer
program uses the mechanism called hash keys for direct access.
What is a serial file and how it is created?
This is a file where records are written to it in the order that they are received.
The records in a
serial file may not be in order with respect to a key field.

How a program access records in a serial file?


The program accesses the records sequentially. A program cannot access records
in a serial file
directly.
What is a sequential file?
This is a file where records are organized in ascending or descending order with
respect to the
primary key.
How a program creates a sequential file?
The program writes a new record to the end of the file and sorts the file each
time a new record
is added.
How a program access records in a sequential file?
The program accesses the records sequentially. A program cannot access records
in a sequential
file directly.

What is an indexed sequential file?


1. This is a file where records are organized in the ascending or descending order
with respect to
the primary key and where the records are divided into pages of equal size.
2. The data pages of the index sequential file are associated with an index file.
Index is a pointer
which contains the absolute memory or disk address of the first record of a
data page.
3. Index file contains two fields: Primary key and the index. All the records in one
data page have
the same index (which is the memory address of the data page where that
record is

contained).
4. A computer program can access records in an indexed sequential file both
sequentially and
directly.
How a program creates an index sequential file?
1. The program writes the new record to the end of the file, divides the records
into equal sized
pages and sorts the records within each page. This process happens each
time a new record is
added to the indexed sequential file.
2. Then the program creates the index file which contains the primary keys and
the
corresponding index of each primary key (index is the pointer which contains
the absolute
memory or disk address of the first record of a data page).
3. When the number of records containing in an indexed sequential file
increases, the number of
pages in the file and therefore the number of indexes also increase. This
makes it necessary
to divide the index also into pages. An index which itself is divided into pages
is called a multilevel
index.

What is a random access file?


1. This is a file where records are written to the absolute memory or disk
addresses pointed to
by a set of hash keys stored in a hash table.
2. A computer program can access records in a random file only directly but not
sequentially.
How a program creates a random access file?
1. When a new record is to be written to the random access file, the computer
program creates
the corresponding hash key of the record by applying a hash function (or a
hashing algorithm) on
the primary key of the record. When deriving the hash function to be applied,
the program
takes into account the estimated number of records in the random access file.
2. The program then stores the record at the memory or disk address pointed to
by the hash
key.
3. The program stores the primary keys and the corresponding hash keys in the
hash table
associated with the random access file.
4. The hash keys are written to the hash table at sequential locations until a
collision occurs.
5. A collision occurs when the computer program finds two hash keys with the
same value
competing for the same location in the hash table.
6. Even though the hash keys are stored in the sequential order in the hash
table, the records in
the random access file may not be in the sequential order.

You might also like