Page 132 - Touhpad Ai
P. 132
Union Operation
The union operation combines two or more relations (tables). The union operation is a binary operation. The resultant
relation of the union operation contains tuples that are in either of the relation or in both relations. The duplicate tuples
are eliminated. The symbol denotes the union operation.
Before applying the union operation, the two relations must satisfy these situations:
u Both the relations have the same number of columns or attributes, also known as the same degree.
u The domain of the attributes of both the relations (pool of data containing values) are the same.
The syntax of Union operation: π Attribute (Relation1) π Attribute (Relation2)
For example, consider the following tables of having different optional subjects. You need to retrieve the names of all
students from French and German tables, without any duplicates. You can write:
π Student_Name (French) π Student_Name (German)
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 union operation on the above two tables Student1 Student2, you get the following result:
Result of the Union Operation
Student_Name
Ronny
Sudha
Punit
Jimmy
Vivek
Kumar
John
Intersection Operation
The intersection operation is also a binary operation. The intersection operation yields the common tuples from the
two tables.
Consider the following tables:
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 are common to both the French and German tables. 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 intersection operation on the above two tables, you get the following result:
130 Touchpad Artificial Intelligence - XI

