b) Consider the following table named ”CONSIGNOR”. Write command of MySql for (i) to (iv) and output
for (v) to (vii).
CnorID CnorName CnorAddress Rate City
ND01 R Singhal 24,ABC Enclave 5000 New Delhi
ND02 Amit Kumar 123,Palm Avenue 4500 New Delhi
MU15 R Kohli 5/A,South Street 3500 Mumbai
MU50 S Kaur 27-K,Westerned 9000 Mumbai
(i) To display the names of all Consignors from Mumbai. 1
(ii) To display Consignor details in ascending order of Consignor’s Name. 1
(iii) Increase the Rate of all Consignors in the given table by 10%. 1
(iv) To display names and Rate of Consignors that have Rate in the range of 3000 to 8000(both
3000 and 8000 included). 1
(v) SELECT COUNT(DISTINCT CITY) FROM CONSIGNOR; 1
(vi) SELECT AVG(RATE) FROM CONSIGNOR; 1
(vii) SELECT CnorName FROM CONSIGNOR WHERE CnorName LIKE “%K%”; 1
(c) What is the degree and cardinality of ‘CONSIGNOR’ TABLE after adding one more row in the table? 1
Answers
Answer:
Pseudocode PROGRAM BiggerOfThree: Read A; Read B; Read C; IF (A>B) THEN IF (A>C) THEN Print A; ELSE Print C; END IF; ELSE IF (B>C) THEN Print B; ELSE Print END; END IF; IF; END. 54. Pseudocode PROGRAM Print1to5: A = 1; WHILE (A != 6) DO Print A; A = A + 1; ENDWHILE; END
Explanation:
Pseudocode PROGRAM BiggerOfThree: Read A; Read B; Read C; IF (A>B) THEN IF (A>C) THEN Print A; ELSE Print C; END IF; ELSE IF (B>C) THEN Print B; ELSE Print END; END IF; IF; END. 54. Pseudocode PROGRAM Print1to5: A = 1; WHILE (A != 6) DO Print A; A = A + 1; ENDWHILE; END
Pseudocode PROGRAM BiggerOfThree: Read A; Read B; Read C; IF (A>B) THEN IF (A>C) THEN Print A; ELSE Print C; END IF; ELSE IF (B>C) THEN Print B; ELSE Print END; END IF; IF; END. 54. Pseudocode PROGRAM Print1to5: A = 1; WHILE (A != 6) DO Print A; A = A + 1; ENDWHILE; END
Pseudocode PROGRAM BiggerOfThree: Read A; Read B; Read C; IF (A>B) THEN IF (A>C) THEN Print A; ELSE Print C; END IF; ELSE IF (B>C) THEN Print B; ELSE Print END; END IF; IF; END. 54. Pseudocode PROGRAM Print1to5: A = 1; WHILE (A != 6) DO Print A; A = A + 1; ENDWHILE; END