Question 6.16 Page 186: ( ( ( Employee) ) - X - ( ( Works - On) ) - X - ( ( Project) ) )
Question 6.16 Page 186: ( ( ( Employee) ) - X - ( ( Works - On) ) - X - ( ( Project) ) )
16 page 186
a. Retrieve the names of all employees in department 5 who work more than 10 hours per week on the 'ProductX' project.
Fname, Minit,,Lname,{[Fname,Lname, SSN ( Dno = 5 Employee)] |X|ssn=essn [Essn,Pno ( Hours > 10 Works_on)] |X|pno = pnumber [Pnumber ( Pname = ‘Product ‘X’ Project)]}
fname lname
John Smith
Joyce English
========================
b. List the names of all employees who have a dependent with the same first name as themselves.
Fname,Minit, Lname,[(Fname, Minit,,Lname, SSN Employee) |X|ssn=essn, fname = dependent_name ( Dependent_name, essn Dependent)]
fname lname
1
========================
c. Find the names of all employees who are directly supervised by ‘Franklin Wong’.
Fname,Minit, Lname{(Fname,Lname, Mgrssn Employee E1) |X|E1.Mgrssn = E2.ssn [ SSN( Fname = ‘Franklin’. Lname = ‘Wong’ Employee E2)]}
OR
fname lname
John Smith
Ramesh Narayan
Joyce English
========================
2
d. For each project, list the project name and the total hours per week (by all employees) spent on that project.
pname (sum)
Newbenefits 55.0
Computerization 55.0
ProductX 52.5
ProductY 37.5
Reorganization 25.0
ProductZ 50.0
Fname, Minit, Lname {[Fname, Minit, Lname, SSN Employee)] |X|SSN = Essn [ (Pno, ESSN Works_on) ÷ (Pnumber Project)]}
FNAME LNAME
--------------- ---------------
Alicia Zeleya
Ahmad Jabbar
f. Retrieve the names of all employees who do not work on any project.
Fname, Minit, Lname {[Fname, Minit, Lname, SSN Employee)] |X|SSN =SSN [ (SSN Employee) - (ESSN Works_on)]}
OR:
fname lname
========================
4
g. For each department, retrieve the department name and the average salary of all employees working in that department.
Dname, Avg_salary {[Dnumber, Dname Department)] |X|Dnumber = Dno (dno avg salary Employee)]}
dname (avg)
Headquaters 55000.00
Administration 31000.00
Research 33250.00
5
h. Retrieve the average salary of all female employees.
select avg(salary)
from employee
where sex='F';
(avg)
31000.00
========================
6
i. Find the names and addresses of all employees who work on at least one project located in Houston but whose department has no location in Houston.
T1 {Fname, Minit,,Lname, ssn {[Fname, Minit,,Lname, SSN, dno (Employee)] |X|Dno = Dnumber {[[dno (Employee)] - Dnumber ( Dlocation = ‘Houston’ Dept_locations)] }}
T2 ESSN{[ ESSN, Pno (Works_on)] |X|Pno = Pnumber [Pnumber ( Plocation = ‘Houston’ Project)]}
7
j. List the last names of all department managers who have no dependents.
Fname, Minit, Lname {[Fname, Minit, Lname, SSN Employee)] |X|SSN =MRRSSN [(MGRSSN Department) - (ESSN Dependent)]}
FNAME LNAME
--------------- ---------------
James Borg
========================