Relational Algebra

Relational algebra is a mathematical foundation for relational databases, defining operations to manipulate and retrieve data.

Explanation:

Relational algebra provides fundamental operations such as:

  1. Selection (ฯƒ) โ€“ Filters rows based on conditions.
  2. Projection (ฯ€) โ€“ Selects specific columns.
  3. Union (โˆช) โ€“ Combines two relations.
  4. Intersection (โˆฉ) โ€“ Returns common tuples.
  5. Difference (-) โ€“ Finds tuples in one relation but not in another.
  6. Cartesian Product (ร—) โ€“ Merges two tables without conditions.
  7. Join (โจ) โ€“ Combines tables based on a condition.

Example in SQL:

  • Selection (ฯƒ condition(R)):
sqlCopyEditSELECT * FROM Employees WHERE department = 'HR';
  • Projection (ฯ€ column1, column2(R)):
sqlCopyEditSELECT name, salary FROM Employees;