Test Index
CBSE Class 12 Computer Science 2025 Paper Set 4
© examsnet.com
Question : 27 of 37
Marks:
+1,
-0
Nisha is assigned the task of maintaining the staff data of an organization. She has to store the details of the staff in the SQL table named
EMPLOYEES with attributes as EMPNO, NAME, DEPARTMENT, BASICSAL to store Employee's Identification Number, Name, Department, and Basic Salary respectively. There can be two or more Employees with the same name in the organization.(i) (a) Help Nisha to identify the attribute which should be designated as the PRIMARY KEY. Justify your answer.OR(b) Help Nisha to identify the constraint which should be applied to the attribute NAME such that the Employees' Names cannot be left empty or NULL while entering the records but can have duplicate values.(ii) (a) Write the SQL command to change the size of the attribute BASICSAL in the table EMPLOYEES to allow the maximum value of 99999.99 to be stored in it.OR(b) Write the SQL command to delete the table EMPLOYEES.
Solution:
(i) (a)Primary key:
EMPNOJustification: A primary key must be unique and not NULL for every record. Each employee has a different identification number, so EMPNO identifies every row uniquely. NAME cannot be the primary key because two or more employees can have the same name; DEPARTMENT and BASICSAL can also repeat.OR (i) (b)Constraint: NOT NULLNOT NULL does not allow a record to be entered without a name, but it allows duplicate values (unlike UNIQUE or PRIMARY KEY). Example:NAME VARCHAR(30) NOT NULL(ii) (a)
ALTER TABLE EMPLOYEESMODIFY BASICSAL DECIMAL(7,2);99999.99 has 7 digits in all, 2 of them after the decimal point, so the size must be
DECIMAL(7,2) (FLOAT(7,2) is also accepted). ALTER TABLE ... MODIFY changes the data type/size of an existing column.OR (ii) (b)DROP TABLE EMPLOYEES;
DROP TABLE removes the whole table, its structure as well as all its records, from the database.© examsnet.com
Go to Question: