Revision SQL Commands
Revision SQL Commands
Section A
Question No. 1 to 4 are based on the given text. Read the text carefully and answer the questions:
[4]
Consider the following tables WORKER and PAYLEVEL:
Table: WORKER
Question No. 5 to 8 are based on the given text. Read the text carefully and answer the questions: [4]
3 Jatin 101
4 Nazneen 103
1/
7. Write SQL commands for the following statements:
i. To display the content of the GAMES table in ascending order of Schedule Date.
ii. To display sum of PrizeMoney for each type of GAMES.
8. Give the output of the following SQL queries:
i. SELECT COUNT (DISTINCT Number) FROM GAMES;
ii. SELECT MAX(ScheduleDate), MIN (ScheduleDate) FROM GAMES;
iii. SELECT Name, GameName FROM GAMES G, PLAYER P WHERE ([Link]= [Link] AND [Link]>10000);
iv. SELECT DISTINCT Gcode FROM PLAYER;
Question No. 9 to 13 are based on the given text. Read the text carefully and answer the questions:
[5]
In a Database, there are two tables with the instances given below:
Table : STUDENTS
Table : SPORTS
ADMNO GAME COACHNAME GRADE
9. Choose the command to display name and game of those students whose address is available in STUDENTS table.
a) b)
SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE
[Link]=[Link], ADDRESS IS NULL; [Link]=[Link] NOT ADDRESS IS NULL;
c) d)
SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE SELECT NAME, GAME FROM STUDENTS, SPORTS WHERE
[Link]=[Link] AND ADDRESS IS NOT NULL; [Link]=[Link] AND ADDRESS IS NULL;
10. Identify the statement to delete a column phone from the table STUDENTS.
a) b)
DROP PHONE; UPDATE DROP PHONE;
c)
ALTER TABLE STUDENTS DROP PHONE; d)
DELETE FROM STUDENTS WHERE DROP PHONE;
11. Choose the command to display name of the students who are studying in class 12 and their corresponding coach names.
a) b)
SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLSAESLSECLTIKNEA=M"E1,2%C"OAACNHDNASMTEUDFERNOTM=SSPTOURDTESN;TS, SPORTS WHERE CLASS
LIKE "12%"
c) d)
SELECT NAME, COACHNAME FROM STUDENTS, SPORTS WHERE CLSAESLSECLTIKNEAM"E1,2%C"[Link]=SS,[Link];RE
CLASS LIKE "12%"
12. Choose the command to count the number of students who play volleyball.
a) b)
SELECT COUNT(GAME) FROM STUDENTS, SPORTS WHERE GAME="SVEOLLELCETYBCAOLULN"T(A*N)D
[Link],O=[Link];SPORTS="VOLLEYBALL" AND
=[Link]
c) d)
SELECT C0UNT(*) FROM STUDENTS, SPORTS WHERE GAME="VOLSLEELYEBCATLLC"OUANNTD(*S)[Link]=SS,[Link];RE
GAME="VOLLEYBALL";
13. Which two select queries will give the same output?
A. SELECT NAME, GRADE FROM STUDENTS, SPORTS WHERE ADDRESS IS NULL AND [Link] =[Link];
B. SELECT NAME, GRADE FROM STUDENTS, SPORTS WHERE ADDRESS IS NOT NULL AND [Link] =[Link];
C. SELECT NAME, GRADE FROM STUDENTS, SPORTS WHERE ADDRESS IS NULL OR [Link]=[Link];
D. SELECT [Link], [Link] FROM STUDENTS ST, SPORTS SP WHERE ADDRESS IS NULL AND ST. ADMNO=[Link];
a) B and C b) A and D
c) C and D d) A and B
Section B
2/
14. Which of the following attributes cannot be considered as a choice for the primary key? [1]
a) Id b) Street
a) SELECT * FROM Students WHERE FirstName LIKE '%a' b) SELECT * FROM Students WHERE FirstName = '%a%'
c) SELECT * FROM Students WHERE FirstName LIKE 'a%' d) SELECT * FROM Students WHERE FirstName = 'a'
17. Which of the following is not an aggregate function? [1]
a) Min b) With
c) Avg d) Sum
18. Consider the table with structure as: [1]
Student(ID, name, dept name, tot_cred)
Which attribute will form the primary key?
a) Dept b) ID
a) From b) Join
c) As d) Rename
20. By default, ORDER BY clause lists the results in order [1]
a) Any b) Descending
c) Same d) Ascending
Section C
21. What is an Alternate Key? [1]
22. Differentiate between Candidate Key and Alternate Key in context of RDBMS. [1]
23. Write the query to select all the persons from the table Persons and sort the persons by their last name in ascending order. [1]
24. What do you understand by the terms Primary Key and Degree of a relation in relational database? [1]
25. Write a query that counts the number of sales people registering orders for each day. (If a salesperson has more than one order on a given day, he or she should be counted
[1]
only once.).
26. Give a suitable example of a table with sample data and illustrate Primary and Alternate Keys in it. [3]
27. i. Write two examples of DBMS software.
[3]
ii. What is meant by NULL value in MySQL?
iii. Table 'Club' has 4 rows and 3 columns. Table 'Member' has 2 rows and 5 columns. What will be the cardinality of the Cartesian product of them?
28. Give output for following SQL queries as per given table(s):
[3]
Table: INTERIORS
3/
TCode TName DepCde Salary Age JoinDate
103 HR P K Singh
32. Consider the following table named "SOFTDRINK". Write commands of SQL for (i) to (iv).
[4]
Table : SOFTDRINK
i. To display names and drink codes of those drinks that have more than 120 calories.
ii. To display drink codes, names and calories of all drinks, in descending order of calories.
iii. To display names and price of drinks that have price in the range 12 to 18 (both 12 and 18 included).
iv. Increase the price of all drinks in the given table by 10%.
33. Consider the following tables STUDENT and STREAM. Write SQL commands for the statements (i) to (v).
TABLE: STUDENT [4]
4/
TABLE: STREAM
STRCDE STRNAME
1 SCIENCE+COMP
2 SCIENCE+BIO
3 SCIENCE+ECO
4 COMMERCE+MATHS
5 COMMERCE+SOCIO
6 ARTS+MATHS
7 ARTS+SOCIO
2 Ravinder 1008
3 Janila 1001
4 Naaz 1003
i. To display the names of all activities with their Acodes in descending order.
ii. To display sum of PrizeMoney for the Activities played in each of the Stadium separately.
iii. To display the coach's names and Acodes in ascending order of Acode from the table COACH.
iv. To display the content of all activities for which ScheduleDate is earlier than 01-01-2004 in ascending order of ParticipantsNum.
35. Consider the following tables CABHUB and CUSTOMER and answer (b) and (c) parts of this question:
Table: CABHUB [6]
Vcode VehicleName Make Colour Capacity Charges
a. Give a suitable example of a table with sample data and illustrate Primary and alternate Keys in it.
b. Write SQL commands for the following statements:
i. To display the names of all the white-colored vehicles.
ii. To display the name of vehicle name and the 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.
c. Give the output of the following SQL queries:
5/
i. SELECT COUNT (DISTINCT Make) FROM CABHUB;
ii. SELECT MAX(Charges), MIN(Charges) FROM CABHUB;
iii. SELECT COUNT (*) Make FROM CABHUB;
iv. SELECT Vehicle FROM CABHUB WHERE Capacity=4;
36. Write SQL commands for the queries (i) to (iv) and output for (v) to (viii) based on the tables 'Watches' and Sale given below.
[6]
Watches
W001 10 1
W003 5 1
W002 20 2
W003 10 2
W001 15 3
W002 20 3
W005 10 3
W003 15 4
i. TO DISPLAY ALL THE DETAILS OF THOSE WATCHES WHOSE NAME ENDS WITH TIME.
ii. TO DISPLAY WATCH'S NAME AND PRICE OF THOSE WATCHES WHICH HAVE PRICE RANGE IN BETWEEN 5000-15000.
iii. TO DISPLAY TOTAL QUANTITY IN-STORE OF UNISEX TYPE WATCHES.
iv. TO DISPLAY WATCH NAME AND THEIR QUANTITY SOLD IN the FIRST QUARTER.
v. SELECT MAX (PRICE), MIN(QTY_STORE) FROM WATCHES;
vi. SELECT QUARTER, SUM(QTY_SOLD) FROM SALE GROUP BY QUARTER;
vii. SELECT WATCHNAME, PRICE, TYPE FROM WATCHES W, SALE S WHERE W. WATCHID!= [Link];
viii. SELECT WATCHNAME, QTYSTORE, SUM (QTYSOLD), QTY_STORE - SUM (QTY_SOLD) "STOCK" FROM WATCHES W, SALE S WHERE W.
WATCHID = [Link] GROUP BY [Link];
37. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables:
DVD
[6]
DCODE DTITLE DTYPE
Cl 02 Dhrupad Classical
i. To display all details from the table MEMBER in descending order of ISSUEDATE.
ii. To display the DCODE and DTITLE of all Folk Type DVDs from the table DVD.
iii. To display the Dtype and number of DVDs in each DTYPE from the table DVD.
iv. To display all NAME and ISSUEDATE of those members from the table MEMBER who have DVDs issued (i.e., ISSUEDATE) in the year 2017.
v. SELECT MIN (ISSUEDATE) FROM MEMBER;
vi. SELECT DISTINCT DTYPE FROM DVD;
vii. SELECT [Link]. NAME, DTITLE: FROM DVD D, MEMBER M WHERE [Link]=[Link];
viii. SELECT DTITLE FROM DVD WHERE DTYPE NOT IN ("Folk", "Classical");
6/