CIS611 Lab Assignment 1 Part 4: Solution SS Chung 4. Update the following new changes into the database: 1) Joyce English with Ssn = 453453453 got married with John. 2) Jenifer Wallace with Ssn = 987654321 just had a new daughter named Erica. 3) Jenifer Wallace with Ssn = 987654321 is just assigned to a new project number ‘10’ to work on. Add these new entries into Dependent, Works_On tables in your database then Select * from Dependent and Select * from Works_On to show the updated table contents. 5. Write SQL Select statements to retrieve data in the followings: Q1: Make a list of all project numbers that Research department employees are working on, either as a worker or as a manager of the department that controls the projects. (SELECT W.Pno FROM DEPARTMENT D, WORKS_ON W WHERE D.Dname = 'research' and w.essn = D.mgrssn) UNION /*as employee */
10
Embed
CIS611 Lab Assignment 1 Part 4: Solution SS Chungcis.csuohio.edu/~sschung/cis611/CIS611_Lab1_2015...CIS611 Lab Assignment 1 Part 4: Solution SS Chung 4. Update the following new changes
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CIS611 Lab Assignment 1 Part 4: Solution SS Chung
4. Update the following new changes into the database:
1) Joyce English with Ssn = 453453453 got married with John.
2) Jenifer Wallace with Ssn = 987654321 just had a new daughter named Erica.
3) Jenifer Wallace with Ssn = 987654321 is just assigned to a new project number ‘10’ to work
on.
Add these new entries into Dependent, Works_On tables in your database then Select * from
Dependent and Select * from Works_On to show the updated table contents.
5. Write SQL Select statements to retrieve data in the followings:
Q1:
Make a list of all project numbers that Research department employees are working on,
either as a worker or as a manager of the department that controls the projects.
(SELECT W.Pno FROM DEPARTMENT D, WORKS_ON W
WHERE D.Dname = 'research' and w.essn = D.mgrssn)
UNION /*as employee */
(SELECT W.Pno
FROM WORKS_ON W, department D, EMPLOYEE E
WHERE E.Dno = D.Dnumber AND
W.Essn = E.Ssn AND D.Dname = 'research');
/*Left Q: for projects as a manager of Research dept -- It returns 2,3,10,20*/ SELECT Distinct W.Pno
FROM DEPARTMENT D, WORKS_ON W
WHERE D.Dname = 'research' and w.essn = D.mgrssn;
/*Right Q: for projects as employees in Research dept -- It returns 1,2,3,10,20*/
SELECT Distinct W.Pno FROM WORKS_ON W, department D,