Tuple Relational Calculus

Tuple Relational Calculus (TRC) is a non-procedural (declarative) query language based on mathematical predicate calculus. Unlike Relational Algebra which specifies how to compute a result (sequence of operations), TRC specifies what the result should contain (a predicate that tuples must satisfy).

Syntax

{ t | P(t) }

“The set of all tuples t such that predicate P(t) is true.”

Example

Find all employees with salary > 50000:

{ t | t ∈ Employee ∧ t.salary > 50000 }

Equivalent Relational Algebra: σ_{salary > 50000}(Employee)
Equivalent SQL: SELECT * FROM Employee WHERE salary > 50000

Equivalence to Relational Algebra

Codd’s Theorem: Relational Algebra and Tuple Relational Calculus are equivalent in expressive power — every query expressible in one can be expressed in the other. SQL draws from both: its declarative syntax resembles TRC while its execution follows Relational Algebra.

Safe Queries

A TRC expression is safe if it guarantees a finite result. Unsafe example: { t | ¬(t ∈ Employee) } — returns all tuples in the universe that are NOT employees (infinite). Practical query languages restrict to safe expressions.