list the names of all employees who have a dependent with the same first name as themselves

6
Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. p10ssn ← (Π essn (σ hours > 10 (works-on |X| pno = pnumber(Π pnumber (σ pname = ‘ProductX’ (project)))) Π lname, minit, fname (σ dno = 5 (employee |X| ssn = essn (p10ssn))) select lname, minit, fname from employee, works-on, project where ssn = essn AND pno = pnumber AND dno = 5 AND hours > 10 AND pname = ‘Product X’;

Upload: conan-dickerson

Post on 31-Dec-2015

7 views

Category:

Documents


0 download

DESCRIPTION

Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. p10ssn ← (Π essn (σ hours > 10 (works-on |X| pno = pnumber(Π pnumber (σ pname = ‘ProductX’ (project)))) Π lname, minit, fname (σ dno = 5 (employee |X| ssn = essn (p10ssn))) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: List the names of all employees who have a dependent with the same first name as themselves

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

p10ssn ← (Π essn (σ hours > 10 (works-on |X| pno = pnumber(Π pnumber (σ pname = ‘ProductX’ (project))))

Π lname, minit, fname (σ dno = 5 (employee |X| ssn = essn (p10ssn)))

select lname, minit, fname

from employee, works-on, project

where ssn = essn AND pno = pnumber AND

dno = 5 AND hours > 10 AND

pname = ‘Product X’;

Page 2: List the names of all employees who have a dependent with the same first name as themselves

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

Π lname, minit, fname (employee |X| fname = dependent-name AND ssn = essn (dependent))

select lname, minit, fname

from employee, dependent

where fname = dependent-name AND

ssn = essn;  

Page 3: List the names of all employees who have a dependent with the same first name as themselves

Find the names of all employees who are directly supervised by ‘Franklin Wong’.

Π lname, minit, fname (employee |X| superssn = ssn (Π ssn (σ fname = ‘Franklin’ AND lname = ‘Wong’ (employee))))

select employee.lname, employee.minit, employee.fname

from employee emp

where emp.lname = ‘Wong’ AND

emp.fname = ‘Franklin’ AND

employee.superssn = emp.ssn;  

Page 4: List the names of all employees who have a dependent with the same first name as themselves

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

pname F sum hours (project |X| pnumber = pno (works-on))

select pname, sum(hours)

from project, works-on

where pno = pnumber

group by pname;  

Page 5: List the names of all employees who have a dependent with the same first name as themselves

For each department, retrieve the department name and the average salary of all employees working in that department.

dname F average salary (department |X| dnumber = dno (Π dno, salary, ssn (employee)))

select dname, average(salary)

from department, employee

where dnumber = dno

group by dname; 

Page 6: List the names of all employees who have a dependent with the same first name as themselves

Retrieve the average salary of all female employees.

F average salary (σ sex = ‘F’ (employee))

select average (salary)

from employee

where sex = ‘f’;