0% found this document useful (0 votes)
59 views6 pages

File Organization

File organization determines how records are stored and accessed in a file. There are three main types: sequential access, which stores records sequentially and is best for sequential searching; direct access, which stores records randomly and allows direct access; and indexed sequential access, which combines sequential and direct access using an index for random access. The most appropriate organization depends on the needed access pattern, such as sequential access for records sorted by name or direct access for searching by attributes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views6 pages

File Organization

File organization determines how records are stored and accessed in a file. There are three main types: sequential access, which stores records sequentially and is best for sequential searching; direct access, which stores records randomly and allows direct access; and indexed sequential access, which combines sequential and direct access using an index for random access. The most appropriate organization depends on the needed access pattern, such as sequential access for records sorted by name or direct access for searching by attributes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

File Organization

File organization ensures that records are available for


processing. It is used to determine an efficient file
organization for each base relation.

For example, if we want to retrieve employee records in


alphabetical order of name. Sorting the file by employee
name is a good file organization. However, if we want to
retrieve all employees whose marks are in a certain
range, a file is ordered by employee name would not be a
good file organization.

Types of File Organization

There are three types of organizing the file:

1. Sequential access file organization


2. Direct access file organization
3. Indexed sequential access file organization

1. Sequential access file organization


 Storing and sorting in contiguous block within files on
tape or disk is called as sequential access file
organization.
 In sequential access file organization, all records are
stored in a sequential order. The records are arranged in
the ascending or descending order of a key field.
 Sequential file search starts from the beginning of the
file and the records can be added at the end of the file.
 In sequential file, it is not possible to add a record in the
middle of the file without rewriting the file.
1. Pile File Method:

o It is a quite simple method. In this method, we store the


record in a sequence, i.e., one after another. Here, the record
will be inserted in the order in which they are inserted into
tables.
o In case of updating or deleting of any record, the record will
be searched in the memory blocks. When it is found, then it
will be marked for deleting, and the new record is inserted.

Insertion of the new record:

Suppose we have four records R1, R3 and so on upto R9 and R8 in


a sequence. Hence, records are nothing but a row in the table.
Suppose we want to insert a new record R2 in the sequence, then
it will be placed at the end of the file. Here, records are nothing
but a row in any table.
2. Sorted File Method:

o In this method, the new record is always inserted at the file's


end, and then it will sort the sequence in ascending or
descending order. Sorting of records is based on any primary
key or any other key.
o In the case of modification of any record, it will update the
record and then sort the file, and lastly, the updated record is
placed in the right place.

Insertion of the new record:

Suppose there is a preexisting sorted sequence of four records R1,


R3 and so on up to R6 and R7. Suppose a new record R2 has to be
inserted in the sequence, then it will be inserted at the end of the
file, and then it will sort the sequence.
Advantages of sequential file

 It is simple to program and easy to design.


 Sequential file is best use if storage space.
Disadvantages of sequential file

 Sequential file is time consuming process.


 It has high data redundancy.
 Random searching is not possible.

2. Relative file organization/Direct access file


organization
 Direct access file is also known as random access or
relative file organization.
 In direct access file, all records are stored in direct
access storage device (DASD), such as hard disk. The
records are randomly placed throughout the file.
 The records does not need to be in sequence because
they are updated directly and rewritten back in the same
location.
 This file organization is useful for immediate access to
large amount of information. It is used in accessing large
databases.
 It is also called as hashing.
Advantages of direct access file organization

 Direct access file helps in online transaction processing


system (OLTP) like online railway reservation system.
 In direct access file, sorting of the records are not
required.
 It accesses the desired records immediately.
 It updates several files quickly.
 It has better control over record allocation.
Disadvantages of direct access file organization

 Direct access file does not provide back up facility.


 It is expensive.
 It has less storage space as compared to sequential file.
3. Indexed sequential access file organization
 Indexed sequential access file combines both sequential
file and direct access file organization.
 In indexed sequential access file, records are stored
randomly on a direct access device such as magnetic
disk by a primary key.
 This file have multiple keys. These keys can be
alphanumeric in which the records are ordered is called
primary key.
 The data can be access either sequentially or randomly
using the index. The index is stored in a file and read
into memory when the file is opened.
Advantages of Indexed sequential access file
organization
 In indexed sequential access file, sequential file and
random file access is possible.
 It accesses the records very fast if the index table is
properly organized.
 The records can be inserted in the middle of the file.
 It provides quick access for sequential and direct
processing.
 It reduces the degree of the sequential search.
Disadvantages of Indexed sequential access file
organization

 Indexed sequential access file requires unique keys and


periodic reorganization.
 Indexed sequential access file takes longer time to
search the index for the data access or retrieval.
 It requires more storage space.
 It is expensive because it requires special software.
 It is less efficient in the use of storage space as
compared to other file organizations.

You might also like