All mock tests are FREE till 31 December — register to save your progress
Unit 4 · Database Management Systems Paper 2 CS · November 2020

Directions (Q96–100): A university database has the tables EMPLOYEE (EID, NAME, SALARY, DEPTNO, HODEID …; PRIMARY KEY EID; HODEID references EMPLOYEE(EID); DEPTNO references DEPARTMENT(DID)), DEPARTMENT (DID, DNAME, HODID; PRIMARY KEY DID; UNIQUE DNAME; HODID references EMPLOYEE(EID)) and PROJECTWORK (EMPID, PROJNO; PRIMARY KEY (EMPID, PROJNO); EMPID references EMPLOYEE(EID)).

Refer table, structures given above. The university decided to give all employees in the 'SCIENCE' department a 20% rise in salary. Which of the following query/queries will compute the above results?

(A) UPDATE EMPLOYEE SET SALARY = SALARY * 1.20 WHERE DEPT NO. IN (SELECT DID FROM DEPARTMENT WHERE DNAME='SCIENCE');

(B) UPDATE TABLE EMPLOYEE SET SALARY = SALARY * 1.20 WHERE DNAME='SCIENCE';

(C) ALTER TABLE EMPLOYEE SET SALARY=SALARY * 1.20 WHERE DEPTNO. IN (SELECT DNAME FROM DEPARTMENT WHERE DNAME = 'SCIENCE')

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. (A) only

Explanation

Only A is valid: update EMPLOYEE where DEPTNO is in the SCIENCE department's DID. B uses invalid syntax (UPDATE TABLE) and a column EMPLOYEE lacks; C uses ALTER instead of UPDATE.

More Database Management Systems questions