Thursday, November 19, 2015

Relational Algebra Operations Continued



The Natural-Join Operation

It is often desirable to simplify certain queries that require a Cartesian product. Usually, a query that involves a Cartesian product includes a selection operation on the result of the Cartesian Product. Consider the query “Find the names of all customers who have a loan at the bank, along with the loan number and the loan amount.”



The natural join is a binary operation that allows us to combine certain selections and a Cartesian product into one operation. It is denoted by the join symbol ∞. The natural-join operation forms a Cartesian product of its two arguments, performs a selection forcing equality on those attributes that appear in both the relation schemas and finally removes duplicate attributes.

We express this query by using the natural join as follows:



  • Find the names of all branches with customers who have an account in the bank and who live in Dhaka.
     



The natural join operation on the three relations can be executed in any order.

  • Find all customers who have both a loan and an account at the bank.
     

 

We can write an expression for this query by using set intersection as follows:

                      

No comments:

Post a Comment