Skip to main content

File Organization

      TAP  HERE


File Organization

File : It maintain the records /details about specific activity. Eg : admission file A file is a sequence of related records. 

File organization: It is a method which mention about physical arrangement of data. 

Record : It is collection of related fields.

 • Fields: It is a single character or group of characters. Eg : A , rno,name 

Character : smallest element. Eg :1 ,2 ,a ,b ,&,*


Physical and Logical File

Physical File SystemLogical File System
Physical files have the real data saved on an iSeries system and describe how the data is to be displayed to or retrieved from a program.The logical file represents or perspective of one or multiple physical files. Logical files don't have data. They have a description of the records found in one or multiple physical files.
It takes up space in memory, and it includes the original data.It doesn't take up any memory space. It does not include data.
It exists without a Logical file.A logical file cannot exist without a physical file.
The CRTPF command is utilized to make such an object in a physical file.The CRTLF command is utilized to make such an object in a logical file system.
If there is a logical file for a physical file, the physical file may not be erased until the logical file is deleted.If a physical file has a logical file, the logical file can be removed without deleting the actual file.
The physical file system has one record format.The logical file system may include up to 32 record formats.

Record Organization

A file is a collection of logically related records. Depends on length of Record : 

A)Fixed –Length Records : Every record in the file is equal in size. 

B)Variable –Length Records : Different records in the file do not have equal size. 


Fixed length record

Advantages :     1. Accessing record is easy

                           2. Insertion and deletion is easy. 

Disadvantages:    1. Wastage of memory

                                2. To fill up blank spaces created by deletion is difficult

Difference between Fixed and Variable length Record

Fixed length record

Variable Length Record

Every record have equal length

Different length

Access to record is fast

Record accessing is slow

Memory wasted

Memory is saved

Insertion and deletion is easy

Insertion and deletion is difficult



File Organization  


1: Heap File
• A file is a collection of logically related records. 
• Simplest way .
• Records are stored in the file as they are inserted . 
• The new records are appended to the end of the file . 
• It is an unordered file. 

Advantages :❑ Simple 

                       ❑ Space is utilized.     

                       ❑ Insertion of record is easy.

Disadvantages :❑ Searching record is slow. 

                             ❑ Cost to update record is high . 

                             ❑ Deletion create wastage of space. 


2: Sorted File :

  • Search Key : The field whose value determines how to insert record. 
  •  Search key is used to arrange record in sequential order. 
  • Sequential or ordered file organization . 
  •  Eg: Employee table and search key: Emp_id

Advantages : ❑ Accessing next record is easy. 
                        ❑ Simple . 
                        ❑ Every record is sorted .

Disadvantages : ❑ Insertion and deletion is expensive. 
                              ❑ Deletion creates wastage of space.


3: Indexed file :

  • A sequential file that is indexed is called as indexed sequential file. 
  •  Records are sorted on disk sequentially by key value. 
  • Indexes are also maintained to allow direct retrieval based on key value. 
  • A separate file stores the data in the order of primary key value. 
  •  Another file is maintained o store index entries . 
  • Two fields : key value ,pointer .

Advantages

Disadvantages

The desired record can be immediately accessed

The files have to be recognized periodically to discard deleted records

Faster access

Back up required

Primary and secondary indexed is used to search the data

Extra overload of maintaining additional DS



4: Hashed File : 

❑ Hash function is applied to a particular filed to find the position of a record on a disk. 
❑ Eg : roll_no =1 to 100 
❑ Hash function : h(f) =n ^ 100 = 10^100 =1000 
❑ Random Access file organization 
❑ In DBMS, hashing is a technique to directly search the location of desired data on the disk without using index structure. 
❑ Hashing method is used to index and retrieve items in a database as it is faster to search that specific item using the shorter hashed key instead of using its original value. 
❑ Data is stored in the form of data blocks whose address is generated by applying a hash function in the memory location where these records are stored known as a data block or data bucket.



Sr

Heap file

Indexed file

1

Searching is slow

Searching is fast.

2

No extra overload.

Extra overload

3

Not recognized periodically.

Recognized periodically.

4

Useful: data is collected prior bases.

Useful: commercial data access.



Heap file

Hashed file

Pile /serial

Random Access file

Data Insert: As come

Insert: Hash function

Search: sequentially : slow

Searching : Direct :fast

Insert :Append : fast

Insert : slow

Overhead

Hash field: change ,overhead



Comments

Popular posts from this blog

Introduction to DBMS

 Database Management System (DBMS) • Collection of interrelated data  • Set of programs to access the data  • DBMS contains information about a particular enterprise  • DBMS provides an environment that is both convenient and efficient to use.  • Database Applications: • Banking: all transactions                                                          • Airlines: reservations, schedules                                                        • Universities: registration, grades                                       ...

Structure of Relational Databases

STRUCTURE OF RELATIONAL DATABASE What is Relational Model? Relational Model represents how data is stored in Relational Databases. A relational database stores data in the form of relations (tables). Consider a relation STUDENT with attributes ROLL_NO, NAME, ADDRESS, PHONE and AGE. Table : 2-Dimensional structure .(rows and columns) Attribute : Attributes are the properties that define a relation. e.g.; ROLL_NO, NAME  Relation Schema : A relation schema represents name of the relation with its attributes. e.g.; STUDENT (ROLL_NO, NAME, ADDRESS, PHONE and AGE) is relation schema for STUDENT. If a schema has more than 1 relation, it is called Relational Schema.  Tuple : Each row in the relation is known as tuple.  Relation Instance : The set of tuples of a relation at a particular instance of time is called as relation instance. Table 1 shows the relation instance of STUDENT at a particular time. It can change whenever there is insertion, deletion or updation in the databa...