Uploaded by karammah28

025611871

advertisement
Ex1. File Storage + Indexing
1. Consider the deletion of record 5 from the file of Figure 1. Compare the relative
merits of the following techniques for implementing the deletion:
a. Move record 6 to the space occupied by record 5, and move record 7 to the space
occupied by record 6.
b. Move record 7 to the space occupied by record
5.
c. Mark record 5 as deleted, and move no
Figure 1
records.
2. Show the structure of the file of Figure 2 after
each of the following steps:
a. Insert (24556, Turnamian, Finance, 98000).
b. Delete record 2.
c. Insert (34556, Thompson, Music, 67000).
Figure 2
3. Given the following Database:


Play (Title : 40 bytes, Director Name: 20 bytes, Year: 4 bytes, Company: 20 bytes)
Staff (ID: 4 bytes, Name: 20 bytes, DoB: 4 bytes)
There exist 30,000 Plays in the database and 100,000 staff members working in these
plays. Each page is 512 bytes and each pointer is 6 bytes. The blocking factor of a file (bfr)
is the number of records that fit in a page.
a) What is the blocking factor for Play relation (bfrP ) and for Actor relation (bfrS )?
b) Assuming that the Play relation is sorted on the Title and there is no index, what is
the cost (in terms of page reads) for finding the Play with title “Gone with the
Wind”?
c) Assuming that the Play relation is sorted on the Title and there is no index, what is
the cost (in terms of page reads) for finding all the plays which “David Lung” works
in?
d) Assume that the Staff relation is sorted on the name and you want to create an
ordered index on ID (each index entry has the form <ID, pointer>).
 What is the blocking factor for the index (single-level)?
 How many index entries do you need?
 How many pages are required for these entries?
 What is the cost of retrieval based on a single id using this organization (e.g., “Find
staff with id=100”)?
 What is the cost of answering the query “Find staff with id=100”?
Download