Page 131 - Touhpad Ai
P. 131

Selection Operation
                 The selection operation is a unary operation that chooses 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 (σ).
                 The syntax of the Selection operation: σ condition  (Relation)

                 For example, to select those tuples from the Student relation where the Roll_No attribute is greater than 103, you
                 can write:

                                                            σ        (Student)
                                                             Roll_No > 103
                                     Table: Student                                   Result of Selection
                         Roll_No     Student_ Name    Total_Marks          Roll_No    Student_ Name     Total_Marks
                           100           Ronny            450                104          Kumar             410

                           101            Vivek           420                105          Jimmy             455
                           102           Sudha            390                106           John             430
                           103            Punit           480
                           104           Kumar            410
                           105           Jimmy            455
                           106            John            430

                 Another example is to retrieve all tuples from the Student relation where the Name attribute is Kumar.

                                                        σ Student_Name = “Kumar” (Student)
                                                            Result of Selection

                                                 Roll_No    Student_Name     Total_Marks
                                                    104         Kumar            410

                 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(π).
                 The syntax of the Projection operation: π          (Relation)
                                                      Attribute1, Attribute2,…
                 For example, we have to retrieve the student names from the Student relation where the Total_Marks attribute is
                 greater than 470, you can write:
                                                       π    (σ           (Student))
                                                         Name  Total_Marks>470

                                           Table: Student                                    Result of Projection
                               Roll_No      Student_Name     Total_Marks                       Student_Name
                                 100            Ronny            450                               Punit
                                 101            Vivek            420
                                 102            Sudha            390
                                 103            Punit            480
                                 104            Kumar            410
                                 105            Jimmy            455
                                 106            John             430



                                                                                                Mathematics for AI  129
   126   127   128   129   130   131   132   133   134   135   136