= Solution
Assume the two <database queries> have compatible output <database attributes>. Then
$$
\boxed{\text{True: }Q_1-Q_2\text{ is safe.}}
$$
For a finite input <database>, the result of the <relational difference> is a subset of the finite result of $Q_1$, so it is finite and introduces no new values. For the usual <domain independence of a database query>, let $D$ be the input <database> and let $A\subseteq A'$ be two ambient value domains containing its data and the query constants. <Database query safety> gives
$$
Q_i^A(D)=Q_i^{A'}(D)\quad(i=1,2),
$$
and therefore
$$
Q_1^A(D)\setminus Q_2^A(D)=Q_1^{A'}(D)\setminus Q_2^{A'}(D).
$$
Although a <domain relational calculus> expression for the <relational difference> uses negation, its positive membership requirement in $Q_1$ supplies the necessary range restriction. Negation is not by itself a reason for failure of <database query safety>.
Back to article page