Question 29 of 29
Q.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 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 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 ?
(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 ?
(iii) Write the statements to :
(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 :
(a) Delete the record of salesman RISHABH, as he has left the company.
(b) Remove an attribute REGION from the table.
Rajasthan RbseCBSE Class XII Board 2023Subjective· 4mImportance★★★★★
100% · 29/29 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →(i) S_ID is the primary key; (ii) degree becomes 6, cardinality stays 5.
Part (a): INSERT a new salesman, then UPDATE SHYAM's REGION to 'SOUTH'.
Part (b): DELETE RISHABH's record, then ALTER TABLE ... DROP COLUMN REGION.
Common parts (i) and (ii)
- Choosing the primary key. A primary key must be unique and not null. Among S_ID, S_NAME, AGE, S_AMOUNT and REGION, only S_ID guarantees this: its codes S001–S005 are all distinct and always present. Names can repeat, ages/amounts recur, and REGION already repeats (NORTH and EAST appear twice). So S_ID is the primary key.
- Degree and cardinality. Degree = number of attributes (columns); cardinality = number of tuples (rows). The table starts with degree 5 and cardinality 5. Adding one attribute makes the degree 6, while the number of rows is unchanged, so the cardinality stays 5. (Cardinality changes only when rows are inserted or deleted.)
Part (a)
(iii)(a) Insert a new salesman. INSERT INTO ... VALUES adds a full row; string values are quoted, numbers are not.
INSERT INTO Salesperson VALUES ('S006', 'PRIYA', 32, 24000, 'SOUTH');
Result: a sixth row S006 | PRIYA | 32 | 24000 | SOUTH is added.
(iii)(b) Change SHYAM's region. UPDATE ... SET ... WHERE modifies matching rows. The WHERE clause restricts the change to Shyam only.
UPDATE Salesperson SET REGION = 'SOUTH' WHERE S_NAME = 'SHYAM';
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.