6: Costs in File Handling Flashcards

1
Q

How are files stored on a disk?

A

Similar to a relational table, they also have indexes associated with them, and are stored on the disk to improve efficiency of retrieval.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the steps for storing a file or index on a disk ?

A
  1. Formatting disk
  2. Dividing disk into pages (equal size blocks, between 512 to 4096 bytes)
  3. The block forming the unit of transfer between disk (secondary storage) and main memory (primary storage in buffers). Buffer size = 1 block.

Can hold more from secondary storage - ‘cluster’ - several contiguous blocks on disk which can be transferred as a single unit to be held in one buffer. This can be done by adjusting the byte-size of the buffer to match the byte-size of the cluster. (magic)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is spanned organisation ?

A

When part of a record is stored in one block and a pointer is used within the block to point to the rest of the record in another block.

Used for variable length records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s an unspanned organisation ?

A

When a record must fit entirely within one block ie record-size cannot exceed block-size.

Used for fixed-length records, ie when B>=R. (Can also be used for variable-length records).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is data held in a block on a disk found ?

A

By using an address, that specifies the:

  • Surface number
  • Track number (within the surface)
  • Block number (within the track)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How long does it take to retrieve a block and store it in a buffer ?

A

It takes the sum time of the following actions:

  • Seek time: taken to move read/write head over the track required in the address
  • Rotational Delay (latency): time taken for the beginning of the block required in the address to rotate into position under the read/write head.
  • Block Transfer time: taken to transfer the data block to the buffer

Total retrieval time = seek time + latency + block transfer time.

Usually seek time and latency are much larger than block transfer time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the factors to consider when calculating the costs of storing records?

A
  • Block Size B [bytes]
  • Record Size R [bytes]
  • Blocking Factor B/R [bfr] ie the number of records in a block, rounded down
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How many blocks are needed to store the file on disk? Given:

  • Block Size (B) = 512 bytes
  • Record Size (R) (fixed length) = 128 bytes
  • Relation (‘File’) Size (F) = 50 records
A

50*128 = 6400 bytes in total required.

6400/512 = 12.5 blocks required => 13 in total, 12 full blocks holding 4 records per block, plus 1 block extra to hold the remaining 2 records.

512/128 = 4 records in one block
50/4 = 12.5 = 13 blocks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How many blocks are required to store an index on disk for the relation given?

  • Block Size (B) = 512 bytes
  • Record Size (R) (fixed length) = 128 bytes
  • Relation (‘File’) Size (F) = 50 records

There is one index entry per block:
Key-Field Size = 20 bytes
Pointer-Field Size = 10 bytes

A

20 + 10 = 30 extra bytes per block.

We have 13 blocks: 30*13 = 390 bytes.

390/512 = 0.762 => 1 block

128+30 = 158 bytes

158*50 = 7900

7900/512 = 15.5 bytes/block

Therefore, we need 15.5-12-5 = 3 records to store an index of 30 bytes per block.

3/4 = 0.75 => 1 block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the cost (in terms of blocks) to store the following file on disk:

Block Size = 512 bytes
Record Size (fixed length) = 75 bytes
Relation Size = 325 records
A

75*325 = 24375 bytes

24375/512 = 47.6 => 48 blocks required.

512/75 = 6.826 records per block => 6 rounded DOWN
325/6 = 54.1 => 55 blocks rounded UP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the cost (in terms of blocks) to store the following file on disk:

Block Size = 512 bytes
Record Size (fixed length) = 75 bytes
Relation Size = 325 records

Index Entry = 1 per block Key-Field size = 25 bytes Pointer-Field Size = 10 bytes

A

55 * 35 = 1925

1925/512 = 3.7597 => 4 blocks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly