Page 174 - Artificial Intellegence_v2.0_Class_11
P. 174

Relational Algebra

              Relational  algebra  is  a  set  of  algebraic  operators  and  rules  used  to  manipulate  relational  tables  to  generate  the
              required information. Relational algebra takes relations (tables) as its operands and returns relations (tables) as its
              result. Relational algebra consists of eight operators:
              SELECT, PROJECT, JOIN, INTERSECT, UNION, DIFFERENCE, PRODUCT, and DIVIDE.

              Select Operation
              Select operation is a unary operation that selects only some of the tuples (records) of the relation. The selection
              operation yields a subset of the tuples (records) from a relation (table) that satisfies a given condition. This yields a
              horizontal subset. The selection is denoted by lower case Greek letter, sigma σ). For example, to select those tuples
              from the table student whose Rollno is greater than 103, we write: σ Rollno > 103 (Student)

                                    Table: Student                      Result of Selection
                                        Rollno         Name                Rollno       Name
                                         100           Ronny                 104        Kumar
                                         101           Vivek                 105        Jimmy
                                         102           Sudha                 106        John
                                         103           Punit
                                         104          Kumar
                                         105          Jimmy
                                         106           John



              Another example, σ name = Kumar (Student).
                 Rollno     Name

                  104      Kumar


              Projection Operation
              The projection of a relation is defined as a projection of all its tuples over some set of attributes. This operation yields
              a vertical subset of the relation (table). Projection also removes duplicate tuples in the resultant table. It is denoted by
              the Greek letter pi (π). Suppose, we have to select the names of those students who scored more than 250, we shall
              write:
                 π Name (sigma marks>250 (Student))
                          Table: Student                                          Result of Projection
                   Rollno           Name          Marks                                  Name
                     101            Vivek          256
                     102            Sudha          210                                   Vivek
                     103             Punit         269                                   Punit
                     104            Kumar          287
                     105            Jimmy          210                                   Kumar
                     106             John          276                                   John








                    172     Touchpad Artificial Intelligence (Ver. 2.0)-XI
   169   170   171   172   173   174   175   176   177   178   179