-
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?
-
- (I) and (II) only
- (I) and (III) only
- (II) and (III) only
- (I), (II) and (III)
- (I) and (II) only
Correct Option: D
Consider the each option.
(i) The results empname who does not belongs to any departments.
(ii) The results empname who does not belongs to some departments.
(iii) The results empname who belongs to same departments. All the given queries generate finite number of tuple hence all are safe query.
Hence, option (d) is correct.