Relational Database Systems Concepts, Design, SQL, PostgreSQL, MySQL, and Applications

Appendices

Appendix E. Relational Algebra Notation

The notation of Chapter 3, consolidated: operators, symbols, formal reading, an equivalent SQL form, and a canonical university example for each.

Notation table

OperationSymbolReads asSQL equivalent
Selectionσ[c](R)rows of R where c holdsWHERE
Projectionπ[A,B](R)columns A, B of R, deduplicatedSELECT DISTINCT A, B
Cartesian productR × Severy tuple of R paired with every tuple of SCROSS JOIN
Theta joinR ⋈[c] Sσ[c](R × S)JOIN ... ON c
Natural joinR ⋈ Sjoin on all shared attribute names, mergedNATURAL JOIN
Inner/outer joinsR ⟕ S, R ⟖ S, R ⟗ Skeep unmatched left / right / both with NULL paddingLEFT/RIGHT/FULL JOIN
Renameρ[S](R) or ρ[S(A1..An)](R)R under a new name / new attribute namesAS
UnionR ∪ Srows in R or S (duplicates collapse; union-compatible)UNION
IntersectionR ∩ Srows in bothINTERSECT
DifferenceR − Srows in R not in SEXCEPT
DivisionR ÷ SA-values of R paired with every S valuedouble NOT EXISTS

Derived operators: join = select-after-product; intersection = union+difference; division = product/projection/difference.

The five primitives

Selection, projection, Cartesian product, union, and difference generate every relational operation (with rename as a notational convenience). The algebra is closed: every operation consumes relations and produces relations, so expressions compose.

Worked examples (canonical data)

σ gpa > 3.80 (student)
→  Sadia Afrin (3.88), Arif Mahmud (3.90)

π full_name, gpa (σ gpa > 3.80 (student))
→  the same two students, two columns

A = π student_id (σ section_id = 11 (enrollment))   → {21100004, 21100006, 21300004, 21500002}
B = π student_id (σ section_id = 12 (enrollment))    → {21300003, 21500002}

A ∪ B  → five students
A ∩ B  → {21500002}              (Shahriar Islam, in both sections)
A − B  → {21100004, 21100006, 21300004}

σ i1.dept_id = i2.dept_id ∧ i1.instructor_id < i2.instructor_id (ρ i1(instructor) × ρ i2(instructor))
→  (Ahmed Kabir, Farhana Rahman) — the only co-departmental pair

π section_id (σ course_id='CSE221' ∧ semester='Fall' ∧ section_year=2026 (course_section))
= {12};   R ÷ {12} → {21300003, 21500002}   (Arif Mahmud, Shahriar Islam)

Calculus notation (tuple and domain forms)

Tuple calculus:      { t | student(t) ∧ t.gpa > 3.80 }
  (and projections)   { t.full_name | student(t) ∧ t.gpa > 3.80 }

Domain calculus:     { ⟨fn, g⟩ | ∃ sid, m, ay, tc
                         ( student(sid, fn, m, ay, tc, g) ∧ g > 3.80 ) }

Universal via negation:  ∀x φ  ≡  ¬∃x ¬φ
  (the shape behind every NOT EXISTS "all/every" query)

Codd's theorem: the safe (range-restricted) calculus and the algebra are equivalent in expressive power — the definition of relational completeness. SQL is relationally complete, with aggregation, ordering, NULLs, and recursion exceeding the pure model.

Translation dictionary (algebra → SQL)

σ[c](R)                 →  FROM R WHERE c
π[A](R)                 →  SELECT DISTINCT A FROM R
R × S                   →  FROM R CROSS JOIN S
R ⋈[c] S                →  FROM R JOIN S ON c
ρ x(R)                  →  FROM R AS x
R ∪ S / R ∩ S / R − S   →  UNION / INTERSECT / EXCEPT
R ÷ S                   →  WHERE NOT EXISTS (... NOT EXISTS (...))