The Select, Project & Rename Operation​ in Relational Algebra

Antosh Dyade November 09, 2022


The Select Operation​

  • The select operation select tuples that satisfy a given predicate.​
  • The small Greek letter sigma(σ) is use to denote select operation​
  • The predicate appears as a subscript to σ​
  • The Comparison operator =,≠,<,>,≤,≥​
  • The Connectives and(∧ ), or( v), not(¬)​

  



Examples

  • To Select the tuples from employee relations those employees belong to CSE Department
    • σdept_name='CSE'(employees)
  • The employees whose salary greater than 12000/-​
    •  σemp_salary>12000(employees)
  • Department is CSE and Salary is greater than 12000/- ​
    • σdept_name='CSE' ∧ emp_salary>12000(employees)


Project Operation

  • It is Unary operation​
  • It selects certain columns from a table while discarding others. ​
  • It removes any duplicated rows from the result relation.​
  • Denoted by the uppercase Greek letter pi (Π)​
  • The attribute list appears in the subscript to  Π  with argument relation in parentheses. ​

Examples:

  • ΠId,name,dept,salary(employees)
    • Selects only id, name, dept_salary Form employees relation.​
  • Πtitle,Author(Book)
    • Display all title and author from book relation

Composition of Relation Operations
  • The relational-algebra operations can be composed together into a relational-algebra expression it is just like composing arithmetic operations into athematic expression. ​
  • Example​
    • Πname(σdept_name='CSE'(employees))


Rename Operation


  • In Relational algebra, we can rename either the relation or the attributes or both.​
  • It is denoted by lowercase Greek letter rho (ρ)​
    • ρs(new attribute name)(R)
    • ρs(R)
    • ρ(new attribute name)(R)

Examples:

  • ρt1(fn,ln,sal)(R)
    • Rename relation R with new relation t1 with  new name for the listed attributes ​
  • ρ(fn,ln,sal)(R)
    • Rename only attributes listed in the brackets.​
  • ρt1(R)
    • Rename only relation R with new name t1.​

Share this

Related Posts

Previous
Next Post »