File Structure
File organization: It is the logical relation between records and it defines how file records are mapped into disk blocks(memory). A database is a collection of files, each file is a collection of records, and each record contains a sequence of fields. The blocking Factor is the average number of records per block.
Strategies for storing files of records in block:
- Spanned Strategy: It allows a partial part of the record to be stored in the block. It is suitable for variable-length records. No wastage of memory in spanned strategy but block access time gets increases.
- Unspanned Strategy: Data cannot be stored partially, the whole block will be occupied, this can lead to internal fragmentation and wastage of memory but block access time is reduced. This is suitable for fixed-length records.
File organizations is of following types:
Sequential File: In this method, files are stored in sequential order one after another.
- Blocking factor: [Tex]\left \lfloor \frac{Block\ Size}{Record\ Size} \right \rfloor [/Tex]
- Number of record blocks: [Tex]\left \lceil \frac{Total\ number\ of\ records}{Blocking\ factor} \right \rceil [/Tex]
- Average number of blocks accessed by linear search: [Tex]\left \lfloor \frac{number\ of\ record\ blocks}{2} \right \rfloor [/Tex]
- Average number of blocks accessed by binary search: [Tex]\left \lfloor { log_2 \ number\ of\ record\ blocks} \right \rfloor [/Tex]
Index File:
- Index blocking factor: [Tex]\left \lfloor \frac{number\ of\ record\ blocks \ +\ 1}{2} \right \rfloor [/Tex]
- First level index block: [Tex]\left \lfloor \frac{number\ of\ record\ blocks}{index\ blocking\ factor} \right \rfloor [/Tex]
- Number of block accesses: [Tex]\left \lfloor { log_2 \ (first\ level\ index\ blocks)} \right \rfloor + 1 [/Tex]
Last Minute Notes – DBMS
Database Management System is an organized collection of interrelated data that helps in accessing data quickly, along with efficient insertion, and deletion of data into the DBMS. DBMS organizes data in the form of tables, schemas, records, etc.
DBMS over File System
The file system has numerous issues, which were resolved with the help of DBMS, the issues with the file system are:
- Data Redundancy: Same data can be stored at multiple places.
- Data Inconsistency: If multiple copies of the same data have different content in each copy. Like, the phone number of students is different in academic and accounts files.
- Data access: In a file system, accessing data was difficult and insecure as well. Accessing data concurrently was not possible.
- No Backup and Recovery: There is no backup and recovery in the file system that can lead to data loss.