Test Index

CBSE Class 12 Computer Science 2026 Paper Compartment Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 27 of 37
Marks: +1, -0
EcoHarvest Solutions Co. is an agricultural technology firm specializing in farm management and crop optimization. The company stores crop planting details in a database table called PLANTINGS with attributes such as :
PlantingID, CropType, PlantingDate, FieldLocation.
Details of each harvest, including yield quantity and quality, are stored in another table named HARVESTS with attributes like.
HarvestID, PlantingID, YieldQuantity, YieldQuality, HarvestDate.
(I) (a) Identify the attribute which should be considered as the FOREIGN KEY for joining the two tables.
OR
(b) Which constraint should be applied to the attribute HarvestID such that it can be used to uniquely identify every harvest record for all crops ?
(II) (a) Write the SQL command to change the value of FieldLocation of the Planting whose PlantingID is 'PL005' to 'North Field 3'.
OR
(b) Write the SQL command to display the records from the table HARVESTS for all records which have excellent YieldQuality.
Solution:  
(I)(a)
PlantingID in the table HARVESTS is the foreign key. It is the primary key of PLANTINGS, and in HARVESTS it refers to that planting, so the two tables are joined on HARVESTS.PlantingID = PLANTINGS.PlantingID.
OR (I)(b)
The PRIMARY KEY constraint should be applied to HarvestID. A primary key does not allow duplicate values or NULL, so every harvest record is uniquely identified.
(II)(a)
UPDATE changes values in existing rows; WHERE selects the row to change:
UPDATE PLANTINGS
SET FieldLocation = 'North Field 3'
WHERE PlantingID = 'PL005';
OR (II)(b)
SELECT * shows all columns; WHERE keeps only the rows with excellent quality:
SELECT * FROM HARVESTS
WHERE YieldQuality = 'Excellent';
© examsnet.com
Advertisements
Go to Question: