Relational Algebra Simulation

Understanding Database Operations with Interactive Examples

What is Relational Algebra?

Relational algebra is a procedural query language that provides a theoretical foundation for relational databases. It consists of operations that take one or two relations as input and produce a new relation as output.

রিলেশনাল অ্যালজেবরা হল একটি প্রসিডিউরাল কুয়েরি ভাষা যা রিলেশনাল ডেটাবেসের জন্য তাত্ত্বিক ভিত্তি প্রদান করে। এতে এমন অপারেশন রয়েছে যা এক বা দুটি রিলেশনকে ইনপুট হিসেবে নেয় এবং একটি নতুন রিলেশন আউটপুট হিসেবে তৈরি করে।

Key Concepts:
  • Relations (tables) are the fundamental data structures
  • Operations are closed - they always return a relation
  • Provides theoretical basis for SQL
  • রিলেশন (টেবিল) হল মৌলিক ডেটা স্ট্রাকচার
  • অপারেশনগুলি ক্লোজড - তারা সর্বদা একটি রিলেশন রিটার্ন করে
  • SQL-এর জন্য তাত্ত্বিক ভিত্তি প্রদান করে

Fundamental Operations

These are the basic operations in relational algebra:

σ Selection

Selects rows that satisfy a given condition

প্রদত্ত শর্ত পূরণ করে এমন সারিগুলি নির্বাচন করে

π Projection

Selects specific columns from a relation

একটি রিলেশন থেকে নির্দিষ্ট কলাম নির্বাচন করে

× Cartesian Product

Combines each row of one relation with each row of another

একটি রিলেশনের প্রতিটি সারিকে অন্য রিলেশনের প্রতিটি সারির সাথে সংযুক্ত করে

Union

Combines rows from two relations, removing duplicates

দুটি রিলেশন থেকে সারি সংযুক্ত করে, ডুপ্লিকেট সরিয়ে

Set Difference

Finds rows in one relation but not in another

একটি রিলেশনে আছে কিন্তু অন্য রিলেশনে নেই এমন সারি খুঁজে বের করে

Join

Combines related tuples from two relations

দুটি রিলেশন থেকে সম্পর্কিত টিপলগুলি সংযুক্ত করে

Sample Database Tables

We'll use these sample tables to demonstrate relational algebra operations:

Employees
ID Name Department Salary
101 Alice Sales 50000
102 Bob IT 60000
103 Charlie Sales 55000
104 Diana HR 45000
Departments
DeptID DeptName Location
D1 Sales Floor 1
D2 IT Floor 2
D3 HR Floor 3

Operation Demonstrations

Click the buttons below to see different relational algebra operations in action:

// Relational algebra expression will appear here
Operation Result
Result will appear here
Select an operation to see the result

Select an operation from the buttons above to see how it works with example data.

Relational Algebra in SQL

Relational algebra operations have direct equivalents in SQL:

Selection (σ) → WHERE Clause

Relational Algebra: σDepartment='Sales'(Employees)

SQL: SELECT * FROM Employees WHERE Department = 'Sales'

রিলেশনাল অ্যালজেবরা: σDepartment='Sales'(Employees)

এসকিউএল: SELECT * FROM Employees WHERE Department = 'Sales'

Projection (π) → SELECT Clause

Relational Algebra: πName, Salary(Employees)

SQL: SELECT Name, Salary FROM Employees

রিলেশনাল অ্যালজেবরা: πName, Salary(Employees)

এসকিউএল: SELECT Name, Salary FROM Employees

Join (⋈) → JOIN Clause

Relational Algebra: Employees ⋈Employees.Department = Departments.DeptName Departments

SQL: SELECT * FROM Employees JOIN Departments ON Employees.Department = Departments.DeptName

রিলেশনাল অ্যালজেবরা: Employees ⋈Employees.Department = Departments.DeptName Departments

এসকিউএল: SELECT * FROM Employees JOIN Departments ON Employees.Department = Departments.DeptName