Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Basic Operators in Relational Algebra
Next article icon

Basic Operators in Relational Algebra

Last Updated : 12 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The Relational Model is a way of structuring data using relations, which are a collection of tuples that have the same attributes. Relational Algebra is a procedural query language that takes relations as input and returns relations as output. Here, we'll explore the basic operators of Relational Algebra using below tables.

Table 1: STUDENT_SPORTS

ROLL_NOSPORTS
1Badminton
2Cricket
2Badminton
4Badminton

 Table 2: EMPLOYEE

EMP_NONAMEADDRESSPHONEAGE
1RAMDELHI945512345118
5NARESHHISAR978291819222
6SWETARANCHI985261762121
4SURESHDELHI915676897118

Table 3: STUDENT 

ROLL_NONAMEADDRESSPHONEAGE
1RAMDELHI945512345118
2RAMESHGURGAON965243154318
3SUJITROHTAK915625313120
4SURESHDELHI915676897118

1. Selection operator (σ)

Selection operator is used to selecting tuples from a relation based on some condition. 

Syntax: 

σ (Cond)(Relation Name)

Extract students whose age is greater than 18 from STUDENT relation given in Table 3  

σ (AGE>18)(STUDENT)

Note: SELECT operation does not show any result, the projection operator must be called before the selection operator to generate or project the result. So, the correct syntax to generate the result is:

∏(σ (AGE>18)(STUDENT))

Result: 

ROLL_NONAMEADDRESSPHONEAGE
3SUJITROHTAK915625313120

2. Projection Operator (∏)

Projection operator is used to project particular columns from a relation. 

Syntax:  

∏(Column 1,Column 2….Column n)(Relation Name)

Extract ROLL_NO and NAME from STUDENT relation given in Table 3  

∏(ROLL_NO,NAME)(STUDENT)

Result:  

ROLL_NONAME
1RAM
2RAMESH
3SUJIT
4SURESH

Note: If the resultant relation after projection has duplicate rows, it will be removed. For Example  ∏(ADDRESS)(STUDENT) will remove one duplicate row with the value DELHI and return three rows. 

3. Cross Product(X)

Cross product is used to join two relations. For every row of Relation1, each row of Relation2 is concatenated. If Relation1 has m tuples and and Relation2 has n tuples, cross product of Relation1 and Relation2 will have m X n tuples. 

Syntax: 

Relation1 X Relation2

To apply Cross Product on STUDENT relation given in Table 1 and STUDENT_SPORTS relation given in Table 2,  

STUDENT X STUDENT_SPORTS

Result:

ROLL_NONAMEADDRESSPHONEAGEROLL_NOSPORTS
1RAMDELHI9455123451181Badminton
1RAMDELHI9455123451182Cricket
1RAMDELHI9455123451182Badminton
1RAMDELHI9455123451184Badminton
2RAMESHGURGAON9652431543181Badminton
2RAMESHGURGAON9652431543182Cricket
2RAMESHGURGAON9652431543182Badminton
2RAMESHGURGAON9652431543184Badminton
3SUJITROHTAK9156253131201Badminton
3SUJITROHTAK9156253131202Cricket
3SUJITROHTAK9156253131202Badminton
3SUJITROHTAK9156253131204Badminton
4SURESHDELHI9156768971181Badminton
4SURESHDELHI9156768971182Cricket
4SURESHDELHI9156768971182Badminton
4SURESHDELHI9156768971184Badminton

4. Union (U)

Union on two relations R1 and R2 can only be computed if R1 and R2 are union compatible (These two relations should have the same number of attributes and corresponding attributes in two relations have the same domain). Union operator when applied on two relations R1 and R2 will give a relation with tuples that are either in R1 or in R2. The tuples which are in both R1 and R2 will appear only once in the result relation. 

Syntax: 

 Relation1 U Relation2

Find the person who is either student or employees, we can use Union operators like: 

STUDENT U EMPLOYEE

RESULT:  

ROLL_NONAMEADDRESSPHONEAGE
1RAMDELHI945512345118
2RAMESHGURGAON965243154318
3SUJITROHTAK915625313120
4SURESHDELHI915676897118
5NARESHHISAR978291819222
6SWETARANCHI985261762121

5. Minus (-) or Set Difference

Minus on two relations R1 and R2 can only be computed if R1 and R2 are union compatible. Minus operator when applied on two relations as R1-R2 will give a relation with tuples that are in R1 but not in R2. Syntax: 

 Relation1 - Relation2

Find the person who is a student but not an employee, we can use minus operator like:  

STUDENT - EMPLOYEE

Result:

ROLL_NONAMEADDRESSPHONEAGE
2RAMESHGURGAON965243154318
3SUJITROHTAK915625313120

6. Rename(ρ)

Rename operator is used to giving another name to a relation. 

Syntax:  

ρ(Relation2, Relation1)

To rename STUDENT relation to STUDENT1, we can use rename operator like:  

ρ(STUDENT1, STUDENT)

If you want to create a relation STUDENT_NAMES with ROLL_NO and NAME from STUDENT, it can be done using rename operator as:  

ρ(STUDENT_NAMES, ∏(ROLL_NO, NAME)(STUDENT))

Extended Relational Algebra Operators

  • Intersection (∩)
  • Division (÷)
  • Join Operations (⋈)
  • Natural Join
  • Theta Join
  • Equi Join

These operators provide more functionality for complex queries in relational databases.


Next Article
Basic Operators in Relational Algebra

K

kartik
Improve
Article Tags :
  • DBMS
  • DBMS-Relational Algebra

Similar Reads

    Introduction of DBMS (Database Management System)
    A Database Management System (DBMS) is a software solution designed to efficiently manage, organize, and retrieve data in a structured manner. It serves as a critical component in modern computing, enabling organizations to store, manipulate, and secure their data effectively. From small application
    8 min read
    Need for DBMS
    A DBMS is essential for efficiently storing, organizing, and managing large amounts of data. It ensures data consistency, integrity, and security while allowing multiple users to access and manipulate data simultaneously. DBMS simplifies complex data operations and supports quick retrieval, making d
    7 min read
    Advantages of DBMS over File system
    File System: A File Management system is a DBMS that allows access to single files or tables at a time. In a File System, data is directly stored in a set of files. It contains flat files that have no relation to other files (when only one table is stored in a single file, then this file is known as
    4 min read
    Introduction of ER Model
    The Entity-Relationship Model (ER Model) is a conceptual model for designing a databases. This model represents the logical structure of a database, including entities, their attributes and relationships between them. Entity: An objects that is stored as data such as Student, Course or Company.Attri
    10 min read
    Recursive Relationships in ER diagrams
    A relationship between two entities of the same entity set is called a recursive relationship or repeated relationship. Here the same entity set participates more than once in a relationship type with a different role for each instance. Recursive relationships are often used to represent hierarchies
    3 min read
    Minimization of ER Diagrams
    Pre-Requisite: ER DiagramEntity-Relationship (ER) Diagram is a diagrammatic representation of data in databases, it shows how data is related to one another. In this article, we require previous knowledge of ER diagrams and how to draw ER diagrams.Minimization of ER Diagram simply means reducing the
    4 min read
    Enhanced ER Model
    As data complexity grows, the traditional ER model becomes less effective for database modeling. Enhanced ER diagrams extend the basic ER model to better represent complex applications. They support advanced concepts like subclasses, generalization, specialization, aggregation, and categories.ER mod
    7 min read
    Mapping from ER Model to Relational Model
    Converting an Entity-Relationship (ER) diagram to a Relational Model is a crucial step in database design. The ER model represents the conceptual structure of a database, while the Relational Model is a physical representation that can be directly implemented using a Relational Database Management S
    7 min read
    Relational Model in DBMS
    The Relational Model organizes data using tables (relations) consisting of rows and columns. Each column represents a specific attribute with a unique name, while each row holds data about a real-world entity or relationship. As a record-based model, it stores data in fixed-format records with defin
    10 min read
    Introduction of Relational Algebra in DBMS
    Relational Algebra is a formal language used to query and manipulate relational databases, consisting of a set of operations like selection, projection, union, and join. It provides a mathematical framework for querying databases, ensuring efficient data retrieval and manipulation. Relational algebr
    9 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences