Test Index
CBSE Class 12 Computer Science 2026 Paper Set 4
© examsnet.com
Question : 27 of 37
Marks:
+1,
-0
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(5))W_Description – Description of the item (type – VARCHAR(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) (a) Write an SQL command to create the above table (W_Code should be the primary key).OR(b) Can U_Price be the primary key of the above table ? Justify your answer.(ii) (a) 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.OR(b) Assuming that the table W_STOCK is already created, write an SQL command to remove the column B_Qty from the table.
Solution:
(i) (a)
CREATE TABLE W_STOCK( W_Code CHAR(5) PRIMARY KEY, W_Description VARCHAR(20), B_Qty INTEGER, U_Price FLOAT);OR (i) (b)No. A primary key must be unique and NOT NULL for every record. Two different items can have the same unit price (for example, two bottle sizes both priced 20.0), and a price may be unknown (NULL), so U_Price cannot identify each record uniquely. W_Code is the right choice.(ii) (a)
ALTER TABLE W_STOCK ADD E_Date DATE;(
ALTER TABLE W_STOCK ADD COLUMN E_Date DATE; is also correct.) ALTER TABLE ... ADD adds a new column to an existing table.OR (ii) (b)ALTER TABLE W_STOCK DROP B_Qty;(
ALTER TABLE W_STOCK DROP COLUMN B_Qty; is also correct.) ALTER TABLE ... DROP removes the column and its data.© examsnet.com
Go to Question: