You are on page 1of 3

ICS 2206 INTRODUCTION TO DATABASE MANAGEMENT

SYSTEMS
ASSIGNMENT 2

Name Kevin Muraga Njuguna

REG NO SCT221-0235/2021

Date 24th march 2022


Why is this table not in 3NF?
The table is not in 3NF because iff it is in 2NFand no non key attributes depend on another non
key attribute

Normalize this table to 3NF.

Branch No Branch address Mgr staff number Name

Branch number Branch address Teleno

Identify the primary, (alternate) and foreign keys in your 3NF relations

Primary key is the branch number

Alternate key is the branch address

Foreign keys are mgr staff number and staff name

2 Using the company database, write SQL statements to [15 Marks]

a. Create a view Dept5Workers that shows all Dno 5 workers


CREATE VIEW Dept5 workers AS
SELECT *
FROM employee
WHERE Dno = 5 ;

b. Create a view called Basic_Employee_Details that shows only the names and
addresses of the employees
CREATE VIEW Basic_Employee_Details AS
SELECT Fname ,Lname ,Address
FROM employee
WHERE Dno = 5
c. A view that has the department name, manager name, and manager salary for
every department
CREATE VIEW manager_information AS
SELECT Dname AS Department _name .Fname AS First_name ,Lname AS
Last_name,salary
FROM employee , department
WHERE Mgr_ssn=SSN;

d. A view that has the employee name, supervisor name, and employee salary for
each employee who works in the ‘Research’ department
CREATE VIEW Research _Dept AS
SELECT Fname ,Lname ,Salary ,Super_ssn AS Supervisor_name
FROM employee
WHERE Dno=5
ORDER BY Salary DESC;

e. A view that has the project name, controlling department name, number of
employees, and total hours worked per week on the project for each project
CREATE VIEW project _information AS
SELECT DISTINCT Pname AS Project _name,Dname AS
Department _name ,Hours_per_week,COUNT(Dnum)AS Employees
FROM worksonhours,department ,employee,project
WHERE Essn = SSN AND Dno = Dnumber AND Pno =Pnumber
GROUP BY Pno;

You might also like