Last Updated : 29 Nov, 2018

Consider a database table which has 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. Assume we allow record spanning. Records are fixed size, but since we can have record fragments we need to add a 5-byte header to every fragment to store its length (and other information). (The block header is still 24 bytes.) Suppose we have 2 blocks of 1024 bytes each, we would like to store 3 records of 600 bytes each. We first allocate as much as we can of the records into the first block and then use space from the second block. After the 3 records are stored, how many bytes are still available in the second block?
(A) 0
(B) 90
(C) 180
(D) None of these.


Answer: (C)

Explanation: Record 2 is split into fragments 2-a and 2-b. Block 1 has room for 390 bytes of record 2-a (1024-24-5-600-5). Block 2 needs to store 210 bytes of record 2-b. Block 2 also needs to store block header, record 3, and two record headers (for record 2-b and 3). Therefore, 180 bytes (1024-24-5-210-5-600) are still available in block 2.
So, option (C) is correct.

Quiz of this Question


Share your thoughts in the comments