Showing posts with label Disk Storage Access Exercises. Show all posts
Showing posts with label Disk Storage Access Exercises. Show all posts

Saturday, 10 February 2018

Find the number of records and record size for storing data in one disk block

Find the number of records and record size for storing data in one disk block, How to calculate block size, How to calculate record size, calculate the number of records fit in one disk block in database management system


Question:

6. Suppose blocks of 1024 bytes are used to store variable-length records. The fixed part of the block header is 24 bytes, and includes a count of the number of records. In addition, the header contains a 4-byte pointer (offset) to each record in the block. The first record is placed at the end of the block, the second record starts where the first one ends, and so on. The size of each record is not stored explicitly, since the size can be computed from the pointers.
(i) How many records of size 50 bytes could we fully fit (no spanning) in such a block? (The block is designed to hold variable size records, but these records by coincidence happen to be all the same size.)
(ii) Suppose we want to store 20 records in the block, all of the same fixed size. What is the size of such records?
(iii) Now assume the block layout is changed to accommodate only fixed size records. In this case, the block header is still 24 bytes and contains the common length of the records in the block.
How many records of size 50 bytes could we fully fit in such a block?

(a) 20 records, 50 bytes, 20 records
(b) 18 records, 46 bytes, 20 records
(c) 20 records, 46 bytes, 25 records
(d) 50 records, 50 bytes, 20 records

Answer:
(b) 18 records, 46 bytes, 20 records

(i) Given,
Block size – 1024 bytes
Block header size – 24 bytes
Record size – 50 bytes
Pointer to each record – 4 bytes
Number of records = floor {Block size / records} ----- Eq. 1
But in the given case, we need to consider the block size after deducting the header size. And for each record we need to add 4 bytes pointer size because it is given that pointer for each record. Hence Eq 1 is now as follows;
Number of records = floor {(Block size – Header size) / (Record size + Pointer size)}
Number of records = floor { (1024 – 24) / (50 + 4)} = 18 records

(ii) For finding the size of record, we need to find the size left with us in each block. When we deduce the block header size and the size required for 20 pointers from block size, what we get is the size completely available for storing records.
(Block size – Header size – 4*20) will give us the available block space
Number of records = floor { (1024 – 24 – 4 * 20) / x}
20 = floor { (1024 – 24 – 4 * 20) / x}
x = floor { (1024 – 24 – 4 * 20) / 20} = floor{980/20} = 46 bytes

(iii) In this case, the record size becomes fixed. Hence, we do not need pointers to each record. The extra memory 4 bytes can be saved. The number of records can be calculated using Eq. 1 as follows;
Number of records = floor {(Block size – Header size) / Record size}
Number of records = floor { (1024 – 24) / 50} = 20 records



         Previous Question                                                                                Next Question






Wednesday, 7 June 2017

Find the transfer rate of and capacity of a hard disk

Find the transfer rate of and capacity of a hard disk in DBMS, How to find the data transfer rate and the capacity of hard disk for efficient storage access in dbms?


Question:

5) Consider a disk with the following specifications: 512 bytes sector size, 8 double sided platters (2 surfaces per platter), 5000 tracks per surface, 100 sectors per track, average seek time of 10 msec, and the disk rotates at 5400 revolutions per minute (rpm). Which of the following is the correct combination of number of cylinders, average rotational delay, and transfer rate (if an entire track of data can be transferred per revolution of disk)?


a) 5000 cylinders, 5.55 milliseconds, 4.5 KB
b) 5000 cylinders, 4.5 milliseconds, 12 KB
c) 4000 cylinders, 5.55 milliseconds, 10 KB
d) 4000 cylinders, 2 milliseconds, 2.5 KB

Answer:




a) 5000 cylinders, 5.55 milliseconds, 4.5 KB

Discussion:


Given,
Number of platters                -        8
Tracks per disk surface         -        5000
Sectors per track                    -        100
Sector size                               -        512 bytes
Average seek time                -        10 msec
rpm                                        -        5400.

Number of cylinders is same as the number of tracks. Hence, the number of cylinders is 5000.
The average rotational delay is half of the rotation time. One complete rotation takes 1/5400 in a minute = (1/5400) * 60 seconds = 0.0111 seconds = 11.1 milliseconds. The average rotational delay = 11.1/2 = 5.55 msec (approx).
We need the capacity of the track to find the transfer rate. The capacity of the track can be found as follows;
Number of bytes per track = bytes per sector * sectors per track
                                                = 512 * 100 = 51200 bytes = 50 KB.
We know that, from above, the time for one complete rotation is 11.1 milliseconds. Hence, the transfer rate is 50 KB/11.1 milliseconds = 4.5 KB/msec (approx.).







         Previous Question                                                                                Next Question

Tuesday, 28 March 2017

Find the capacity of the hard disk

Find the capacity of a hard disk in database, How many recrods can be stored in a hard disk track? Which of the following is the correct combination of capacity of track, capacity of each surface, and capacity of disk?


Question:




4) Consider a disk with a sector size of 512 bytes, 14409 tracks per surface, 16947 sectors per track, 8 double-sided platters, and an average seek time of 9 ms. Which of the following is the correct combination of capacity of track, capacity of each surface, and capacity of disk (approximately)?

a) 100 MB, 200 GB, and 2 TB
b) 8 MB, 116 GB and 2 TB
c) 8 MB, 200 GB and 1 TB
d) 80 MB, 116 GB and 1 TB


Answer:






b) 8 MB, 116 GB and 2 TB

Discussion:


Given,
          Sector size                                                  - 512 bytes
          Number of sectors per track                    – 16947
          Number of tracks per surface                  14409
          Number of platters                                   8 double-sided
         
Answer:
Capacity of a track = sector size * number of sectors per track
                                 = 512 * 16947 = 8 MB approx.
Capacity of each surface = capacity of track * number of tracks per surface
                                          = (512*16947) * 14409 = 116 GB approx.
Capacity of the disk = capacity of each surface * number of platters * number  of pages per platter
                                   = 116 GB * 8 * 2 = 2 TB approx. 







         Previous Question                                                                                Next Question


Simple introduction to Naive Bayes classifier

Simple introduction to Naive Bayes classifier What is Naive Bayes Classifier? A Naive Bayes classifier is a probabilistic classifier ...