2014 Midterm Answer
2014 Midterm Answer
NUMBER:
_____________________________
STUDENT NAME: Family Name
_____________________________
First Name
PERUSAL TIME
WRITING TIME 120 mins
EXAMINER Dr. Mohamed Sharaf
THIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM
Examiner’s use
ONLY
Exam Type: Closed Book Question Mark
Other
Instructions:
Total Number of
Questions: (for the 5
whole examination)
Total Number of 25
Marks
TOTAL
Students must comply with the General Award Rules 1A.5 and 1A.7 which outline the responsibilities of students during an examination.
INFS2200/7903: Relational Database Systems – Mid Semester Exam, Semester 1, 2014
Question 1:
1.1) [1 mark] List (without explanation) the three levels of abstraction in a DBMS (i.e.,
the three-schema architecture).
1. External Schema
2. Conceptual Schema
3. Physical Schema
1.3) [1 mark] Briefly explain what are the advantages of a materialized view?
Materialized views are Stored tables, in which the DBMS physically stores the view
(query) and its data
Advantages: avoid re-computing the view with every query. This is especially useful
when more queries can use the same view
Page 2 of 8
INFS2200/7903: Relational Database Systems – Mid Semester Exam, Semester 1, 2014
Question 2:
In the relational schema defined above: Hotel contains hotel details and hotelNo is the
primary key; Room contains room details for each hotel and (roomNo, hotelNo) forms the
primary key; Guest contains guest details and guestNo is the primary key; Booking
contains details of bookings.
2.1) [1 marks] In your opinion, which of the following is a more suitable primary key for the
Booking table? Justify your answer.
(hotelNo, guestNo, dateFrom) is a suitable primary key because it is unique for each
booking, whereas (hotelNo, guestNo, roomNo)could be duplicated if the same guest stays
at the same room in multiple visits
2.2) [3 marks] Write all the DDL statements necessary to create the Room table. In
addition to the specifications described above, your statements should also enforce the
following constraints:
Page 3 of 8
INFS2200/7903: Relational Database Systems – Mid Semester Exam, Semester 1, 2014
Question 3:
3.1) [1 mark] What is a block anchor? And what is its usage in the implementation of a
primary index?
A block anchor is the first record in each block of the data file.
In a primary index, each entry in the index points to one block anchor. This has the
advantage that a primary index will have much less entries than the number of data
records. Thus, an index is stored in much fewer blocks, which makes a binary search on
primary index very efficient.
3.2) [1 mark] If you have a large file that is frequently scanned sequentially; explain an
efficient scheme to store the blocks of that file on a disk.
Store such blocks next to each other using the “Next” block concept:
blocks on same track, followed by blocks on same cylinder, followed by blocks on adjacent
cylinder
Page 4 of 8
INFS2200/7903: Relational Database Systems – Mid Semester Exam, Semester 1, 2014
3.3) [1 mark] Explain what are the advantages of a B+ tree over a multi-level index?
3.4) [1 mark] Compare the advantages and limitations of data mirroring and partitioning
Data partitioning:
Cons: if popular data is stored on same disk, it might lead to request collisions (hot spots)
Cons: the cost of several small disks is greater than a single one with the same capacity
Data Mirroring
Cons: Expensive -- Pay the cost for two disks to get the storage of one
Page 5 of 8
INFS2200/7903: Relational Database Systems – Mid Semester Exam, Semester 1, 2014
3.5) [2 marks] Assume that you have a multi-level primary index on a table of 100,000
tuples where
• A block can hold 20 data tuples
Page 6 of 8
INFS2200/7903: Relational Database Systems – Mid Semester Exam, Semester 1, 2014
Question 4:
4.1) [2 marks] Consider a disk with the following characteristics:
Block size (B) = 512 bytes,
Average seek time (s) = 20 msec.
Average rotational delay (rd) = 5 msec,
Block transfer time (btt) = 1 msec,
Calculate the average time it takes to transfer 20 blocks that are stored at random
locations on disk.
4.2) A table has 100,000 rows and each row occupies 200 bytes. The table is stored on a
disk, which has 4000 bytes per block. Compute and explain the maximum (worst case)
cost (i.e., number of I/O operations) of doing an equality search on the primary key
assuming the following access methods.
The data file has (105 ∗ 200)/(4 ∗ 103) blocks = 5000 blocks
In the worst case the entire file has to be searched costing 5000 I/O operations
4.2.B) [2 marks] The data file is sorted on the primary key and has no index.
Use binary search. Cost = log25000. Hence worst case is 13 I/O operations.
Page 7 of 8
INFS2200/7903: Relational Database Systems – Mid Semester Exam, Semester 1, 2014
Question 5
A disk with block size (B) = 512 bytes, a block pointer (P) = 6 bytes long, and an
EMPLOYEE file has r=30,000 records of fixed-length where the size of each record is 100
bytes. Answer the following assuming an unspanned organization.
Suppose the file is ordered by the key field eID, whose size is 10 bytes, and we want to
construct a primary index on eID.
5.3) [2 marks] Calculate the number of index entries and the number of index blocks.
Page 8 of 8