You are on page 1of 5

UNIVERSITY OF THE FREE STATE

DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS

BLOEMFONTEIN/QWAQWA CAMPUS

SEMESTER TEST 1 MEMO


CSIS2634 & CSIQ2634

ASSESSORS/ Prof. T.R. Stott TIME: 2 hours


Mr M.B. Mase DATE: 25 May 2021
MODERATOR: Prof J.E. Kotzé MARKS: 65

Instructions
1. Answer all the questions.
2. Number your answers clearly.
3. When drawing ERDs you must use UML notation. No Crow’s foot notation will be
marked.
4. This is a closed book test. You may not use any notes, text books or electronic devices
during the test.
Question 1
The following sample data is given for a small cell phone shop:
CELLPHONE

CellId CellName BrandId RetailPrice Quantity_In_Stock


1 Apple iPhone 12 A001 12000 2
2 Samsung A51 S001 5400 5
3 Apple iPhone 11 A001 10580 3
4 Nokia 3310 N001 1250 1
5 Nokia 3330 N001 2300 7

BRAND

BrandId BrandName CountryId


S001 Samsung SK
A001 Apple CH
N001 Nokia FN
H001 Huawei null

1
COUNTRY

CountryId CountryName
SK South Korea
CH China
FN Finland

Use the given data and entities to write the SQL statements required for the following queries.
a) List all the Apple phones that are available. Show the name of the phone and the
current retail price. Order the list from most expensive to the cheapest.
(5)
select CellName, RetailPrice []
from Cellphone []
where BrandId = 'A001' []
order by RetailPrice [] desc []

b) For each brand, show the brand name, and the number of phones that are currently
in stock (regardless of the phone name).
(7)

select BrandName, sum(Quantity_In_Stock) [] []


from Brand []
join Cellphone []
on Brand.BrandId = Cellphone.BrandId []
group by BrandName [][]
c) Show the cell phone name and retail price of all phones that contain the word ‘Nokia’
in their name.
(4)
select CellName, RetailPrice []
from Cellphone []
where CellName like '%Nokia%' [][]

d) Show the brand name for all brands that currently do not have any cell phones
available.
(7)

select BrandName []


from Brand []
left join Cellphone [][]
[]
on Brand.BrandId = Cellphone.BrandId
where Cellphone.Cellid is null[][]
e) List the country name, brand name and cell name for all cell phones that have more
than 3 phones in stock.
(7)
[30]

2
select CountryName, BrandName, CellName []
from Brand []
join Cellphone []
on Brand.BrandId = Cellphone.BrandId []
and Quantity_In_Stock > 3[]
join Country []
on Brand.CountryId = Country.CountryId[]

Question 2
Draw an EERD for the following specifications. You need only show the primary keys and
foreign keys in the entities. Show all multiplicities and other notation on the EERD.

 A document has a font (for the sake of simplicity only a single font).
 A font has a font name and a weight
 A font can be either a serif or sans serif font. Each of these types of fonts have unique
attributes that distinguish them from one another.
[14]

[] []
[] []
[] []

[]

[] [] []

[] []
[] []

Question 3
Normalise the following table to 3NF:

Cust_Num Cust_Name Movie_Id Movie_Name Rental_Date Return_Date


C01 Harry 356 Top Gun 2020/10/04 2020/10/06
Houdini

3
C02 Nelly Green 897 Notting Hill 2020/11/14 2020/11/15
C01 Harry 235 Die Hard 2020/11/25 2020/11/26
Houdini
C01 Harry 453 Die Hard 2 2020/11/25 2020/11/26
Houdini
C03 Jason Ford 356 Top Gun 2021/02/06 2021/02/14
C02 Nelly Green 897 Notting Hill 2021/05/04 2021/05/06
[21]
1NF
Step 1: Eliminate the repeating groups[]
There are no nulls
Step 2: Identify the primary key []
Cust_Num, Movie_Id [][]
Step 3: Identify all dependencies []

Cust_Num Cust_Name Movie_Id Movie_Name Rental_Date Return_Date

Diagram [][]
PK dependencies []
Partial [][]
2NF
Step 1: Write each key component on a separate line []
Cust_Num
Movie_Id
Cust_Num, Movie_Id [][]

Step 2: Assign corresponding dependent attributes[]


CUSTOMER(Cust_Num, Cust_Name) []
MOVIE(Movie_Id, Movie_Name) []
CUSTOMERMOVIE(Cust_Num, Movie_Id, Rental_Date, Return_Date) []

4
3NF
Step 1: Identify each determinant []
There are no determinants (transitive dependencies) []
Step 2: Identify the dependent attributes []
Step 3: Remove the dependent attributes from transitive dependencies []

You might also like