edited by
17,287 views
85 votes
85 votes

Which of the following query transformations (i.e., replacing the l.h.s. expression by the r.h.s expression) is incorrect? R1 and R2 are relations, C1 and C2 are selection conditions and A1 and A2 are attributes of R1.

  1. $\sigma_{C_1} \left(\sigma_{C_2}\left(R_1\right)\right) \to \sigma_{C_2} \left(\sigma_{C_1}\left(R_1\right)\right)$
  2. $\sigma_{C_1} \left(\pi_{A_1}\left(R_1\right)\right) \to \pi_{A_1} \left(\sigma_{C_1}\left(R_1\right)\right)$
  3. $\sigma_{C_1} \left(R_1 \cup R_2\right) \to  \sigma_{C_1}\left(R_1\right) \cup \sigma_{C_1} \left(R_2\right)$
  4. $\pi_{A_1} \left(\sigma_{C_1}\left(R_1\right)\right) \to \sigma_{C_1} \left(\pi_{A_1}\left(R_1\right)\right)$
edited by

6 Answers

1 votes
1 votes
It is asked if LHS can be replaced by RHS , so basically does RHS able to produce same ROWS and COLUMNS that LHS can PRODUCE ?

 

-> In option (b) , in LHS , we first TAKE OUT a column A1 and then apply condition  C1 on THAT column .

So it is guaranteed that condition is applied on A1.

Thus we get Column A1 and some Rows in answer according to condition C1.

 

Now in RHS we apply SAME  condition C1 on WHOLE TABLE .

Whole Table will definitely contain Column A1.

And then we keep only Column A1,and eliminate Rest , same as lhs.

 

 

-> In option (b), it is inverse of option (b).

LHS = First Condition c1 Is Applied on Whole table. They Have Not Mentioned that condition is applied on which column. Lets assume its applies on A2. Thus we get some rows.

Now Projection applied on A1. Thus we get column A1 and rows(which satisfy c1) in OUTPUT.

 

But In RHS , they are Projecting column A1 and applying same PREVIOUS Condition C1 which we assumed is applied on A2.

But because we projected only A1 from table we cant apply condition on A2 (bcoz it doesnt exist) . ERROR.

 

ITS JUST THE ORDER THAT MATTERS HERE AND WHETHER RHS CAN PRODUCE SAME OUTPUT AS LHS IN ALL CASES.
0 votes
0 votes
This question can also be answered by using the p -> q analogy this implies statement only becomes FALSE  when p is TRUE and q is FALSE

so, in option D we can see from the below given examples p is TRUE and q is FALSE but in all other option we we get TRUE p-> q

Please refer p-> q truth table i.e.:

P Q

T  T =T

T   F=F

F  T= T

F   F=T
Answer:

Related questions

47 votes
47 votes
2 answers
7
Kathleen asked Sep 25, 2014
9,861 views
There are five records in a database.$$\begin{array}{|c|c|c|c|} \hline \textbf {Name} & \textbf {Age} & \textbf {Occupation} & \textbf{Category } \\\hline \text{Rama} & ...