database-tutorials

Tutorial 6

Exercises

Regard the following Relational model

Q1 Retrieve employees names who are working in the Research department.

Q2 Retrieve project names where the last name of the department manager is Wong

Q3 Retrieve managers names having projects in ‘Stafford’

Q4 Retrieve the names of all employees in ‘Research’ department who work more than 10 hours per week on theProductX project.

Q5 List the names of all employees who have a dependent with the same first name as themselves.

select FNAME, MINIT, LNAME
from employee join dependent on ESSN =ssn
where FNAME = DEPENDENT_NAME;

Q6 For each project, list the project name and the total hours per week (by all employees) spent on that project.

select PNAME, sum(HOURS)
from project join works_on on PNO = PNUMBER
group by PNAME;

Q7 Retrieve the names of all employees who do not work on any project.

select Fname
from employee
where SSN not in (select SSN from employee, works_on
where SSN = ESSN );

Q8 Retrieve project names where the department manager last name is Wong or project names where employee smith is working in.