Question:

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.

Show Hint

PRIMARY KEY must be unique and NOT NULL.
Use NOT NULL for fields that must always have a value.
Use ALTER TABLE to modify and DROP TABLE to delete.
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

(i) (a)
The attribute that should be designated as the PRIMARY KEY is EMPNO.
This is because EMPNO (Employee Number) uniquely identifies each employee,
ensuring that each record is unique in the table.
Unlike NAME, which can repeat, EMPNO must be unique.
OR
(i) (b)
To ensure that the NAME attribute cannot be left empty,
apply the NOT NULL constraint.
This allows duplicate names but does not allow NULL values.
Example: NAME VARCHAR(50) NOT NULL.
(ii) (a)
ALTER TABLE EMPLOYEES MODIFY BASICSAL DECIMAL(7,2);
This command changes the data type of BASICSAL to allow
a maximum of 7 digits, including 2 decimal places, which covers 99999.99.
OR
(ii) (b)
DROP TABLE EMPLOYEES;
This SQL command deletes the entire table EMPLOYEES permanently
along with all its data.
Was this answer helpful?
0
0

Top Questions on SQL

View More Questions