/  Technology   /  Renames Operation ( ρ ) in Python

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

FNoFNameDNoQualSalary
22Riya21Ph.D55000
24Priya22M. Tech50000
25Zayn22M. Tech42000
27Harry23M. Tech28000
30Sia23M. Tech32000
33Max24Ph.D53000
35Fred24Ph.D52000
37Diva25M. Tech26000
39Ben25M. Tech24000
40Trent25M. Tech34000

 

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             

 

Leave a comment