edited by
136 views
2 votes
2 votes

Consider the following database schema with a relation $\textsf{"Likes" :}$
$$\textsf{Likes(kid, candy)}$$

Table Likes tells which candy a kid likes.

Consider the following relational algebra query :
$$\begin{aligned}
&\textsf{H} \leftarrow \Pi_{\textsf{KID}}\left(\sigma_{\textsf{CANDY = "HERSHEYS" }}(\textsf{LIKES})\right)\\
&\textsf{M} \leftarrow \Pi_{\textsf{KID}}\left(\sigma_{\textsf{CANDY = "MARS" }}(\textsf{LIKES})\right)\\
&\textsf{BOTH} \leftarrow \textsf{H UNION M}\\
&\Pi_{\textsf{KID}}(\textsf{BOTH})
\end{aligned}$$
Which of the following is true about the result of the above query?

  1. The query is to find the kids who like "Hersheys" and "Mars" candy.
  2. The query is to find the kids who like "Hersheys" candy but not "Mars" candy.
  3. The query is to find the kids who like "Hersheys" or "Mars" candy.
  4. The query is to find the kids who like neither "Hersheys" nor "Mars" candy.
edited by

1 Answer

2 votes
2 votes
$\textsf{H}$ will have those $\textsf{KIDS}$ who like Hershays candy.
$\textsf{M}$ will have those $\textsf{KIDS}$ who like Mars candy.
$\textsf{“BOTH”}$ will have those $\textsf{KIDS}$ who like Hershays candy or Mars candy.
From $\textsf{“BOTH”},$ we project the Kids.
Answer:

No related questions found