Renames Operation ( ρ ) in Python
Consider the following expression.
ρx (E)
Here, this operator gives the name ‘x’ to the result of the relational algebra expression E.
Consider the following relation
R1 : FACULTY-1
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 |
Example-1: Execute the following SQL expression.
ρx (P Qual (Faculty-1)
Output : Qual
Ph.D.
MTech
Example-2 : Find the names of Ph.D. holders in a new relation named ‘F-PhD’.
ρ F-Ph.D. (P FName(squal = ‘Ph.D.’ (Faculty-1) )
Output : F-PhD
FName
Riya
Max
Fred
Example-3: Find the Salaries of Ph.D. holders belonging to DNo = 24, under a new relation named ‘Sal-PhD-24’.
ρ Sal-PhD-24. (P Salary(squal = ‘Ph.D.’ (Faculty-1) )˄ DNo = 24
Output : Sal-PhD-24
Salary
53000
52000