Dark Mode

0 votes

Let r

p | a | b |

1 | 1 | 2 |

2 | 4 | 3 |

3 | 4 | 4 |

s

b | c |

3 | 12 |

5 | 13 |

2 | 15 |

(r⋈s)

p | a | b | c |

1 | 1 | 2 | 15 |

2 | 4 | 3 | 12 |

1. σ_{(a=4)} (r⋈s) =

2 | 4 | 3 | 12 |

2.let p= σ_{(a=4)}(r) =

2 | 4 | 3 |

3 | 4 | 4 |

p⋈s=

2 | 4 | 3 | 12 |

Note:- same scenario in the case of cross product...

when attribute is not common:-

r

1 | 1 | 2 |

2 | 4 | 3 |

s

3 | 12 |

5 | 13 |

σ_{(a=4)} (r⋈s)=2 touple

σ_{(a=4)} (r)⋈s) = 2 touple

0 votes

First thing first, it's a natural join and the answer will be **a**,

**Case I** -- let there is a common column

if R and S have common column, then the table will join based on that and then the tuples with **A = 'a'**, will be selected.

Now, if you select tuples with **A = 'a'**, and then do the natural join then also the result will be the same. You just are applying the conditions in opposite order.

let they have **test** as common attribute, then the above relational algebra can be written as,

σ_{(A=a) and (r.test = s.test) }(rxs), **joins** are just used to minimize the comparisons, while combining tuples.

**Case II** -- let there be no common column

Natural join will perform the Cartesian product, in case of no common column and then apply the condition **A = 'a'**, which is equivalent to selecting the tuples with condition **A = 'a' **and then apply the Cartesian product.

Coz in both cases in the end the tuples gets selected are with condition **A = 'a'**.