CBSE 2026 · Central · Set 4 · Q27 · 2 marks
Ms. Zoya is a Production Manager in a factory which packages mineral water. She decides to create a table in a database to keep track of the stock present in the factory. Each record of the table will have the following fields : W_Code - Code of the item (type - CHAR ($\displaystyle 5$)) W_Description - Description of the item (type - VARCHAR ($\displaystyle 20$)) B_Qty - Balance quantity of the item (type - INTEGER) U_Price - Unit Price of the item (type - FLOAT) The name of the table is W_STOCK.(i)Write an SQL command to create the above table (W_Code should be the primary key).Can U_Price be the primary key of the above table ? Justify your answer.(ii)Assuming that the table W_STOCK is already created, write an SQL command to add an attribute E_Date (of DATE type) to the table.Assuming that the table W_STOCK is already created, write an SQL command to remove the column B_Qty from the table.
Ms. Zoya is a Production Manager in a factory which packages mineral water. She decides to create a table in a database to keep track of the stock present in the factory. Each record of the table will have the following fields : W_Code - Code of the item (type - CHAR ($\displaystyle 5$)) W_Description - Description of the item (type - VARCHAR ($\displaystyle 20$)) B_Qty - Balance quantity of the item (type - INTEGER) U_Price - Unit Price of the item (type - FLOAT) The name of the table is W_STOCK.
(i)
Write an SQL command to create the above table (W_Code should be the primary key).
Can U_Price be the primary key of the above table ? Justify your answer.
(ii)
Assuming that the table W_STOCK is already created, write an SQL command to add an attribute E_Date (of DATE type) to the table.
Assuming that the table W_STOCK is already created, write an SQL command to remove the column B_Qty from the table.
Marking-scheme solution
(i)
CREATE TABLE W_STOCK
(W_Code CHAR(5) PRIMARY KEY,
W_Description VARCHAR (20),
B_Qty INTEGER, #OR B_Qty INT/B_Qty DECIMAL
U_Price FLOAT); #OR U_Price FLOAT(7,2)
#OR U_Price DECIMAL(7,2)No, U_Price cannot be the primary key because it may
contain duplicate and Null values.
(ii)
ALTER TABLE W_STOCK ADD COLUMN E_Date DATE;
ALTER TABLE W_STOCK ADD E_Date DATE;ALTER TABLE W_STOCK DROP COLUMN B_Qty;
ALTER TABLE W_STOCK DROP B_Qty;Structured Query LanguageCreate, Describe and Show TablesApplyvery_short_answer
More from Structured Query Language
- Assume that you are the Manager of the Loans department of a Finance House. To keep track of the loans you…2026
- Abhishek has created a table, named STOCK, with a set of records to maintain the data of packaged milk in his…2026
- Which aggregate function in SQL returns the smallest value from a column in a table?2026
- What will be the output of the query? SELECT MACHINE ID, MACHINE NAME FROM INVENTORY WHERE QUANTITY <= 100;2026
CBSE Class 12 Computer Science past-paper question from the 2026board exam, with the answer as CBSE’s own marking scheme gives it. Where our answers come from.