Open in App
Not now

# GATE | GATE-CS-2017 (Set 1) | Question 36

• Last Updated : 28 Jun, 2021

Consider a database that has the relation schemas EMP (EmpId, EmpName, DepId), and DEPT(DeptName, DeptId). Note that the DepId 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] â‰  DeptId]))}

II. {t | âˆƒ u âˆˆ EMP (t[EMPName] = u[EmpName] âˆ§ âˆƒ v âˆˆ DEPT (t[DeptId] â‰  DeptId]))}

III. {t | âˆƒ u âˆˆ EMP (t[EMPName] = u[EmpName] âˆ§ âˆƒ v âˆˆ DEPT (t[DeptId] = DeptId]))}

(A)

I and II only

(B)

I and III only

(C)

II and III only

(D)

I, II, and III

Explanation:

A SAFE EXPRESSION is one that is guaranteed to yield a finite number of tuples as its results. Otherwise, it is called UNSAFE

Given, DepId can be permitted to be NULL

I. {t | âˆƒ u âˆˆ EMP (t[EMPName] = u[EmpName] âˆ§ âˆ€ v âˆˆ DEPT (t[DeptId] â‰  DeptId]))} : Gives empnames who donot belong to any department

II. {t | âˆƒ u âˆˆ EMP (t[EMPName] = u[EmpName] âˆ§ âˆƒ v âˆˆ DEPT (t[DeptId] â‰  DeptId]))} : Gives empnames who donot belong to some department

III. {t | âˆƒ u âˆˆ EMP (t[EMPName] = u[EmpName] âˆ§ âˆƒ v âˆˆ DEPT (t[DeptId] = DeptId]))}: Gives empnames who donot belong to some department

All of these queries are giving some results which are finite and thus all are safe expressions.

Therefore, option D is correct.

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Related Articles