Tuple relational calculus
Tuple relational calculus (TRC) is a non-procedural, declarative query language for relational databases that retrieves data by specifying the logical conditions that tuples in the result must satisfy, without detailing the retrieval steps.[1] Introduced by Edgar F. Codd in his 1971 paper as a foundational component of the relational model, TRC draws from first-order predicate logic to enable high-level data manipulation, including retrieval, insertion, deletion, and updates on relations treated as sets of tuples.[2] Formally, a TRC query takes the form{ t | P(t) }, where t is a tuple variable ranging over a relation or the result set, and P(t) is a predicate formula built from atomic conditions (such as membership t ∈ r, comparisons t[A] θ u[B] between attributes of tuples t and u, or constants), combined with logical connectives (conjunction ∧, disjunction ∨, negation ¬) and quantifiers (existential ∃ and universal ∀).[1] This structure ensures "range separability," where variables are bound to specific relations via declarations, preventing ambiguity in multi-relation queries.[2] For safety and finiteness, expressions are restricted so that all values in the result derive from the database domains, avoiding infinite or undefined outputs.[1]
TRC's expressive power matches that of relational algebra for safe queries, as proven by Codd's concept of relational completeness, meaning it can express all operations like selection, projection, join, union, and difference.[3] This equivalence underpins modern query languages like SQL, which incorporates TRC's declarative style while adding procedural elements for practical implementation.[1] Originating from Codd's 1970 relational model to promote data independence and logical simplicity, TRC contrasts with procedural approaches by focusing on what data is needed rather than how to obtain it, facilitating optimization by database systems.[4]
Introduction
Overview
Tuple relational calculus (TRC) is a non-procedural, declarative query language for relational databases, expressed as a formalism using first-order predicate logic with tuple variables to define the desired output relations based on logical predicates.[3] Introduced by E. F. Codd in 1971 (published 1972) as part of the relational model's theoretical underpinnings, TRC allows users to specify queries by describing the properties that tuples must satisfy, without detailing the algorithmic steps for data manipulation or retrieval.[3] This approach draws from applied predicate calculus, where formulas are constructed using quantifiers, logical connectives, and atomic predicates over database relations.[5] The core idea of TRC is to retrieve the set of all tuples that make a given well-formed formula true under assignments from the database, emphasizing what data is needed rather than how to compute it.[5] Queries typically take the form{t | φ(t)}, where t is a free tuple variable and φ(t) is a formula involving bound and free variables ranging over relation schemas.[3] This declarative nature contrasts with procedural languages like relational algebra, which require specifying a sequence of operations (e.g., selection, projection, join) to derive results, whereas TRC focuses purely on logical conditions for equivalence in expressive power as proven by Codd's theorem.[3]
A simple example of a TRC query is one that retrieves all employees earning more than 50,000:
Here,{t | EMPLOYEE(t) ∧ t.SALARY > 50000}{t | EMPLOYEE(t) ∧ t.SALARY > 50000}
EMPLOYEE(t) restricts the tuple variable t to range over the Employee relation, and the condition t.SALARY > 50000 filters for qualifying tuples, yielding a result relation of those employee records.[5]