Relational Algebra Joins

Context: FIT2094_MOC · combine two relations on a predicate · theta, equi, and natural joins · built from Cartesian Product + project

Quick Revision

  • 🎯 Objective: combines tuples from two relations satisfying a predicate ➔ product + select (+ project).
  • 📦 Core Components: theta (any comparison) ➔ equi () ➔ natural (shared attrs, dedup column).
  • ⚡ Key Constraint: joins are derived from Cartesian Product, not primitive.

📝 Core

1. The Join

  • Definition combines tuples from two relations satisfying a predicate.
  • Three kinds ➔ theta / equi / natural.

2. The Three Kinds

  • Theta, , .
  • Equi ➔ theta with being ; shared attribute appears twice.
  • Natural ➔ equi join on common attribute(s) with duplicate column removed; no explicit predicate needed.

3. Natural Join = 3 Steps

  • Product.
  • Select (this is the equi join).
  • Project ➔ drop the duplicate column → natural join.

Key identities:

⚖️ Core Decision Matrix

JoinPredicateShared column
thetaany kept (both)
equiduplicated
natural on commonremoved
vs set opsdifferent schemas(set ops need identical)

When It Flips: every join is a Cartesian Product filtered by the predicate (natural join also projects) — joins are derived, not primitive. Equi joins on PK = FK are the everyday case (Foreign Key and Referential Integrity); pure algebra drops unmatched tuples (inner join, no NULLs).

📊 Exam Execution Trace

Applied Exercise

Problem: Show the natural join of STUDENT and MARK on ID as three steps. Derivation Proof / Hand-Calculation Walkthrough:

Final Extracted Output: 3 tuples; Alice (ID 1) appears twice, Bob (ID 2) once.

⚠️ Common Mistakes

  • 💡 Natural join needs a shared attribute ➔ if relations share matching attribute(s) the predicate is implicit; without one, use an equi join and state the predicate.

🧠 Active Recall