Select and Project (σ, π)

Context: FIT2094_MOC · the two single-relation Relational Algebra operators · SELECT filters rows, PROJECT keeps columns · combine for SQL-style queries

Quick Revision

  • 🎯 Objective: σ filters rows, π keeps columns ➔ horizontal vs vertical cut.
  • 📦 Core Components: (rows) ➔ (columns, dedup).
  • ⚡ Key Constraint: PROJECT removes duplicate tuples; SQL SELECT list is π, WHERE is σ.

📝 Core

1. The Two Operators

  • SELECT ➔ filters tuples by a condition (horizontal cut).
  • PROJECT ➔ keeps chosen attributes, removing duplicate tuples (vertical cut).

2. Combining σ then π

  • Filter then narrow.
  • SQL parallelWHERE = σ, SELECT column-list = π.

3. Mnemonic

  • σ (S)elect ➔ cuts horizontally (rows).
  • π (P)roject ➔ cuts vertically (columns).
  • Name clash ➔ SQL SELECT ≠ relational-algebra SELECT.

Key identities:

⚖️ Core Decision Matrix

OperatorCutsDuplicates
(select)rows (horizontal)not removed
(project)columns (vertical)removed
SQL WHERE= σ
SQL column list= πdistinct if projected

When It Flips: both are unary (single relation); combining relations needs joins/set operations. Select-then-project (filter rows, then narrow columns) is the natural, cheaper order the optimiser exploits. A σ predicate expresses FIT1058 logical conditions.

📊 Exam Execution Trace

Applied Exercise

Problem: Write the algebra for “the project manager of project 25-5A” and the SQL. Derivation Proof / Hand-Calculation Walkthrough:

Final Extracted Output: result George F. Dorts; WHERE = σ, column list = π.

⚠️ Common Mistakes

  • 💡 PROJECT deduplicates, SELECT does not ➔ π’s result is a relation (no duplicates, Relation Properties); σ only drops non-matching rows.

🧠 Active Recall