Test Index
Structured Query Language (SQL)
© examsnet.com
Question : 53 of 58
Marks:
+1,
-0
The ABC Company is considering to maintain their salespersons records using SQL to store data. As a database administrator, Alia created the table Salesperson and also entered the data of 5 Salespersons.Table : Salesperson
Based on the data given above, answer the following questions :(i) Identify the attribute that is best suited to be the Primary Key and why ? (1)(ii) The Company has asked Alia to add another attribute in the table. What will be the new degree and cardinality of the above table ? (1)(iii) Write the statements to : (2)(a) Insert details of one salesman with appropriate data.(b) Change the Region of salesman ‘SHYAM’ to ‘SOUTH’ in the table Salesperson.OR (Option for part iii only)(iii) Write the statement to : (2)(a) Delete the record of salesman RISHABH, as he has left the company.(b) Remove an attribute REGION from the table.
| S_ID | S_NAME | AGE | S_AMOUNT | REGION |
|---|---|---|---|---|
| S001 | SHYAM | 35 | 20000 | NORTH |
| S002 | RISHABH | 30 | 25000 | EAST |
| S003 | SUNIL | 29 | 21000 | NORTH |
| S004 | RAHIL | 39 | 22000 | WEST |
| S005 | AMIT | 40 | 23000 | EAST |
[CBSE 2023 Compartment]
Solution:
(i) S_ID is best suited as the Primary Key, because its value is unique for every salesperson and never empty (NULL), so it identifies each record. Names or ages can repeat for new salespersons.(ii) Degree = number of attributes (columns) = 5 + 1 = 6. Cardinality = number of tuples (rows) stays 5, since adding a column adds no rows.(iii)
(a) INSERT INTO Salesperson VALUES ('S006', 'JAYA', 23, 34000, 'SOUTH');(b) UPDATE Salesperson SET REGION = 'SOUTH' WHERE S_NAME = 'SHYAM';OR (iii)(a) DELETE FROM Salesperson WHERE S_NAME = 'RISHABH';(b) ALTER TABLE Salesperson DROP COLUMN REGION;DELETE removes the record (row); ALTER TABLE ... DROP changes the structure by removing the column.
© examsnet.com
Go to Question: