17 Qs · since 2011 · 28 marks · 1.1 marks/paperStandard yield
In GATE CS, SQL is tested through a balanced mix of declarative query semantics, relational-algebra correspondence, subquery evaluation (correlated, nested, and universal quantific… Guide
player(pid, pname, age)team(tid, tname, city, cid)coach(cid, cname)members(pid, tid)
An instance of the table and an SQL query are given.
SELECT MIN(P.age)
FROM player P
WHERE P.pid IN (
SELECT M.pid
FROM team T, coach C, members M
WHERE C.cname = 'Mark'
AND T.cid = C.cid
AND M.tid = T.tid
)…Student in a relational database. The primary key of this table is rollNum.
The SQL query below is executed on this database.
SELECT *
FROM Student
WHERE gender = 'F' AND
marks > 65;
The number of rows returned by the query is _________.empId is the key and deptId indicates the department to which the employee is assigned. Each employee is assigned to exactly one department.
…SELECT s.sno, s.sname
FROM Suppliers s, Catalogue c
WHERE s.sno = c.sno AND
cost > (SELECT AVG (cost)
FROM Catalogue
WHERE pno = 'P4'
GROUP BY pno);…SELECT B.isbn, S.copies
FROM Book B INNER JOIN Stock S
ON B.isbn = S.isbn;
Query 2:
SELECT B.isbn, S.copies
FROM Book B LEFT OUTER JOIN Stock S
ON B.isbn = S.isbn;…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.capacitySELECT S.Student_Name, sum(P.Marks)
FROM Student S, Performance P
WHERE S.Roll_No = P.Roll_No
GROUP BY S.Student_Name
The number of rows that will be returned by the SQL query is ____________.SELECT P1.address
FROM Cinema P1
such that it always finds the addresses of theaters with maximum capacity?employees(emp-id, first-name, last-name, hire-date,
dept-id, salary)departments(dept-id, dept-name, manager-id, location-id)
You want to display the last names and hire dates of all latest hires in their respective departments in the location ID 1700.…employee(empId, empName, empDept)customer(custId, custName, salesRepId, rating)salesRepId is a foreign key referring to empId of the employee relation. Assume that each employee makes a sale to at least one customer. What…SELECT A.Id
FROM A
WHERE A.Age > ALL (SELECT B.Age
FROM B
WHERE B.Name = 'Arun')integer. After the creation of the table, one record (X=1, Y=1) is inserted in the table.
Let MX and MY denote the respective maximum values of X and Y among all records in the table at any point in time. Using MX and MY, new records…Topic guide
In GATE CS, SQL is tested through a balanced mix of declarative query semantics, relational-algebra correspondence, subquery evaluation (correlated, nested, and universal quantification), and instance-level tracing. Questions range from conceptual integrity rules (DDL constraints, FOREIGN KEY targets, GROUP BY/HAVING rules) to practical computation of output row counts and aggregate values on small database instances. Recent papers strongly emphasize NAT execution traces and multi-correct (MSQ) equivalent query formulations.
Instance Tracing and Output/Tuple Counting
common · NAT · 2 marks · 2025, 2023, 2022, 2016
Given small relational instances across 1 to 4 tables, evaluate an SQL query involving joins, WHERE filters, CTEs (WITH clause), or subqueries to determine the number of returned tuples or a scalar aggregate value (e.g., MIN, SUM, AVG).
Universal Quantification and Division via Subqueries
common · MCQ · 2 marks · 2022, 2015, 2014, 2012
Formulating or interpreting 'for all' queries using `NOT EXISTS (correlated subquery)`, `NOT EXISTS (... EXCEPT ...)`, or quantified comparison predicates like `> ALL`, `>= ALL`.
Query Equivalence and Construct Validity
occasional · MSQ · 2 marks · 2025, 2014
Identifying which SQL query or queries among multiple options correctly solve an English problem specification, checking valid SQL syntax (e.g., rejecting non-SQL built-ins like SIZEOF) vs NATURAL JOIN vs EXISTS vs scalar COUNT subqueries.
DDL, Integrity Constraints, and SQL Semantics
common · MCQ · 1 marks · 2021, 2018, 2015, 2014
Conceptual MCQs testing the requirements of FOREIGN KEY references (must reference primary key / unique candidate key), check assertions vs referential actions, bag semantics of SELECT (projection with duplicates), and outer join containment.
Iterative DML State Simulation
rare · MCQ · 2 marks · 2011
Tracing repeated execution of parameterized INSERT/UPDATE operations tracking aggregate values (MAX/MIN) across generations of records.
Vacuous Truth of ALL on Empty Sets
Used when an inner subquery inside `> ALL` or `>= ALL` returns zero rows, causing the WHERE condition to evaluate to true for every outer tuple.
Relational Division via Double Negation / EXCEPT
Used in SQL queries checking `WHERE NOT EXISTS (SELECT ... EXCEPT SELECT ...)` or `WHERE NOT EXISTS (SELECT ... WHERE NOT ...)` to verify that a tuple matches all criteria.
Join Result Set Containment
Used to determine superset/subset relationships among INNER, LEFT, RIGHT, and FULL OUTER joins.
GROUP BY Cardinality
Used to count output tuples when aggregation is performed on joined tables grouped by non-key or key attributes.
Transitioned from pure conceptual MCQs (relational algebra equivalence, join superset properties) to rigorous NAT row-counting and scalar-value calculation from multi-table instances.
2025, 2023, 2022, 2016, 2015, 2012, 2011
Introduction of advanced query features such as Common Table Expressions (WITH clause), multi-column tuple comparison ((col1, col2) IN (...)), and MSQ query equivalences.
2025, 2016, 2014
Sustained focus on edge cases of subquery logic, such as empty subquery evaluation with ALL/ANY and relational division idioms.
2022, 2015, 2014, 2012
Easy: Direct single/two-table SELECT queries with simple WHERE/AND filters, direct relational algebra vs SQL definitions, or basic outer-join containment properties. Medium: Multi-table joins (3–4 tables), queries with CTEs/aggregation comparisons, division queries using double negation/EXCEPT, empty-set quantifier edge cases (> ALL on empty sets), and MSQs discriminating between valid equivalent constructs (EXISTS vs scalar COUNT vs NATURAL JOIN) and invalid syntax.