Unit 2 · Lesson 412 minAcademic review pending

Algebra says how to get there. Calculus says what you want.

Relational calculus describes the result you want by a logical condition, without specifying the step-by-step operations — the same how-versus-what distinction as C loops versus describing a search's outcome directly.

Choose explanation

After this lesson

You should be able to

  • Explain the core difference between relational algebra (procedural) and relational calculus (declarative).
  • Distinguish tuple relational calculus from domain relational calculus.
01

Procedural versus declarative, with a search you already know

Relational algebra is procedural: you write select, then join, then project, specifying the exact sequence of operations that produces the answer — much like writing a binary search function step by step in CS205ES. Relational calculus is declarative: you write a single logical condition describing the properties the answer must have, and leave the actual steps to the DBMS entirely.

This is the same difference as telling someone "walk to the shelf, scan left to right, stop at the third book" (procedural) versus "give me the book whose title is Database System Concepts" (declarative) — both can reach the same book, but only one describes how to walk there.

02

Two flavors of calculus, differing in what the variable ranges over

Tuple relational calculus uses a variable that ranges over entire tuples — "find t such that t is a Student tuple and t.branch equals CSE" — the variable stands for a whole row at once, and its individual fields are accessed with dot notation, similar to accessing a struct's fields in C through one struct variable.

Domain relational calculus uses variables that range over individual domain values instead — one variable per column value, not one variable per row — "find name, branch such that a Student tuple exists with these exact name and branch values." Both flavors are provably equal in expressive power to relational algebra; they exist as alternative ways to specify the same query, and different systems and later theory favor one or the other for different reasons.

Try it yourself

In plain English, phrase the query "find the names of students in the CSE branch" once the procedural way (algebra style) and once the declarative way (calculus style).

Need a hint?

The procedural version names an ordered sequence of steps. The declarative version names only the condition the answer must satisfy, with no mention of steps.

Check the worked solution

Procedural: "First select the Student tuples where branch equals CSE, then project just the name column from that result." Declarative: "Find every name such that there exists a Student tuple with that name and branch equal to CSE" — no steps, just the defining condition, leaving the DBMS free to execute it however is fastest.

Quick check

What is the core difference between relational algebra and relational calculus?

Select an answer to check your thinking.

Why this lesson exists

Syllabus mapping

Tuple relational Calculus, Domain relational calculus

Maps to course outcomes CO1, CO2.