The rename operator
This relational operator is a base for SQL (Structured Query Language) and is used to rename relations.
A rename query looks like the following:
The
The following are some reasons to use the rename operator:
It helps us have user-friendly names so that it is easy to understand.
We can easily write queries without using complex names.
We may want to save the result of a RA expression in the form of a relation.
It removes the confusion of attributes having the same names.
It works really well to distinguish relations/tables that are joined with themselves.
Three following types of renaming can be done:
Renaming a relation
Renaming an attribute
Renaming both
Let's look at the differences between them using examples:
Suppose we have a relation named
Suppose we have a relation named Students and we want to change its attributes
The attributes will be ordered as same as the tables and must be renamed in the same order. If only selective attributes are to be changed, rewrite the original attribute names of those that are supposed to be unchanged.
Next, we'll change both the relation name and attributes of the
Once relations and attributes are renamed, they can be used in the projection and selection operations to access the relations.
Free Resources