Storage and File Structure (40 points)

advertisement
Part III. Storage and File Structure (40 points)
1. (2 points) Volatile memory is used in databases
a) to keep user data permanently
b) to keep user data temporarily
c) to keep system data permanently
d) to keep data temporarily
e) none of the above
2. (2 points) What types of volatile memory are used in databases?
Main memory, cache memory
3. (2 points) Disk cylinder consists of same numbered
a) sectors
b) surfaces
c) tracks
d) bytes
e) none of the above
4. (2 points) Remapping of bad sectors is a responsibility of
a) database administrator
b) user
c) application
d) disk controller
e) none of the above
5. (2 points) Redundant arrays of independent disks
a) increase seek time
b) decrease seek time
c) increase performance
d) decrease performance
e) none of the above
6. (2 points) Disk fragmentation means
a) partitioning of disk into parts
b) splitting of surfaces into tracks
c) not contiguous allocation of files
d) usage of disk fragments
e) none of the above
7. (2 points) In RAID level 1 (mirroring) each block-write operation requires
a) 2 additional block-read operations
b) 1 additional block-write operation
c) 2 additional block-write operations
d) 2 additional block-read and 1 additional block-write operations
e) none of the above
8. (2 points) In RAID level 5 each block-write operation requires
a) 2 additional block-read operations
b) 1 additional block-write operation
c) 2 additional block-write operations
d) 2 additional block-read and 1 additional block-write operations
e) none of the above
9. (2 points) Rate of data transfer for hard disks is about 10
f) KByte/sec
g) MByte/sec
h) GByte/sec
i) TByte/sec
j) none of the above
10. (2 points) Rate of data transfer for magnetic tapes is about 10
a) KByte/sec
b) MByte/sec
c) GByte/sec
d) TByte/sec
e) none of the above
11. (4 points) Assume, there are now 6 pages P28, P1, P2, P3, P21, P79 in database
buffer, which were last time used 1,2,3,3,4,5 milliseconds ago,
respectively. There is a request for database page P29. Show contents of
the buffer after its loading, if MRU strategy is used and all slots in the
buffer are occupied now (no free slots).
P29, P1, P2, P3, P21, P79
12. (6 points) Assume, list of deleted records is maintained in the file; it has now the
following records: record9, record5, record4, record10, record6 in the
given order.
a) What record was deleted last? Record 9
b) What record is referred to now by the header? Record 9
c) Where will be inserted next record? Record 9
13. (4 points) Assume, slotted-page structure (for keeping variable length records) size is
1024 bytes.
a) Has it enough room to accommodate 4 records of sizes 256, 512, 128,
128? No
b) How many free bytes will be in this slotted page after insertion of 2
records of sizes 128, 256?
1024- (128+256)-3*sizeof(SlotStructureEntry)
14. (6 points) Assume, we have sequential file account, ordered on attribute
branch_name, with 4 records: (A1, Downtown,10), (A2, Perryridge, 20),
(A13, Downtown, 30), (A21, RoundHill, 20). Physical order is the same as
logical, at first.
a) Show physical and logical (by pointers) order of file records
Header: 1
Record# Account# Branch_name Balance
Pointer
1
A1
Downtown
10
2
2
A13
Downtown
30
3
3
A2
Perryridge
20
4
4
A21
Roundhill
20
null
b) Show file after insertion of (A22, Clearview, 30)
Header: 5
Record# Account# Branch_name Balance
1
A1
Downtown
10
2
A13
Downtown
30
3
A2
Perryridge
20
4
A21
Roundhill
20
5
A22
Clearview
30
Pointer
2
3
4
Null
1
c) Show file after deletion of (A2, Perryridge, 20) in original file with 4 records
(deleted records are marked as deleted).
Header: 1
Record# Account# Branch_name Balance
Pointer
1
A1
Downtown
10
2
2
A13
Downtown
30
4
3
A2
Perryridge
20
4
4
A21
Roundhill
20
null
Part IV. Ordered Indices (10 points)
In tasks of this part assume, we have sequential file account, ordered on attribute
branch_name, with 4 records: (A1, Downtown,10), (A2, Perryridge, 20), (A13,
Downtown, 30), (A21, RoundHill, 20). Physical order is the same as logical, at first.
1. (3 points) Show data file and dense primary index for it
SearchKey
Downtown
Perryridge
Roundhill
Pointer
1
3
4
Record#
1
2
3
4
Account#
A1
A13
A2
A21
Branch_name
Downtown
Downtown
Perryridge
Roundhill
Balance
10
30
20
20
Pointer
2
3
4
null
2. (3 points) Show data file and secondary index file for it, built on attribute balance
SearchKey Bucket
of
pointers
10
1
20
3, 4
30
2
Record# Account# Branch_name Balance Pointer
1
2
3
4
A1
A13
A2
A21
Downtown
Downtown
Perryridge
Roundhill
10
30
20
20
2
3
4
null
3. (4 points) Show data file and sparse primary index file for it with 1 index entry per
block. Assume that 1 block can accommodate 2 records. Show blocks by rectangles with
enclosed records.
SearchKey Pointer
to
block
Downtown Block1
Perryridge Block2
Block# Record# Account# Branch_name Balance Pointer
Block1 1
2
Block2 3
4
A1
A13
A2
A21
Downtown
Downtown
Perryridge
Roundhill
10
30
20
20
2
3
4
null
Download