Review of Relational Algebra

  • Relational Algebra:

    • is a mathematical language for manipulating sets


  • Recall that a relation is:

    • a set of tuples

    Example: the employee relation is a set of employee tuples

    ssn       fname  lname    salary    dname           
    --------- ------ -------- --------- --------------- 
    123456789 John   Smith    20900.00  Research        
    333445555 Frankl Wong     50000.00  Research        
    999887777 Alicia Zelaya   25000.00  Administration     <-- 1 tuple      
    987654321 Jennif Wallace  43000.00  Administration  
    666884444 Ramesh Narayan  38000.00  Research        
    453453453 Joyce  English  25000.00  Research        
    987987987 Ahmad  Jabbar   25000.00  Administration  
    888665555 James  Borg     55000.00  Headquarters    
    

Operators in Relational Algebra

  • Operations in Relational Algebra can be divided into 3 categories:

    1. Set operators:

      • = set union
      • = set intersection
      • = set difference
      • × = cartesian product

    2. Relational database specific operators:

      • σ = the selection operator
      • π = the projection operator
      • = the join operator

    3. Aggregate functions:

      • sum:     find the sum of a set of values
      • avg:      find the average of a set of values
      • count:  find the cardinality of a set of values       
      • any:      find the existance of a set of values
      • max:     find the maximum of a set of values
      • min:     find the minumum of a set of values

Properties of Relational Algebra operators

  • Property of Relational Algebra operators:

    • A Relational Algebra operator/function operates on one or more input set(s) (of tuples)

    • A Relational Algebra operator/function produces an output set (of tuples)

    Graphical representation of a Relational Algebra operator: