RENAME (ρ) Operation in Relational Algebra
The RENAME operation is used to rename the output of a relation.
Sometimes it is simple and suitable to break a complicated sequence of operations and rename it as a relation with different names. Reasons to rename a relation can be many, like –
- We may want to save the result of a relational algebra expression as a relation so that we can use it later.
- We may want to join a relation with itself, in that case, it becomes too confusing to specify which one of the tables we are talking about, in that case, we rename one of the tables and perform join operations on them.
ρ X (R)
where the symbol ‘ρ’ is used to denote the RENAME operator and R is the result of the sequence of operation or expression which is saved with the name X.
- Example-1: Query to rename the relation Student as Male Student and the attributes of Student – RollNo, SName as (Sno, Name).
ρ MaleStudent(Sno, Name) πRollNo, SName(σCondition(Student))
- Example-2: Query to rename the attributes Name, Age of table Department to A,B.
ρ (A, B) (Department)
- Example-3: Query to rename the table name Project to Pro and its attributes to P, Q, R.
ρ Pro(P, Q, R) (Project)
- Example-4: Query to rename the first attribute of the table Student with attributes A, B, C to P.
ρ (P, B, C) (Student)