0% found this document useful (0 votes)
54 views8 pages

2014 Midterm Answer

This document appears to be a mid-semester exam for a Relational Database Systems course. It consists of 5 questions testing students' knowledge of database concepts. The questions cover topics like the three-schema architecture, physical data independence, materialized views, relational schema design, indexing techniques like B-trees, data storage optimizations, and performance analysis of different data access methods. The exam is closed book and students have 120 minutes to complete it.

Uploaded by

brip sel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views8 pages

2014 Midterm Answer

This document appears to be a mid-semester exam for a Relational Database Systems course. It consists of 5 questions testing students' knowledge of database concepts. The questions cover topics like the three-schema architecture, physical data independence, materialized views, relational schema design, indexing techniques like B-trees, data storage optimizations, and performance analysis of different data access methods. The exam is closed book and students have 120 minutes to complete it.

Uploaded by

brip sel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

STUDENT

NUMBER:

_____________________________
STUDENT NAME: Family Name

_____________________________
First Name

Mid Semester EXAMINATION


St Lucia Campus Semester One 2014

INFS2200/7903 – Relational Database Systems

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

Permitted Calculator Yes - Non-programmable calculators only


Materials:

– No electronic aids are permitted (e.g. laptops,


phones)
Answer: (Where Answers are to be written on the examination paper
students should
write answers)

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.2) [1 mark] Explain what is meant by physical data independence

Physical data independence provides protection from changes in physical data


structure and it is achieved by conceptual scheme. Examples of such changes:
add/drop index, change file order

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:

Hotel(hotelNo, hotelName, city)


Room (roomNo, hotelNo, type, price)
Guest(guestNo, guestName, guestAddress)
Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)

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), or(hotelNo, guestNo, roomNo)?

(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:

• Type must be one of Single, Double, or Family.


• Price must be between $10 and $100.

CREATE DOMAIN RoomType AS CHAR(1)


CHECK(RoomType IN (‘S’, ‘F’, ‘D’));
CREATE DOMAIN RoomPrice AS INT
CHECK(RoomPrice BETWEEN 10 AND 100);

CREATE TABLE Room(


roomNo INT NOT NULL,
hotelNo INT NOT NULL,
type RoomType NOT NULL DEFAULT ‘S’
price RoomPrice NOT NULL,
PRIMARY KEY (roomNo, hotelNo),
FOREIGN KEY (hotelNo) REFERENCES Hotel
ON DELETE CASCADE ON UPDATE CASCADE);

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?

A multi-level index is a static structure. Hence, an Insert/delete of an index entry is a


problem because every level of the index is ordered.
Because of that problem, most multi-level indexes use dynamic B+-trees. A B+ tree
overcomes the insert delete/delete problem by leaving space in each tree node. In
particular, each node is kept between half-full and completely full, which allows for efficient
insertion and deletion of search values

3.4) [1 mark] Compare the advantages and limitations of data mirroring and partitioning

Data partitioning:

Pros: increased access rate

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

Pros: Doubles read rate

Pros: Does not have the problem of request collisions

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

• An index block can have up to 100 entries


What is the minimum possible number of levels such an index can have? Explain your
answer.

The table has 100000/20 = 5000 blocks.


The minimum number of levels will result if the nodes of the tree are maximally packed.
Thus, the minimum depth is:
ceiling(logfo #of blocks) = ceiling(log100 5000) = 2.

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.

Average access time =


# of blocks * (avg. seek time + avg rotational delay + block transfer time)
20 * (20 + 5 + 1) = 520 msec

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.

4.2.A) [2 marks] The data file is unsorted and has no index.

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

Consider the following configuration:

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.

5.1) [2 marks] Calculate the number of data file blocks.

Data file blocking factor = floor(512/100) = 5


# of blocks = # of records / blocking factor = 30,000/5 = 6,000

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.2) [2 marks] Calculate the index file blocking factor.

Index entry size = key + pointer = 10 + 6


Index blocking factor = block size / entry size = 512/16 = 32

5.3) [2 marks] Calculate the number of index entries and the number of index blocks.

# of index entries = number of data blocks = 6,000


# of index blocks = # of index entries / index blocking factor = 6,000/32 = 188

Page 8 of 8

You might also like