= Domain relational calculus
{wiki}
<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 $R(i,v)$ records an <scientific instrument> identifier and a <measurement> value, then
$$
\{i:\exists v\,(R(i,v)\land v>5)\}
$$
returns identifiers with some recorded value above five. The <existential quantifier> binds $v$, while $i$ 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 $\{x:\neg P(x)\}$ 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 $C$ gives the safer intended query $\{x:C(x)\land\neg P(x)\}$.
Back to article page