Relational Algebra questions

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

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

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

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

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

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

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

Q40

GATE CS 2015 CS-2Relational QueriesMCQ2 marks−2/3 if wrong
Consider two relations R1(A,B)R_1(A,B) with the tuples (1,5), (3,7) and R2(A,C)R_2(A,C) = (1,7), (4,9). Assume that R(A,B,C) is the full natural outer join of R1R_1 and R2R_2. Consider the following tuples of the form (A,B,C): a = (1,5,null), b = (1,null,7), c = (3,null,9), d = (4,7,null), e = (1,5,7), f = (3,7,null), g = (4,null,9). Which one of the following statements is correct?
Show answer without attempting

Answer: C

Q30

GATE CS 2014 CS-2Relational QueriesMCQ2 marks−2/3 if wrong
Consider a join (relation algebra) between relations r(R) and s(S) using the nested loop method. There are 3 buffers each of size equal to disk block size, out of which one buffer is reserved for intermediate results. Assuming size(r(R)) < size(s(S)), the join will have fewer number of disk block accesses if
Show answer without attempting

Answer: A

Q21

GATE CS 2014 CS-3Relational QueriesMCQ1 mark−1/3 if wrong
What is the optimized version of the relation algebra expression πA1(πA2(σF1(σF2(r))))\pi_{A1}(\pi_{A2}(\sigma_{F1}(\sigma_{F2}(r)))) where A1,A2A1, A2 are sets of attributes in rr with A1⊂A2A1 \subset A2 and F1,F2F1, F2 are Boolean expressions based on the attributes in rr?
Show answer without attempting

Answer: A

Q30

GATE CS 2014 CS-3Relational QueriesMCQ2 marks−2/3 if wrong
Consider the relational schema given below, where eId of the relation dependent is a foreign key referring to empId of the relation employee. Assume that every employee has at least one associated dependent in the dependent relation.

employee (empId, empName, empAge)
dependent(depId, eId, depName, depAge)

Consider the following relational algebra query:

ΠempId(employee)−ΠempId(employee⋈(empId=eID)∧(empAge≤depAge)dependent)\Pi_{empId}(\text{employee}) - \Pi_{empId}(\text{employee} \bowtie_{(\text{empId} = \text{eID}) \land (\text{empAge} \le \text{depAge})} \text{dependent})

The above query evaluates to the set of empIds of employees whose age is greater than that of
Show answer without attempting

Answer: D

Q35

GATE CS 2013 CSRelational QueriesMCQ2 marks−2/3 if wrong
Consider the following relational schema.

Students(rollno: integer‾\underline{\text{rollno: integer}}, sname: string)
Courses(courseno: integer‾\underline{\text{courseno: integer}}, cname: string)
Registration(rollno: integer, courseno: integer‾\underline{\text{rollno: integer, courseno: integer}}, percent: real)

Which of the following queries are equivalent to this query in English?
"Find the distinct names of all students who score more than 90% in the course numbered 107"

(I) SELECT DISTINCT S.sname
FROM Students as S, Registration as R
WHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent > 90
(II) Πsname(σcourseno=107∧percent>90(Registration⋈Students))\Pi_{\text{sname}}(\sigma_{\text{courseno}=107 \wedge \text{percent}>90}(\text{Registration} \bowtie \text{Students}))
(III) {T∣∃S∈Students,∃R∈Registration(S.rollno=R.rollno∧R.courseno=107∧R.percent>90∧T.sname=S.sname)}\{T \mid \exists S \in \text{Students}, \exists R \in \text{Registration} (S.\text{rollno}=R.\text{rollno} \wedge R.\text{courseno}=107 \wedge R.\text{percent}>90 \wedge T.\text{sname}=S.\text{sname})\}
(IV) {⟨SN⟩∣∃SR∃RP(⟨SR,SN⟩∈Students∧⟨SR,107,RP⟩∈Registration∧RP>90)}\{\langle S_N \rangle \mid \exists S_R \exists R_P (\langle S_R, S_N \rangle \in \text{Students} \wedge \langle S_R, 107, R_P \rangle \in \text{Registration} \wedge R_P > 90)\}
Show answer without attempting

Answer: A

Q50

GATE CS 2012 CSRelational QueriesMCQ2 marks−2/3 if wrong
How many tuples does the result of the following relational algebra expression contain? Assume that the schema of A∪BA \cup B is the same as that of AA.

(A∪B)⋈A.Id>40∨C.Id<15C(A \cup B) \bowtie_{A.Id > 40 \lor C.Id < 15} C
Show answer without attempting

Answer: A

0/150 correct0 marks

Related topics in Relational Queries