Home » Database » Database miscellaneous » Question

Database miscellaneous

  1. 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?
    1. (I) and (II) only
    2. (I) and (III) only
    3. (II) and (III) only
    4. (I), (II) and (III)
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.



Your comments will be displayed only after manual approval.