Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Database Systems Please answer questions (a) and (b) using the following tables

ID: 3902509 • Letter: D

Question

Database Systems

Please answer questions (a) and (b) using the following tables held in a Relational Database Management Systems.

            Employee        (empID, fName, lName, address, DOB, sex, position, deptNo)

            Department     (deptNo, deptName, mgrEmpID)

            Project            (projNo, projName, deptNo)

            WorksOn         (empID, projNo, hoursWorked)

            where Employee        contains employee details and empID is the key.

                        Department     contains department details and deptNo is the key. mgrEmpID identifies the employee who is the manager of the department. There is only one manager for each department.

                        Project            contains details of the projects in each department and the key is projNo (no two departments can run the same project).

            and      WorksOn         contains details of the hours worked by employees on each project, and empID/projNo form the key.

A) Produce a report of the total hours worked by each employee, arranged in order of department number and within department, alphabetically by employee surname. (Show the query)

B) For each project on which more than two employees worked, list the project number, project name and the number of employees who work on that project. (Show the query)

Explanation / Answer

A) select e.empID, e.lname,sum(w.hoursWorked),e.deptno from Employee eWorksOn w where e.empID=w.empID group by e.deptno order by e.deptno,e.lname;

The above query will retrieve the employee and worked hours details in the required order.

B) select p.projNo,p.projName,count(w.empID) from Project p,WorksOn w,Employee e where p.projNo=w.projNo,e.empID=w.empID group by p.projNo having count(empID) >2;