Tuple relational calculus
Calculus states which tuples qualify; algebra specifies operations that produce them. Translate quantified variables into relation aliases and link them through equality predicates before inspecting answer choices.
3.1 Predicates, bindings and translation
Past papers · CS 2014–2026 (23 papers): 2 questions, 4 marks · DA 2024–2026 (3 papers): 1 question, 2 marks
A tuple-calculus query has the form . The output tuple variable is free; variables introduced by or are bound within their scopes. Membership ranges over relation . An attribute reference is or .
For Maker(mid, city) and Part(pid, mid), the pids made in Pune are:
The algebra is projection of pid from the matching join after selecting Pune makers. Omitting the equality on mid makes the query test whether any Pune maker exists, rather than whether the part's own maker is in Pune.
3.2 Safe and domain-independent queries
Past papers · CS 2014–2026 (23 papers): 1 question, 2 marks
A safe calculus expression restricts output values to values occurring in the referenced relations or constants in the query. Merely being finite on one chosen instance is insufficient. A domain-independent query does not change if unused values are added to the ambient domains. Safe relational calculus has the expressive power of basic relational algebra.
is unsafe over an unbounded domain. A condition such as excludes a value but does not positively bind to a finite input set. Binding one output attribute does not bind the others. A safe universal query begins with a finite candidate relation, then removes candidates with counterexamples.
Last-minute recall
- Free variables determine the output; quantified variables are local.
- A join needs a predicate connecting the relevant aliases.
- “For all” means “there is no counterexample”.
- Restrict output candidates even when a universal test is present.
- Inequality alone does not bind an attribute to the active domain.