Natural Join Operation, Assignment Operation in Python
Natural Join Operation ( |X| ):
This operation combines one tuple from relation-1 with another tuple from relation-2, only when the common attribute values of both the relations are the same.
Consider the following relation :
R1 : STUD | R2 : DEPT | ||||
SNo | SName | DNo | DNo | DName | |
21 | Riya | 21 | 21 | CSE | |
23 | Priya | 21 | 22 | IT | |
26 | Zayn | 22 | 23 | ECE | |
28 | Harry | 22 | 24 | ME | |
30 | Sia | 23 | 25 | EEE |
Example-1 : Combine the above two relations with the Natural Join operator.
STUD |X| DEPT
Output : Here the first tuple in STUD is combined with the first tuple in DEPT.
There will be a total of 5 tuples and 4 attributes.
SNo | SName | DNo | DName |
21 | Riya | 21 | CSE |
23 | Priya | 22 | IT |
26 | Zayn | 23 | ECE |
28 | Harry | 24 | ME |
30 | Sia | 25 | EEE |
Assignment Operation ( ß ):
This operation finds the result on RHS and keeps it in LHS.
Example-2 : Execute the following SQL expression for the following table
FNo | FName | DNo | Qual | Salary |
22 | Riya | 21 | Ph.D | 55000 |
24 | Priya | 22 | M. Tech | 50000 |
25 | Zayn | 22 | M. Tech | 42000 |
27 | Harry | 23 | M. Tech | 28000 |
30 | Sia | 23 | M. Tech | 32000 |
33 | Max | 24 | Ph.D | 53000 |
35 | Fred | 24 | Ph.D | 52000 |
37 | Diva | 25 | M. Tech | 26000 |
39 | Ben | 25 | M. Tech | 24000 |
40 | Trent | 25 | M. Tech | 34000 |
XXX ß sDNo = 25 (Faculty-1)
Output : XXX
FNo | FName | DNo | Qual | Salary |
37 | Diva | 25 | M. Tech | 26000 |
39 | Ben | 25 | M. Tech | 24000 |
40 | Trent | 25 | M. Tech | 34000 |