Mid Term Exam (Due Date: March 17, 2021 @09:45 PM) Weight 40%
Mid Term Exam (Due Date: March 17, 2021 @09:45 PM) Weight 40%
Mid Term Exam (Due Date: March 17, 2021 @09:45 PM) Weight 40%
Mid Term Exam (Due Date: March 17, 2021 @09:45 PM) Weight 40%
Number of Questions: 3 All Questions are required.
Discuss any assumptions you make, and then justify your EER design choices.
MDT_OY
i. Retrieve the average salary of all female employees per each department.
SELECT AVG(salary)
FROM EMPLOYEE
WHERE EMPLOYEE.sex = 'F'
AND ssn in (select essn from department);
ii. Retrieve a list of all department manager and the names of all projects that is controlled by this
department.
SELECT fname, lname
FROM employee e, dependent d
WHERE e.fname = d.dependent_name
(15%)
MDT_OY
Suppose that a disk unit has the following parameters: block size B = 2400 bytes; An EMPLOYEE file has
the following fields: Ssn, 9 bytes; Last_name, 15 bytes; First_name, 15 bytes; Middle_init, 1 byte;
Birth_date, 10 bytes; Address, 30 bytes; Phone, 12 bytes; Supervisor_ssn, 9 bytes; Department, 4 bytes;
Job_code, 4 bytes, Email 15 bytes; deletion marker, 1 byte. The EMPLOYEE file has r = 30,000 records,
fixed-length format, and spanned blocking. Write appropriate formulas and calculate the following values for
the above EMPLOYEE file (Assume size of the pointer (record or block) is 6 bytes):
i. Calculate the record size R (including the deletion marker), the blocking factor bfr, and the number of
disk blocks.
R=125
bfr = floor(B / R) = floor(512 / 125) = 4 records per block
b = ceiling(r / bfr) = ceiling(30000 /4) = 7500 blocks
ii. Calculate the average number of block accesses needed to search for an arbitrary record in the file,
using Binary search in the DB file without any auxiliary files.
binary search of index file would need • log2bi = log 7500=13 block accesses
block accesses without index = b/2 (average cost for linear search) = 7500/2 = 3750
iii. Assume you create a secondary unique index on EMail which is dense index. Compare the
performance of using this index in retrieving number of K values with the linear search (Scan) to the
DB file. What is the optimum value of K based on the above data that makes using index in search is
useful?
Good Luck