You are on page 1of 2

Chancellor College

Department of Computer Science


Test Two Deferred
COM222 Database Systems
Answer All Questions 2 hours
1. Define a prime attribute (2)

2. Specify relation algebra query to retrieve the average salary of all female employees on the
COMPANY relational database schema shown in Figure 1 below. Also show the result of
each query as it would apply to the database state in Figure 1 below. (3)

FIGURE 1 COMPANY RELATIONAL DATABASE SCHEMA

COM222 Database Systems Page 1 of 2


3. Assume we have an enterprise that buys products from different supplying companies, and
we would like to keep track of our data by means of a database. We would like to keep track
of what kind of products (e.g. cars) we buy, and from which supplier (e.g. Toyota) we buy
them. We can buy each product from several suppliers. Further, we want to know the price of
the products. The price of a product is naturally dependent on which supplier we bought it
from. We would also like to store the address of each supplier, i.e. the city where the supplier
is located. Here, we assume that each supplier is only located at one place. Perhaps we
suddenly need to order a large number of cars from Toyota. It can then be good to know how
many people that live in the city where Toyota is located. Thus, we can know if Toyota can
employ a sufficient amount of people to produce the cars. Hence, we also store the
population for each city.
A first try to design the database produced the schema Product[Product, price,(supplier, city,
population)] with an instance as shown below:
PRODUCT SUPPLIER PRICE CITY POPULATION
Cars Toyota 100000 Mzuzu 80000
Cars Nissan 150000 Zomba 50000
Trucks Nissan 400000 Zomba 50000
Aspirin Astra 10 Zomba 50000

Normalise the table into 3rd Normal form. Show all the intermediate normal forms and the
functional dependencies defining the forms or otherwise. (11)
4. 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 expression into their equivalent SQL statements. (4)
b. Assuming that (ii) is transformed from (i), list the attributes that each of the schemas A, B,
and C must have and the attributes that each (or some) of these schemas must not have in
order for the above transformation to be correct. (6)

COM222 Database Systems Page 2 of 2

You might also like