Friday, October 30, 2015

Relational Algebra: Project Operator



The Project Operation

The project operation helps to filter out some of the attributes of a relation. In other words we can select part of the attributes of a relation using project operation. Projection is denoted by the uppercase Greek letter pi (Π). We list those attributes of a relation we wish to appear in the result as a subscript to Π. The relation appears in parenthesis after the projection.

If we wish to list all loan numbers and amount of the loans for the loan relation, we write:





Consider the more complicated query “Find those customers who live in Dhaka city”. We write:
 


This query is a composition of the relational operations of both select and projection.





         



Thursday, October 22, 2015

Relational Algebra: Select Operator



Relational Algebra

A query language is a language in which a user requests information from the database. These languages can be categorized as either procedural or non-procedural. The relational algebra is procedural. Here I introduce the SELECT operator in relational algebra.

 The SELECT Operation          

The select operation selects tuples that satisfy a given condition. The select operation is denoted by the Greek letter sigma (σ) The condition appears as a subscript to σ. The relation is enclosed in parenthesis after the σ.

Considering the Banking Enterprise problem, if we want to select those tuples of the loan relation where the branch is “Kakrail”, we write:


 σ                      (Loan) 
     branch_name=“kakrail” 
               
 
Another problem to find all tuples of loan relation in which the amount lent is more than Tk1000 can be solved as :

 σ         (Loan)
     amount>1000           
               
             
              














In general, we allow comparisons using =, !=, <, <=, >, >= in the selection condition.

To find those tuples of loan relation in which the amount lent is more than Tk1000 made by Kakrail branch, we write:



         σ                                           (Loan)
             branch_name=”kakrail” Λ amount>1000
 

Here Λ stands for AND.