Documente Academic
Documente Profesional
Documente Cultură
. Viktor and Iluju Kiringa 21 April 2012 09:h30-12h30 Duration: 3 hrs Closed book; no aid allowed, except one double-sided letter-size cheat sheet. Answer all questions in ink. Good luck! / Bonne Chance!
Family name:
First name:
Student number:
There are 6 questions and a total of 100 points. This exam must contain 16 pages, including this cover page. 1 EER Diagram 2 Relational Algebra and Relational Calculus 3 The Relational Model and SQL 4 Normal Forms 5 Physical database design 6 Storage and Indexing Total / 15 / 15 / 15 / 20 / 15 / 20 / 100
Page 2 of 16
... Contd
Page 3 of 16
... Contd
Page 4 of 16
Nurse(nid : int, nname : string, age : real, salary : real, sid : int) Supervisor (sid : int, rating : real) W orksIn(nid : int, hid : int, hours : real) Hospital(hid : int, hname : string, tid : int) T own(tid : int, tname : string, mayor : string) Part A 4 points Provide the relational algebra expression to display the names and salaries of all nurses who do not work at any hospital.
Part B 5 points Provide the relational algebra expression to display the names of all nurses, younger than 30 years old, who worked at all the hospitals that are based in a town called Campbellford.
... Contd
Page 5 of 16
Part C 3 points Explain, by means of your own example, the main difference between tuple and domain relational calculus.
... Contd
Page 6 of 16
Nurse(nid : int, nname : string, age : real, salary : real, sid : int) Supervisor (sid : int, rating : real) W orksIn(nid : int, hid : int, hours : real) Hospital(hid : int, hname : string, tid : int) T own(tid : int, tname : string, mayor : string) Part A 3 points Explaining a Query Consider the following query and explain what data it retrieves. SELECT nname FROM Nurse N WHERE NOT EXISTS ( (SELECT FROM WHERE EXCEPT (SELECT FROM WHERE
... Contd
Page 7 of 16
Part B 4 points Explain how views may be used to ensure logical data independence.
Part C 8 points (SQL Queries) 1. Write the following query in SQL: For each Hospital in which more than 100 nurses work, nd the hospital name, and the number of nurses who work in the hospital. (4 points)
... Contd
Page 8 of 16
2. Write the SQL integrity constraint (primary/foreign key, check, assertion or any other) to ensure each one of the following requirements: Every supervisor must also be a nurse. (2 points)
... Contd
Page 9 of 16
Name John Smith John Smith John Smith John Smith Ann Doe Ann Doe Sam Watson
A. (8 points) This table may be susceptible to a number of data inconsistencies, due to information redundancy. Explain, by means of your own examples with reference to the BigTeeth data, what potential problems (or anomalies) may occur.
... Contd
Page 10 of 16
B. (4 points) Identify all the functional dependencies, as based on the data in the BigTeeth table.
C. (4 points) Normalize the relation to Boyce Codd Normal Form and show your resultant relations, indicating all primary and foreign keys.
D. (2 points) Determine whether your decomposition is dependency preserving and motivate your answer.
E. (2 points) Determine whether your decomposition is a lossless-join decomposition and motivate your answer.
... Contd
Page 11 of 16
Nurse(nid : int, nname : string, age : real, salary : real, sid : int) Supervisor (sid : int, rating : real) W orksIn(nid : int, hid : int, hours : real) Hospital(hid : int, hname : string, tid : int) T own(tid : int, tname : string, mayor : string) Assume that there are currently no indexes dened on any of the tables. The Nurse relation spans 100 disk pages and the current buffer size is 10. Further, the WorksIn relation spans 20 disk pages. Consider the following query 1.
SELECT N.nname, W.hours FROM Nurse N, WorksIn W WHERE N.salary > 20000 AND N.nid = W.nid AND hours = 100;
A. (5 points) Discuss a scenario where adding indexes may improve the efciency of the query. Motivate your answer by listing two different indexing options to consider.
... Contd
Page 12 of 16
B. (4 points) Explain how the buffer manager processes a read request for a page.
C. (6 points) Having variable-length elds in a record may raise some subtle issues, especially when a record is modied. Discuss three (3) issues that may arise.
... Contd
Page 13 of 16
In this question, you must use the bulk loading algorithm to build a B+ tree index on the relation instance above. Use the index organization (alternative 1) where a data entry k is an actual data record with search key value k . Assume an order of 1. Answer the following questions: 1. (4 Points) Show only the rst three steps of the bulk loading algorithm.
... Contd
Page 14 of 16
2. (2 Points) Show the nal tree, after the bulk loading algorithm has been executed.
3. (4 points) Consider the tree you obtained in (2) and show the resulting B+ tree after the deletion (in the order given) of the tuples : 3, Sumo , 3.0, 23 , 5, Mikey , 10.0, 67 , 2, Noam , 3.0, 23 , and 4, Jil , 2.0, 71 .
... Contd
Page 15 of 16
Part B 10 points ((Hash Indexing)) In this question, use the following assumptions and notations: k denotes the data entry corresponding to the search key k . h is the hash function, and for any key k , h(k ) returns the last two bits of the binary representation of the ASCII code of k . Each bucket contains a maximum of 4 data entries. The set of available keys, along with their associated ASCII codes is given in the table below. binary ASCII code 1000001 1000010 1000011 1000100 1000101 1000110 1000111 1001000 1001001 1001010 1001011 1001100 1001101 key A B C D E F G H I J K L M binary ASCII code 1001110 1001111 1010000 1010001 1010010 1010011 1010100 1010101 1010110 1010111 1011000 1011001 1011010 key N O P Q R S T U V W X Y Z
... Contd
Page 16 of 16
Global depth 1 0 1
Local depth 1
Show the steps of the extendible hashing algorithm by inserting the following keys from the table above into this table, in this order: D, H, K, M, A, O, P, R, Y, W and V. (Hint: follow the method used in the example of the textbook, where a new gure was introduced only if you must double the directory).