Domain relational calculus Created 2026-10-31 Updated 2026-11-05
Domain relational calculus describes a database query using first-order logic variables ranging over individual attribute values. A formula specifies which output tuples qualify, instead of prescribing a sequence of physical scans or joins. This differs from tuple relational calculus, whose variables range over whole database tuples.
For example, if records an scientific instrument identifier and a measurement value, thenreturns identifiers with some recorded value above five. The existential quantifier binds , while is the output variable. Each returned identifier occurs in a stored database tuple, so extending the ambient domain by unused values cannot change the result.
The apparently simple query behaves differently: with unrestricted quantification, it can return every unused domain value as well as absent recorded values. Database query safety and domain independence of a database query formalize why a finite input must not silently turn such a query into an unbounded enumeration. A finite candidate relation gives the safer intended query .
Safe tuple relational calculus 2026-11-05
Safe tuple relational calculus restricts tuple relational calculus so that output values come from the finite input relations or explicit constants, with suitable restrictions on quantification. This prevents an apparently simple database query from demanding an infinite result over an unrestricted value universe. Database query safety is a semantic requirement; merely writing a familiar-looking formula does not ensure it.[ref]
Relational Model slides for Database System Concepts by Abraham Silberschatz and others. slides3.82 and3.86, Safety of Expressions
For a finite unary relation , the database query safely returns . In contrast, over all integers requests every other unary database tuple, an infinite collection. Restricting negation to tuples already drawn from another finite relation gives an expressible finite set difference. Under the usual finite relational model, the safe calculus and relational algebra express the same queries.
Tuple relational calculus 2026-11-05
Tuple relational calculus describes query answers by predicates over database tuples rather than a sequence of storage operations. A set-builder expression returns tuples satisfying a formula built from relation membership, attribute comparisons, logical connectives and quantifiers. For example,selects employee tuples whose salary exceeds100. A join can be expressed using existentially quantified tuples from two relations and equality of their shared identifying attribute.
The formula needs a safety restriction. Over an unrestricted infinite value universe, a query such as can demand infinitely many absent tuples. Safe tuple relational calculus restricts results to information grounded in the input and explicit constants. Under the usual finite-relation assumptions, its expressive power agrees with relational algebra. This gives a declarative query language while leaving the database system free to choose an efficient query plan.