Relational Queries questions — page 1 of 2

Q43

GATE CS 2026 CS-1Relational QueriesMCQ2 marks−2/3 if wrong
Consider a relational database schema with two relations R(P,Q)R(P, Q) and S(X,Y)S(X, Y).

Let E={⟨u⟩∣∃v∃w⟨u,v⟩∈R∧⟨v,w⟩∈S}E = \{\langle u \rangle \mid \exists v \exists w \langle u, v \rangle \in R \land \langle v, w \rangle \in S\} be a tuple relational calculus expression.

Which one of the following relational algebraic expressions is equivalent to EE?
Show answer without attempting

Answer: B

Q39

GATE CS 2025 CS-1Relational QueriesMCQ2 marks−2/3 if wrong
Consider two relations describing teamsteams and playersplayers in a sports league:
- teams(tid,tname)teams(tid, tname): tid,tnametid, tname are team-id and team-name, respectively
- players(pid,pname,tid)players(pid, pname, tid): pid,pnamepid, pname, and tidtid denote player-id, player-name and the team-id of the player, respectively
Which ONE of the following tuple relational calculus queries returns the name of the players who play for the team having tnametname as ′MI′'MI'?
Show answer without attempting

Answer: A

Q55

GATE CS 2025 CS-1Relational QueriesNAT2 marks
Consider the following database tables of a sports league.
player(pid,pname,age)
coach(cid,cname)
team(tid,tname,city,cid)
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
 )
The value returned by the given SQL query is ______ . (Answer in integer)
Question figure
Show answer without attempting

Answer: 26

Q54

GATE CS 2025 CS-2Relational QueriesMSQ2 marks
Consider the following relational schema:

Students (rollno: integer‾\underline{\text{rollno: integer}}, name: string, age: integer, cgpa: real)
Courses (courseno: integer‾\underline{\text{courseno: integer}}, cname: string, credits: integer)
Enrolled (rollno: integer‾\underline{\text{rollno: integer}}, courseno: integer‾\underline{\text{courseno: integer}}, grade: string)

Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e., courseno) 1470?
More than one option can be correct.
Show answer without attempting

Answer: A, C, D

Q35

GATE CS 2024 CS-1Relational QueriesNAT1 mark
Consider the following two relations, R(A,B) and S(A,C):

The total number of tuples obtained by evaluating the following expression
σB<C(R⋈R.A=S.AS)\sigma_{B<C}(R \bowtie_{R.A=S.A} S)
is _________
Question figure
Question figure
Show answer without attempting

Answer: 2

Q45

GATE CS 2024 CS-2Relational QueriesMCQ2 marks−2/3 if wrong
The relation schema, Person(pid, city)\text{Person(pid, city)}, describes the city of residence for every person uniquely identified by pid\text{pid}. The following relational algebra operators are available: selection, projection, cross product, and rename.

To find the list of cities where at least 3 persons reside, using the above operators, the minimum number of cross product operations that must be used is
Show answer without attempting

Answer: B

Q61

GATE CS 2023 CSRelational QueriesNAT2 marks
Consider the following table named Student in a relational database. The primary key of this table is rollNum.

Student
rollNumnamegendermarks
1NamanM62
2AliyaF70
3AliyaF80
4JamesM82
5SwatiF65
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 ____________.
Show answer without attempting

Answer: 2

Q25

GATE CS 2022 CSRelational QueriesMSQ1 mark
Consider the following three relations in a relational database.

Employee(eId‾,Name),Brand(bId‾,bName),Own(eId‾,bId‾)\text{Employee}(\underline{\text{eId}}, \text{Name}), \text{Brand}(\underline{\text{bId}}, \text{bName}), \text{Own}(\underline{\text{eId}}, \underline{\text{bId}})

Which of the following relational algebra expressions return the set of eIds who own all the brands?
More than one option can be correct.
Show answer without attempting

Answer: A, B

Q56

GATE CS 2022 CSRelational QueriesNAT2 marks
Consider the relational database with the following four schemas and their respective instances.

Student(sNo‾\underline{\text{sNo}}, sName, dNo) Dept(dNo‾\underline{\text{dNo}}, dName)
Course(cNo‾\underline{\text{cNo}}, cName, dNo) Register(sNo‾\underline{\text{sNo}}, cNo‾\underline{\text{cNo}})

Student
sNosNamedNo
S01JamesD01
S02RockyD01
S03JacksonD02
S04JaneD01
S05MilliD02
Dept
dNodName
D01CSE
D02EEE
Course
cNocNamedNo
C11DSD01
C12OSD01
C21DED02
C22PTD02
C23CVD03
Register
sNocNo
S01C11
S01C12
S02C11
S03C21
S03C22
S03C23
S04C11
S04C12
S05C11
S05C21
SQL Query:
SELECT * FROM Student AS S WHERE NOT EXIST
 (SELECT cNo FROM Course WHERE dNo = “D01”
 EXCEPT
 SELECT cNo FROM Register WHERE sNo = S.sNo)
The number of rows returned by the above SQL query is___________.
Show answer without attempting

Answer: 2

Q23

GATE CS 2021 CS-1Relational QueriesNAT1 mark
A relation r(A,B)r(A, B) in a relational database has 1200 tuples. The attribute AA has integer values ranging from 6 to 20, and the attribute BB has integer values ranging from 1 to 20. Assume that the attributes AA and BB are independently distributed.
The estimated number of tuples in the output of σ(A>10)∨(B=18)(r)\sigma_{(A>10) \vee (B=18)}(r) is ______.
Show answer without attempting

Answer: 819 to 820 OR 205

Q27

GATE CS 2021 CS-1Relational QueriesMCQ2 marks−2/3 if wrong
The following relation records the age of 500 employees of a company, where empNo (indicating the employee number) is the key:
empAge(empNo‾,age)empAge(\underline{empNo}, age)
Consider the following relational algebra expression:
ΠempNo(empAge⋈(age>age1)ρempNo1, age1(empAge))\Pi_{empNo}\left(empAge \bowtie_{(age > age1)} \rho_{empNo1,\, age1}(empAge)\right)
What does the above expression generate?
Show answer without attempting

Answer: C

Q31

GATE CS 2021 CS-2Relational QueriesMCQ2 marks−2/3 if wrong
The relation scheme given below is used to store information about the employees of a company, where empId is the key and deptId indicates the department to which the employee is assigned. Each employee is assigned to exactly one department.

emp(empId‾\underline{\text{empId}}, name, gender, salary, deptId)

Consider the following SQL query:
select deptId, count(*)
from emp
where gender = "female" and salary > (select avg(salary) from emp)
group by deptId;
The above query gives, for each department in the company, the number of female employees whose salary is greater than the average salary of
Show answer without attempting

Answer: B

Q13

GATE CS 2020 CSRelational QueriesMCQ1 mark−1/3 if wrong
Consider a relational database containing the following schemas (the tables Catalogue, Suppliers and Parts are shown in the figure).

The primary key of each table is indicated by underlining the constituent fields.
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);
The number of rows returned by the above SQL query is
Question figure
Show answer without attempting

Answer: A

Q51

GATE CS 2019 CSRelational QueriesNAT2 marks
A relational database contains two tables Student and Performance as shown below:

Student
Roll_no.Student_name
1Amit
2Priya
3Vinit
4Rohan
5Smita
Performance
Roll_no.Subject_codeMarks
1A86
1B95
1C90
2A89
2C92
3C80
The primary key of the Student table is Roll_no. For the Performance table, the columns Roll_no. and Subject_code together form the primary key. Consider the SQL query given below:
SELECT S.Student_name, sum(P.Marks)
FROM Student S, Performance P
WHERE P.Marks > 84
GROUP BY S.Student_name;
The number of rows returned by the above SQL query is __________.
Show answer without attempting

Answer: 5

Q55

GATE CS 2019 CSRelational QueriesNAT2 marks
Consider the following relations P(X, Y, Z), Q(X, Y, T) and R(Y, V).

P
XYZ
X1Y1Z1
X1Y1Z2
X2Y2Z2
X2Y4Z4
Q
XYT
X2Y12
X1Y25
X1Y16
X3Y31
R
YV
Y1V1
Y3V2
Y2V3
Y2V2
How many tuples will be returned by the following relational algebra query?
∏X(σ(P.Y=R.Y∧R.V=V2)(P×R))−∏X(σ(Q.Y=R.Y∧Q.T>2)(Q×R))\prod_X \left(\sigma_{(P.Y = R.Y \land R.V = V2)}(P \times R)\right) - \prod_X \left(\sigma_{(Q.Y = R.Y \land Q.T > 2)}(Q \times R)\right)
Answer: __________.
Show answer without attempting

Answer: 1

Q12

GATE CS 2018 CSRelational QueriesMCQ1 mark−1/3 if wrong
Consider the following two tables and four queries in SQL.

Book (isbn, bname), Stock (isbn, copies)

Query 1: 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;

Query 3: SELECT B.isbn, S.copies
FROM Book B RIGHT OUTER JOIN Stock S
ON B.isbn = S.isbn;

Query 4: SELECT B.isbn, S.copies
FROM Book B FULL OUTER JOIN Stock S
ON B.isbn = S.isbn;

Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
Show answer without attempting

Answer: D

Q41

GATE CS 2018 CSRelational QueriesMCQ2 marks−2/3 if wrong
Consider the relations r(A,B)r(A, B) and s(B,C)s(B, C), where s.Bs.B is a primary key and r.Br.B is a foreign key referencing s.Bs.B. Consider the query

Q:r⋈(σB<5(s))Q: r \bowtie (\sigma_{B<5}(s))

Let LOJ denote the natural left outer-join operation. Assume that rr and ss contain no null values.

Which one of the following queries is NOT equivalent to QQ?
Show answer without attempting

Answer: C

Q23

GATE CS 2017 CS-1Relational QueriesNAT1 mark
Consider a database that has the relation schema EMP(EmpId, EmpName, and DeptName). An instance of the schema EMP and a SQL query on it are given below.
EmpIdEmpNameDeptName
1XYAAA
2XYBAA
3XYCAA
4XYDAA
5XYEAB
6XYFAB
7XYGAB
8XYHAC
9XYIAC
10XYJAC
11XYKAD
12XYLAD
13XYMAE
SELECT AVG(EC.Num)
FROM EC
WHERE (DeptName, Num) IN
    (SELECT DeptName, COUNT(EmpId) AS
                    EC(DeptName, Num)
     FROM EMP
     GROUP BY DeptName)
The output of executing the SQL query is ____________.
Show answer without attempting

Answer: 2.6

Q41

GATE CS 2017 CS-1Relational QueriesMCQ2 marks−2/3 if wrong
Consider a database that has the relation schemas EMP(EmpId, EmpName, DeptId), and DEPT(DeptName, DeptId). Note that the DeptId can be permitted to be NULL in the relation EMP.
Consider the following queries on the database expressed in tuple relational calculus.

(I) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∀v∈DEPT(t[DeptId]≠v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \forall v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \rbrace
(II) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]≠v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \exists v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \rbrace
(III) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]=v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \exists v \in \text{DEPT}(t[\text{DeptId}] = v[\text{DeptId}])) \rbrace

Which of the above queries are safe?
Show answer without attempting

Answer: D

Q46

GATE CS 2017 CS-1Relational QueriesNAT2 marks
Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the schema CR is as given below.
StudentNameCourseName
SACA
SACB
SACC
SBCB
SBCC
SCCA
SCCB
SCCC
SDCA
SDCB
SDCC
SDCD
SECD
SECA
SECB
SFCA
SFCB
SFCC
The following query is made on the database.

T1←πCourseName(σStudentName=′SA′(CR))T1 \leftarrow \pi_{\text{CourseName}}(\sigma_{\text{StudentName} = '\text{SA}'}(\text{CR}))
T2←CR÷T1T2 \leftarrow \text{CR} \div T1

The number of rows in T2T2 is ____________.
Show answer without attempting

Answer: 4.0

0/200 correct0 marks

Related topics in Databases