- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

**Relational Algebra** is a procedural query language, it is used to provide a single table / relation as output of performing operations on more than one relations. Some of the basic relations will be discussed here.

In our course of learning, we will use three relations (table) −

Course_id | Name |
---|---|

1 | Computer science |

2 | Information Technology |

3 | mechanical |

Roll No. | Name | address | age |
---|---|---|---|

1 | Ram | Delhi | 18 |

2 | Raju | hyderabad | 20 |

4 | Faiz | Delhi | 22 |

5 | Salman | hyderabad | 20 |

St. No. | Name | address | age |
---|---|---|---|

1 | Ram | Delhi | 18 |

2 | Akash | hyderabad | 20 |

3 | neha | Jhansi | 21 |

On this relations, we will perform some operation to make new relation based on operations performed.

**Selection operation (σ)**− The selection operator denoted by sigma σ is used to select the tuples of a relation based on some condition. Only those tuples that fall under certain conditions are selected.

σ(condition)(relation_name)

Select the student with course id 1. σ(course_id = 1)(student)

Roll No. | Name | address | age |
---|---|---|---|

4 | Faiz | Delhi | 22 |

**Projection operation (∏)**The projection operator denoted by ∏ is used to select columns from a specific reaction. Only specific columns are selected.

∏(column1 , column2 , … , columnn)(relation_name)

Let’s select all students's name and no who are in hostel. ∏( st. No. , name)(hostel)

St. No. | Name |
---|---|

1 | Ram |

2 | Akash |

3 | neha |

The row are always distinct in projection i.e. if their is any other student whose name is panjak the other one is removed.

**Cross Product(X)**- Cross product is denoted using the X symbol and is used to find the value of join of two variables. In cross product each tuple of relation1 is crossed with each tuple of relation2. Which makes the output relation of the order nXm, where n is the number of tuples in relation1 and m is the number of tuples in relation2.

relation1 X relation2

Let’s find cross product of course and hostel table.

student X course

St. No. | Name | address | age | Course_id | Name |
---|---|---|---|---|---|

1 | Ram | Delhi | 18 | 1 | Computer science |

1 | Ram | Delhi | 18 | 2 | Information Technology |

1 | Ram | Delhi | 18 | 3 | mechanical |

2 | Akash | hyderabad | 20 | 1 | Computer science |

2 | Akash | hyderabad | 20 | 2 | Information Technology |

2 | Akash | hyderabad | 20 | 3 | mechanical |

3 | neha | Jhansi | 21 | 1 | Computer science |

3 | neha | Jhansi | 21 | 2 | Information Technology |

3 | neha | Jhansi | 21 | 3 | mechanical |

**Union (U)**- The union of two relations relation1 and relation2 will gives the tuples that are either in relation1 or in relation2 but tuples that are in both relation1 and relation2 are considered only once.Also both relations should be of the same domain for finding there union.

relation1 U relation2

Let’s find the union of student and hostel

student U hostel

Roll No. | Name | address | age |
---|---|---|---|

1 | Ram | Delhi | 18 |

2 | Raju | hyderabad | 20 |

4 | Faiz | Delhi | 22 |

5 | Salman | hyderabad | 20 |

2 | Akash | hyderabad | 20 |

3 | neha | Jhansi | 21 |

**Minus (-) operator**- operator is denoted by - symbol. Relation1 - relation2 will result into a relation in which the tuple in relation1 and not in relation2 are present. For calculating minus too, the relations must be union compatible.

relation1 - relation2

Let’s find the operation student - hostel

student - hostel

Roll No. | Name | address | age |
---|---|---|---|

2 | Raju | hyderabad | 20 |

4 | Faiz | Delhi | 22 |

5 | Salman | hyderabad | 20 |

**rename(ρ)**− the rename operation denoted by the ρ is used to rename the given relation to another name given.

ρ(new_name , old_name)

- Related Questions & Answers
- Extended Operators in Relational Algebra in C++
- Difference between Relational Algebra and Relational Calculus
- Explain the relational algebra in DBMS?
- Java Relational Operators
- Explain rename operation in relational algebra (DBMS)?
- Explain project operation in relational algebra (DBMS)?
- Explain intersection operation in relational algebra (DBMS)?
- Explain union operation in relational algebra (DBMS)?
- Explain cartesian product in relational algebra (DBMS)?
- Explain division operation in relational algebra (DBMS)?
- Relational Operators in C++
- Explain the select operation in relational algebra (DBMS)?
- What is join operation in relational algebra (DBMS)?
- Explain the binary operations in relational algebra (DBMS)?
- Basic operators in Java

Advertisements