SQL · Databases
43 questions · asked in 23 of 27 years (2000–2026)
MCQ 34 · MSQ 1 · NAT 81-mark 26 · 2-mark 17
2000Questions per year2026
Questions 11–15 of 43
Consider the following database table named water_schemes :
The number of tuples returned by the following SQL query is __________.
The number of tuples returned by the following SQL query is __________.
with total(name, capacity) as
select district_name, sum(capacity)
from water_schemes
group by district_name
with total_avg(capacity) as
select avg(capacity)
from total
select name
from total, total_avg
where total.capacity ≥ total_avg.capacityAnswer: 2
Total capacity for each district: Ajmer 20, Bikaner 10 + 10 + 20 = 40, Churu 10 + 20 = 30, Dungargarh 10.
Average of these totals = (20 + 40 + 30 + 10) / 4 = 25.
The districts whose total is 25 are Bikaner and Churu 2 rows.
Answer: 2
Average of these totals = (20 + 40 + 30 + 10) / 4 = 25.
The districts whose total is 25 are Bikaner and Churu 2 rows.
Answer: 2
SELECT operation in SQL is equivalent to
Answer: (D)
In SQL, the SELECT list picks columns. This is the same as projection in relational algebra. The difference is that SQL does not remove duplicate rows unless DISTINCT is written.
Answer: the projection operation, except that SELECT in SQL retains duplicates
Answer: the projection operation, except that SELECT in SQL retains duplicates
Consider the following relations:
Consider the following SQL query.
The number of rows that will be returned by the SQL query is _____________.
Consider the following SQL query.
SELECT S.Student_Name, sum(P.Marks)
FROM Student S, Performance P
WHERE S.Roll_No = P.Roll_No
GROUP BY S.Student_NameThe number of rows that will be returned by the SQL query is _____________.
Answer: 2
The query uses GROUP BY on Student_Name. Two distinct names appear: Raj, who has roll 1 and roll 3, and Rohit. This gives 2 groups.
The output rows are: Raj, 310 and Rohit, 140.
Answer: 2
The output rows are: Raj, 310 and Rohit, 140.
Answer: 2
Consider the following relation
Cinema(theater, address, capacity)
Which of the following options will be needed at the end of the SQL query
SELECT P1.address FROM Cinema P1
such that it always finds the addresses of theaters with maximum capacity?
Cinema(theater, address, capacity)
Which of the following options will be needed at the end of the SQL query
SELECT P1.address FROM Cinema P1
such that it always finds the addresses of theaters with maximum capacity?
Answer: (A)
A theater has the maximum capacity when its capacity is all the capacities in the table. This means ALL.
Using ANY gives every theater. Using ALL (max) or ANY (max) gives no rows.
Answer: WHERE P1.capacity All (select P2.capacity from Cinema P2)
Using ANY gives every theater. Using ALL (max) or ANY (max) gives no rows.
Answer: WHERE P1.capacity All (select P2.capacity from Cinema P2)
Given the following statements:
S1: A foreign key declaration can always be replaced by an equivalent check assertion in SQL
S2: Given the table R(a,b,c) where a and b together form the primary key, the following is a valid table definition.
CREATE TABLE S (
a INTEGER,
d INTEGER,
e INTEGER,
PRIMARY KEY (d),
FOREIGN KEY (a) references R)
Which one of the following statements is CORRECT?
S1: A foreign key declaration can always be replaced by an equivalent check assertion in SQL
S2: Given the table R(a,b,c) where a and b together form the primary key, the following is a valid table definition.
CREATE TABLE S (
a INTEGER,
d INTEGER,
e INTEGER,
PRIMARY KEY (d),
FOREIGN KEY (a) references R)
Which one of the following statements is CORRECT?
Answer: (D)
Let us check each statement:
- S1: A CHECK constraint cannot always take the place of a foreign key. It cannot easily refer to another table, and it cannot handle updates and deletes so S1 is FALSE.
- S2: The primary key of R is (a, b), so a foreign key has to refer to both columns. FOREIGN KEY (a) references R is not valid so S2 is FALSE.
Answer: Both S1 and S2 are FALSE
- S1: A CHECK constraint cannot always take the place of a foreign key. It cannot easily refer to another table, and it cannot handle updates and deletes so S1 is FALSE.
- S2: The primary key of R is (a, b), so a foreign key has to refer to both columns. FOREIGN KEY (a) references R is not valid so S2 is FALSE.
Answer: Both S1 and S2 are FALSE
Keep practising