Professional Documents
Culture Documents
COM222 Test2
COM222 Test2
2. Explain how SQL provides physical and logical data independence. (4)
4. Specify relation algebra query to retrieve the names of all employees who work on every
project on the COMPANY relational database schema shown in Figure 1 below. Also show
the result of the query as it would apply to the database state in Figure 1 below. (4)
5. Consider the two tables 𝑇 and 𝑆 shown below.
T S
P Q R A B C
10 a 5 10 b 6
15 b 8 25 c 3
25 a 6 10 b 5
Show the result of the following operation: 𝑇 ⋈ 𝑇.𝑃=𝑆.𝐴 𝒂𝒏𝒅 𝑇.𝑅=𝑆.𝐶 𝑆 (4)
6. Using the Company relational Database Schema in Figure 1 below write an SQL statement to
retrieve:
a. The project number, the project name, and the number of employees who work on that
project. (4)
b. For each department that has more than five employees, the department number and the
number of its employees who are making more than K40,000 (5)
b. Normalise the table into 3rd Normal form. Show all the intermediate normal forms and
the functional dependencies defining the forms or otherwise. (7)
8. Consider the following relational algebra expressions:
i. πw((A ⋈x=y B) ⋈z=v C)
ii. πw((πv(C) ⋈v=z πwyz(B)) ⋈y=x A)
a. Translate the relational algebra expressions into their equivalent query trees (4)
b. Assuming that (ii) is transformed from (i), explain why query (ii) can be considered to
be more efficient than query (i) (4)