Thursday, December 10, 2015

Relational Algebra Operations Continued



Modification of the Database

 Deletion

Here are several examples of relational algebra delete operations:

         Delete all of Smith’s account records


         Delete all loans with amount in the range 0 to 50.

    Delete all accounts at branches located in Dhaka.  

 


Insertion

Suppose we wish to insert the fact that Smith has Tk1200 in account A-973 at Kakrail branch. We write:




Updating

Suppose that interest rates are being made, and that all branches are to be increased by 5%.  For this we require an update operation.

 


Suppose that accounts with balances over Tk10,000 receive 6% interest, where as all others receive 5%.






Thursday, December 3, 2015

Relational Algebra Operations Continued



The Division Operation

The division operation in relational algebra, denoted by ÷, is suited to queries that include the phrase “for all”.

Suppose that we wish to find all customers who have an account at all branches located in Dhaka.

Firstly we can obtain all branches in Dhaka by the expression:



We can find all (customer_name, branch_name) for which the customer has an account at a branch by writing:
 



We need to find customers who appear in r2 with every branch name in r1. The operation that provides exactly those customers is the divide operation that is, the customers who have an account for all branches in Dhaka city.