GATE Papers >> CSE >> 2017 >> Question No 41

Question No. 41 CSE | GATE 2017

Consider  a database that has the relation schems EMP (Empld, EmpName, DeptId), and DEPT (DeptName, DeptId). Note that the DeptId can be permited to be NULL in the relation EMP. Consider the following queries on the database expressed in tuple relational calculus.

$\style{font-family:'Times New Roman'}{\begin{array}{l}(\mathrm I)\;\{\mathrm t\vert\exists\mathrm u\in\mathrm{EMP}(\mathrm t\lbrack\mathrm{EmpName}\rbrack=\mathrm u\lbrack\mathrm{EmpName}\rbrack\wedge\forall\mathrm v\in\mathrm{DEPT}\;(\mathrm t\lbrack\mathrm{DeptId}\rbrack\neq\mathrm v\lbrack\mathrm{DeptId}\rbrack))\}\\(\mathrm{II})\;\{\mathrm t\vert\exists\mathrm u\in\mathrm{EMP}(\mathrm t\lbrack\mathrm{EmpName}\rbrack=\mathrm u\lbrack\mathrm{EmpName}\rbrack\wedge\exists\mathrm v\in\mathrm{DEPT}\;(\mathrm t\lbrack\mathrm{DeptId}\rbrack\neq\mathrm v\lbrack\mathrm{DeptId}\rbrack))\}\\(\mathrm{III})\;\{\mathrm t\vert\exists\mathrm u\in\mathrm{EMP}(\mathrm t\lbrack\mathrm{EmpName}\rbrack=\mathrm u\lbrack\mathrm{EmpName}\rbrack\wedge\exists\mathrm v\in\mathrm{DEPT}\;(\mathrm t\lbrack\mathrm{DeptId}\rbrack=\mathrm v\lbrack\mathrm{DeptId}\rbrack))\}\end{array}}$ 

Which of the above queries are safe?


Answer : (D) (I) ,(II) and (II)


Solution of Question No 41 of GATE 2017 CSE Paper

$ \begin{array}{l}\mathbf I\boldsymbol.\;\;\;\;\{t\vert\exists u\in\;\mathrm{EMP}(t\left[\mathrm{EmpName}\right]=u\left[\mathrm{EmpName}\right]\\\;\;\;\;\;\;\wedge\forall v\in\;\mathrm{DEPT}\left(t\left[\mathrm{DeptId}\right]\neq v\left[\mathrm{DeptId}\right])\right)\}\end{array} $

     results empname who does not belongs to any departments (safe query).

$ \begin{array}{l}\mathbf{II}\boldsymbol.\;\;\;\{t\vert\exists u\in\;\mathrm{EMP}(t\left[\mathrm{EmpName}\right]=u\left[\mathrm{EmpName}\right]\\\;\;\;\;\;\;\wedge\exists v\in\;\mathrm{DEPT}\left(t\left[\mathrm{DeptId}\right]\neq v\left[\mathrm{DeptId}\right])\right)\}\end{array} $

     results empname who does not belongs to some departments (safe query).

$ \begin{array}{l}\mathbf{III}\boldsymbol.\;\;\;\{t\vert\exists u\in\;\mathrm{EMP}(t\left[\mathrm{EmpName}\right]=u\left[\mathrm{EmpName}\right]\\\;\;\;\;\;\;\wedge\exists v\in\;\mathrm{DEPT}\left(t\left[\mathrm{DeptId}\right]=v\left[\mathrm{DeptId}\right])\right)\}\end{array} $

     resluts empname who belongs to same departments (safe query).

$\therefore$ All are safe queries.

Comments
No Comments
Leave a comment