The following tables form part of a database held in a Relational Database Management System:
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. Thereis 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) (1) List all employees in alphabetical order of surname and within surname, first name.
(2) List all the details of employees who are female.
(3) List the names and addresses of all employees who are Managers.
(4) Produce a list of the names and addresses of all employees who work for the ‘IT’ department.
(5) Produce a complete list of all managers who are due to retire this year, in alphabetical order of surname.
(6) Find out how many employees are managed by ‘James Adams’.
(7) Produce a report of the total hours worked by each employee, arranged in order of department number and within department, alphabetically by employee surname.
(8) 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.
(9) List the total number of employees in each department for those departments with more than 10 employees. Create an appropriate heading for the columns of the results table.
(b) Create a view of employee details for all employees who work on project ‘MIS Development’, excluding department number.
(a) (1) SELECT *
FROM Employee
ORDER BY lName, fName;
(2) SELECT *
FROM Employee
WHERE sex = ‘F’;
(3) SELECT fName, lName, address
FROM Employee
WHERE position = ‘Manager’;
Or
SELECT fName, lName, address
FROM Employee e, Department d
WHERE e.empID = d.mgrEmpID;
(4) SELECT e.lName, e.address
FROM Employee e, Department d
WHERE e.deptNo = d.deptNo AND d.deptName = ‘IT’;
(5) SELECT lName
FROM Employee e, Department d
WHERE e.empID = d.mgrEmpID AND
date_part(‘year’,DOB) < date_part(‘year’, DATE(‘2001-10-01’) – 65;
(6) SELECT COUNT(*)
FROM Employees e1,e2, Department d
WHERE e1.lName = ‘Adams’ AND e1.fName = ‘James’ AND
e1.empID = d.mgrEmpID AND d.deptNo = e2.deptNo;
(7) SELECT e.empID, e.lName, e.fName, e.deptNo,
SUM(w.hoursWorked)
FROM Employee e, Project p, WorksOn w
WHERE e.deptNo = p.deptNo AND e.empID = w.empID
ORDER BY e.deptNo, e.lName;
(8) SELECT e.projNo, e.projName, COUNT(*)
FROM Project p, WorksOn w
WHERE p.projNo = w. projNo
GROUP BY e.projNo, e.projName
HAVING COUNT(*) > 2;
(9) SELECT deptNo AS departmentNumber, COUNT(empID) AS totalEmployees
FROM Employee
GROUP BY deptNo, empID
HAVING COUNT(empID) > 10
(b) CREATE VIEW ED(eid, fName, lName, address, DOB)
AS SELECT empID, fName, lName, address, DOB
FROM Employee e, Project p
WHERE e.deptNo = p.deptNo AND p.projName = ‘MIS Development’;
You might also like to view...
Creating a model for an existing system is called ____.
A. reverse synthesis B. engineering C. reverse engineering D. synthesis
Word does not give you the ability to open multiple documents
Indicate whether the statement is true or false
Case B-1You are in the planning stages of designing a website to market children's books. The continually expanding field of children's books makes this an exciting adventure. You realize that planning is an essential part of creating an effective website, and that your planning decisions will affect the success of the project. What process would best ensure that the site contains accurate information, looks good, and works smoothly?
A. Create pages, set up the basic structure, plan the site, publish the site B. Plan the site, publish the site, create pages, test pages, modify pages C. Create pages, plan the site, modify pages, publish the site D. Plan the site, set up the basic structure, create pages, test pages, modify pages, publish the site
Main memory is part of the central processing unit (CPU).
Answer the following statement true (T) or false (F)