A database is a collection of large amount of related data. In case of RDBMS (Relational Database Management System), the data is stored in the form of relations or tables. As a normal user, we see the data stored in tables but actually this huge amount of data is stored in the form of files in physical memory.
A File is a collection of related records stored on the secondary storage such as magnetic disks in binary format. There are various strategies for mapping file records into blocks of disk:
1. Spanned Mapping:
In spanned mapping, the record of a file is stored inside the block even if it can only be stored partially and hence, the record is spanned over two blocks giving it the name Spanned Mapping.
- Advantages: No wastage of memory (no internal fragmentation).
- Disadvantages: The record which has been spanned, while accessing it we would be required to access two blocks and searching time of a block is greater than the searching time of a record inside a block as the number of blocks on the disk are too large.
2. Unspanned Mapping:
In unspanned mapping, unlike spanned strategy, the record of a file is stored inside the block only if it can be stored completely inside it.
- Advantages: Access time of a record is less. It is because in spanned mapping, for accessing the spanned record we were required to access two blocks and as we know accessing time of a block is much higher than that of a record. But in unspanned mapping, for a single record we need to access only a single block every time and hence, it is faster.
- Disadvantages: Wastage of memory is more (internal fragmentation).
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.