Skip to content
Official PYQ · 2017

GATE CS 2017 Set 1 Q41 — Tuple Calculus and SQL

Explain with AI

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.

  1. {tt | ∃\existsu ∈\in EMP(t[EmpName] = u[EmpName] ∧\wedge ∀\forallv ∈\in DEPT(t[DeptId] ≠\neq v[DeptId]))}
  2. {tt | ∃\existsu ∈\in EMP(t[EmpName] = u[EmpName] ∧\wedge ∃\existsv ∈\in DEPT(t[DeptId] ≠\neq v[DeptId]))}
  3. {tt | ∃\existsu ∈\in EMP(t[EmpName] = u[EmpName] ∧\wedge ∃\existsv ∈\in DEPT(t[DeptId] == v[DeptId]))}

Which of the above queries are safe?

Choose one option
View worked solution

Answer: D

A query in Tuple Relational Calculus (TRC) is said to be safe if it yields a finite number of result tuples for any database instance.

Let us analyze the three queries:

  • Query I: {tt | ∃\existsu ∈\in EMP(t[EmpName] = u[EmpName] ∧\wedge ∀\forallv ∈\in DEPT(t[DeptId] ≠\neq v[DeptId]))}
  • Query II: {tt | ∃\existsu ∈\in EMP(t[EmpName] = u[EmpName] ∧\wedge ∃\existsv ∈\in DEPT(t[DeptId] ≠\neq v[DeptId]))}
  • Query III: {tt | ∃\existsu ∈\in EMP(t[EmpName] = u[EmpName] ∧\wedge ∃\existsv ∈\in DEPT(t[DeptId] == v[DeptId]))}

In all three queries, the attribute t[EmpName]t[\text{EmpName}] is constrained by t[EmpName]=u[EmpName]t[\text{EmpName}] = u[\text{EmpName}] where u∈EMPu \in \text{EMP}. Since the relation EMP\text{EMP} is finite, the set of possible values for t[EmpName]t[\text{EmpName}] is always finite.

For t[DeptId]t[\text{DeptId}], under the standard relational database assumption, the domain of any attribute is restricted to the active domain (the finite set of all constant values appearing in the database instance). Since the active domain is finite, the possible values for t[DeptId]t[\text{DeptId}] are also restricted to a finite set.

Therefore, all three queries produce a finite number of result tuples, making them all safe.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions