Question
Assume the following table is added to the Company database: CREATE TABLE works_on_total ( essn NUMERIC (9) NOT NULL, totalProjects INTEGER, totalHours NUMERIC (9, 2),
Assume the following table is added to the Company database:
CREATE TABLE works_on_total ( essn NUMERIC (9) NOT NULL, totalProjects INTEGER, totalHours NUMERIC (9, 2), PRIMARY KEY (essn), FOREIGN KEY (essn) REFERENCES employee (ssn) );
Assume table works_on_total already has a row for each employee, detailing the current total number of projects they are working on, and the total number of hours that they are working.
Q4.1 Write an SQL AFTER trigger for updating an employees works_on_total entry each time they have a project added to table works_on to update the current total number of projects they are working on, and the total number of hours that they are working.
EMPLOYEE Fname Minit Dno John B 5 T 5 Franklin Alicia Jennifer J 4 S Lname Ssm Bdate Address Sex Salary Super_ssn Smith 1234567891965-01-09 731 Fondren, Houston, TX M 30000 333445558 Wong 3384555 1955-12-08 638 Voss, Houston, TX M 40000 880665555 Zelaya 99988777 1968-01-19 3321 Castle, Spring, TX F 25000 987654321 Wallace $87654321 1941-06-20 291 Berry, Bellaire, TX F 43000 888665555 Narayan/666884444 1962-09-15 975 Fire Oak, Humble, TX M 38000 333445555 English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 Jabbat 987987987 1969-03-29 580 Dallas, Houston, TX M 25000 987654321 Boys 888665555 1937 1-10 450 Stone, Houston, TX M 55000 NULL 4 Ramesh 5 5 Joyce Ahmad V 4 James E 1 DEPARTMENT DEPT LOCATIONS Dnumber Dlocation Dname Dnumber glash Research 5 1 3374*5555 987654321 fotgr start date 1988-05-22 1995-01-01 1981-06-19 4 4 Administration Headquarters 1 888565555 5 Houston Stafford Bellaire Sugarland Houston 5 PROJECT WORKS/ON Essn Pno Pnumber Dnum Hours 32.5 1 1 5 123456789 123456789 666884444 Prame ProductX ProductY Productz Plocation Bellaire Sugarland Houston 2 2 5 7.5 40.0 3 3 5 453453453 1 20.0 10 Stafford 4 453453453 2. 20.0 Computerization Reorganization Newbenefits 20 1 Houston Stafford 333445555 2. 10.0 30 4 3 10.0 333445555 333445555 10 10.0 DEPENDENT 20 10.0 Essn Dependent name Sex 333445555 999887777 Bdate 30 30.0 Alice F 10 10.0 Theodore M 999887777 987987987 987987987 333445555 333445555 333445555 987654321 10 35.0 1986-04-05 1983-10-25 1958-05-03 1942-02-28 F Joy Abner Relationship Daughter Son Spouse Spouse Son Daughter Spouse 30 5.0 M 987654321 30 20.0 123456789 Michael M 1988-01-04 987654321 20 15.0 123456789 1988-12-30 Alice Elizabeth F F 888665555 20 NULL 123456789 1967-05-05Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started