Page 133 - Touhpad Ai
P. 133

Result of the Intersection Operation
                                                              Student_Name
                                                                  Sudha

                 Difference Operation
                 The difference operation removes common tuples from the first table. The set operation is denoted by ‘– ‘.
                 The syntax of Intersection operation: π  (Relation1) - π   (Relation2)
                                                    Attribute         Attribute
                 For example, consider the following tables with different optional subjects. You need to retrieve the names of students
                 who have opted for French but not German. You can write:
                                                π Student_Name (Student1) - π Student_Name (Student2)
                                     Table: French                                     Table: German
                        Roll_No      Student_Name       Subject            Roll_No     Student_Name        Subject
                          100            Ronny          French               101            Vivek          German
                          102            Sudha          French               102           Sudha           German
                          103            Punit          French               104           Kumar           German
                          105           Jimmy           French               106            John           German


                 If you perform difference operation on the above two tables, you get the following result:
                                                     Result of the Difference Operation
                                                              Student_Name
                                                                  Ronny
                                                                   Punit

                                                                  Jimmy

                 Cartesian Product Operation
                 The cartesian product of two relations is the concatenation of tuples belonging to the two relations. The cartesian
                 product is a binary operation and is denoted by (x).
                 The syntax of Cartesian Product operation: Relation1 x Relation2
                 For example, consider the following tables with different optional subjects. You need to create all possible pairs of
                 students from the Sanskrit and Teacher tables. You can write:

                                                             Sanskrit x Teacher
                                            Table: Sanskrit                            Table: Teacher
                               Roll_No      Student_Name       Subject          Teacher_ID    Teacher_Name
                                 107           Ananya          Sankrit              201          Mr Naveen
                                 108            Rohan          Sankrit              202          Ms Mehta
                                 109            Meera          Sankrit

                 The Cartesian Product of the above two relations, Sanskrit × Teacher, will produce a relation which has a degree
                 (number of columns) of 5 and a cardinality (number of rows) of 6.
                                                 Result of the Cartesian Product Operation

                                  Roll_No      Student_Name        Subject      Teacher_ID    Teacher_ID
                                     107           Ananya          Sankrit         201         Mr Naveen

                                     107           Ananya          Sankrit         202         Ms Mehta


                                                                                                Mathematics for AI  131
   128   129   130   131   132   133   134   135   136   137   138