1.

Consider the following tables CABHUB and CUSTOMER and answer (b) and (c) parts of this question :1. Give a suitable example of a table with sample data and illustrate Primary and Candidate Keys in it.2. Write SQL commands for the following statements:(i) To display the names of all the white coloured vehicles.(ii) To display name of vehicle name and capacity of vehicles in ascending order of their sitting capacity.(iii) To display the highest charges at which a vehicle can be hired from CABHUB.(iv) To display the customer name and the corresponding name of the vehicle hired by them.3. Give the output of the following SQL queries :(i) SELECT COUNT(DISTINCT Make) FROM CABHUB;(ii) SELECT MAX(Charges), MIN(Charges)(iii) FROM CABHUB;(iv) SELECT COUNT (*) Make FROM CABHUB;(v) SELECT Vehicle FROM CABHUB WHERE Capacity=4;

Answer»

1. Primary key of CABHUB = Vcode 

alternate key of CABHUB = Vehicle Name. 

Primary key of Customer = Ccode 

Alternate Key of CUSTOMER = Cname.

2. (i)  SELECT VehicleName FROM CABHUB WHERE Colour = “WHITE”;

(ii)  SELECT VehicleName, capacity From CABHUB ORDER BY Capacity ASC;

(iii). SELECT MAX(Charges) FROM CABHUB;

(iv). SELECT Cname,VehicleName FROM CABHUB, CUSTOMER WHERE CUSTOMER. Vcode=CABHUB. Vcode;

3. (i) 4 

    (ii) MAX(Charges) MIN (Charges) 35 12 

    (iii) 5 

    (iv) SX4 

    (v)  C Class



Discussion

No Comment Found