Let R and S be two relations with the following schema
where is the key for both schemas. Which of the following queries are equivalent?
View worked solution
Answer: D
To find the equivalent queries, let us analyze each expression based on the schema where the common attributes between and are and :
- Query I:
Since the common attributes of and are and , the natural join performs an equality match on both and . Thus, the pairs in the join are exactly those present in both relations. Projecting this result on yields the -values of the common pairs. - Query III:
This expression explicitly finds the intersection of the pairs from both relations and then projects the result on . This is semantically identical to Query I. Thus, I III. - Query IV:
Using the set-theoretic identity , we can simplify the inner expression: Applying the outer projection makes this query identical to Query III. Thus, I III IV. - Query II:
This performs a join only on the attribute . For example, if and , then , but (and thus ). Hence, Query II is not equivalent to the others.
Therefore, only queries I, III, and IV are equivalent.
Free practice · Your answers on this page are not saved.
