Saturday 22 April 2017

File organization, their purpose and various file organization method


 In today post  we are going to discuss following topic:
  1. File Meaning
  2. File Organization 
  3. File Organization Objective
  4. File Organisation Technique/ Method 
  5. And their pros and cons

File

  • Files are a kind of container that is  used for storing the Data of the users for a Long time Period.
  • Files can contain any type of information means they can Store the text, any Images or Pictures or any data in any Format.
  • So that there must be Some Mechanism those are used for Storing the information, Accessing the information and also Performing Some Operations on the files.

File Organization

  • File organization is a way of organizing the data or records in a file.
  • It does not refer to how files are organized in folders, but how the contents of a file are added and accessed.
  • File organization is very important because it determines the methods of access, efficiency, flexibility and storage devices to use.
File organization objective
Storing the files in certain order is called file organization. The main objective of file organization is
  • Optimal selection of records i.e.; records should be accessed as fast as possible.
  • Any insert, update or delete transaction on records should be easy, quick and should not harm other records.
  • No duplicate records should be induced as a result of insert, update or delete
  • Records should be stored efficiently so that cost of storage is minimal.
 File organization technique
There are Various methods of organizing files on a storage media. Some of them are:

  • Sequential,
  • Random,
  • Serial and
  • Indexed-sequential
  • Heap
  • Hash Clustered

  1. Sequential file organization

  • Records are stored and accessed in a particular order sorted using a key field.
  • Retrieval requires searching sequentially through the entire file record by record to the end.
  • Because the record in a file are sorted in a particular order, better file searching methods like the binary search technique can be used to reduce the time used for searching a file .
  • For example, of the file has records with key fields 20, 30, 40, 50, 60 and the computer is searching for a record with key field 50, it starts at 40 upwards in its search, ignoring the first half of the set.
Pros of sequential file organization
  • The sorting makes it easy to access records.
  • The binary chop technique can be used to reduce record search time by as much as half the time taken.
Cons of sequential file organization
  • The sorting does not remove the need to access other records as the search looks for particular records.
  • Sequential records cannot support modern technologies that require fast access to stored records.
  • The requirement that all records be of the same size is sometimes difficult to enforce.

2. Random or direct file organization

  • Records are stored randomly but accessed directly.
  • To access a file stored randomly, a record key is used to determine where a record is stored on the storage media.
  • Magnetic and optical disks allow data to be stored and accessed randomly.
Pros of random file access
  • Quick retrieval of records.
  • The records can be of different sizes.
3. Serial file organization
  • Records in a file are stored and accessed one after another.
  • The records are not stored in any way on the storage medium this type of organization is mainly used on magnetic tapes.
Pros of serial file organization
  • It is simple
  • It is cheap
Cons of serial file organization
  • It is cumbersome to access because you have to access all proceeding records before retrieving the one being searched.
  • Wastage of space on medium in form of inter-record gap.
  • It cannot support modern high speed requirements for quick record access.
4. Indexed-sequential file organization method
  • Almost similar to sequential method only that, an index is used to enable the computer to locate individual records on the storage media. 
  • For example, on a magnetic drum, records are stored sequential on the tracks. However, each record is assigned an index that can be used to access it directly.

5.Heap File Organization

  •  When a file is created using Heap File Organization mechanism, the Operating Systems allocates memory area to that file without any further accounting details.
  • File records can be placed anywhere in that memory area. It is the responsibility of software to manage the records. Heap File does not support any ordering, sequencing or indexing on its own.

Pros of Heap storage

Heap is a good storage structure in the following situations:
  • When data is being bulk-loaded into the relation.
  • The relation is only a few pages long. In this case, the time to locate any tuple is Short, even if the entire relation has been searched serially.
  • When every tuple in the relation has to be retrieved (in any order) every time the relation is accessed. For example, retrieve the name of all the students.

Cons of Heap storage

Heap files are inappropriate when only selected tuples of a relation are to be accessed.

 6. Hash File Organization

  • This mechanism uses a Hash function computation on some field of the records. As we know, that file is a collection of records, which has to be mapped on some block of the disk space allocated to it. 
  • This mapping is defined that the hash computation. The output of hash determines the location of disk block where the records may exist.


Pros of Hash file organization

Hash is a good storage structure in the following situations:
  • When tuples are retrieve based on an exact match on the hash field value, particularly if the access order is random.
  •  For example, if the STUDENT relation is hashed on Name then retrieval of the tuple with Name equal to "Rahat Bhatia" is efficient.

Cons of Hash file organization

Hash is not a good storage structure in the following situations:
  • When tuples are retrieved based on a range of values for the hash field. For example, retrieve all students whose name begins with the "R".

7. Clustered File Organization

  • Clustered file organization is not considered good for large databases. In this mechanism, related records from one or more relations are kept in a same disk block, that is, the ordering of records is not based on primary key or search key. 
  • This organization helps to retrieve data easily based on particular join condition. Other than particular join condition, on which data is stored, all queries become more expensive.

0 comments:

Post a Comment