GATE / CS ARCHIVE

GATE CSE 2017 SET 1 / QUESTION 41

GATE CSE 2017 Set 1 Q41

Database Management Systems · Relational Algebra & Calculus · Full GATE CSE 2017 Set 1 paper

GATE 2017 Set 1, Q41 2 marks · MCQ
Report issue

Relational Algebra & Calculus

Question 41, GATE 2017: EMP(EmpId,EmpName,DeptId), DEPT(DeptName,DeptId); EMP.DeptId may be NULL. Which tuple-calculus queries are safe?
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]))}
A I and II; B I and III; C II and III; D all three. No range restriction t∈EMP is printed.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Our answer: Only III under unrestricted-domain TRC; official D under active-domain restriction

1. Safety requires finite results independent of arbitrary values outside the database. The free result tuple t is not explicitly restricted to EMP; only t.EmpName is equated to an employee name in I and II.

2. Use one employee Alice with DeptId 1 and one department with DeptId 1. For every value z outside the database, t=(Alice,z) satisfies I: z differs from every department ID. It also satisfies II because the existing department ID 1 differs from z. Infinitely many z are possible in an unrestricted domain.

3. III instead equates t.EmpName to an EMP name and t.DeptId to a DEPT ID, bounding both fields by finite stored values. Therefore only III is classically safe, but that option is missing. Official D requires an unstated finite active-domain interpretation. Allowing NULL in EMP neither binds t nor removes the counterexample.

Original paper, page 18 · Answer key