Skip to content
GATEiit

GATE CSE 2017 Session 1 Q51: Which tuple relational calculus queries on EMP and DEPT are safe

Syllabus topic: Relational model: relational algebra, tuple calculus and SQL

Question

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?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: D (official GATE 2017 final answer key)

Concept used: A tuple relational calculus query is safe if its result is finite and drawn from values in the database. The official key (D) evaluates each query only over the values present in EMP and DEPT, under which all three return finite results; under the strict textbook definition, (I) and (II) leave t[DeptId] unbounded, so this question is disputed.

Concept notes

Loading notes…

First step: Note that t[EmpName] is always tied to EMP through u, then see how evaluating over the values present in EMP and DEPT keeps t[DeptId] finite in each query.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Relational model: relational algebra, tuple calculus and SQL

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2017 Session 1 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key