GateAI
Relational Model and SQL

GATE CSE 2017 Set 1 · Q41

MCQ2 marksHard

Time

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]))}\{ t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \wedge \forall v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \} (II) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]≠v[DeptId]))}\{ t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \wedge \exists v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \} (III) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]=v[DeptId]))}\{ t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \wedge \exists v \in \text{DEPT}(t[\text{DeptId}] = v[\text{DeptId}])) \} Which of the above queries are safe?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) (I), (II) and (III)

Relational Model and SQL

A Tuple Relational Calculus (TRC) expression {t∣P(t)}\{ t \mid P(t) \} is said to be safe if it is guaranteed to yield a finite number of tuples whose attribute values are drawn strictly from the domain of the expression (the constants appearing in the query and the values present in the database relations).

In all three expressions:

  • The components of the resulting tuple tt are bounded by the database relations: t[EmpName]t[\text{EmpName}] is drawn from the domain of EMP\text{EMP} via ∃u∈EMP(t[EmpName]=u[EmpName])\exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}]), and t[DeptId]t[\text{DeptId}] is constrained relative to the finite values in the DEPT\text{DEPT} / EMP\text{EMP} relation domains.

  • None of the queries generate an infinite relation or depend on values from an infinite universal domain outside the database.

Consequently, all three queries (I), (II), and (III) are safe.

Thus, the correct option is (D).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Relational Model and SQL previous year question is Q41 of the GATE CSE 2017 Set 1 paper. Find more GATE CSE PYQs on Relational Model and SQL in Databases, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Relational Model and SQL PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Relational Model and SQL in GATE CSE

Relational Model and SQL has 15 GATE CSE PYQs across 12 papers from 2011 to 2026. 8 of them are 2-mark MCQs like this one, and GATE CSE 2017 Set 1 has 3.

How GATE tests Relational Model and SQL

More from GATE CSE 2017 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2017 Set 1 · Q41 · MCQ

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])) } (II) { t ∃ u ∈ EMP(t[EmpName] = u[EmpName] ∃ v ∈ DEPT(t[DeptId] ≠ v[DeptId])) } (III) { t ∃ u ∈ EMP(t[EmpName] = u[EmpName] ∃ v ∈ DEPT(t[DeptId] = v[DeptId])) } Which of the above queries are safe?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.