Given a commutative ring $R$, I am interested in the ring epimorphisms outgoing from $R$. In the opposite category of affine schemes, those quotient objects become subobjects of Spec $R$ and I study their set operations like union, intersection and complement.
Epimorphisms from $R$ are ordered by factorization, have a maximum element $\text{id}_R:R\to R$, a minimum element $R\to 0$, and any two epics $f:R\to A, g:R\to B$ have a lower bound which is their pushout $A\otimes_R B$. The lower bounds represent the intersections of the corresponding affine schemes. For upper bounds (unions), I am considering the pullback of the pushout of $f$ and $g$, which is $(f,g):R\to U$ with $$U=\{(a,b)\in A\times B \;/\; a\otimes_R 1 = 1\otimes_R b\}$$ When the pushout $A\otimes_R B$ is zero, then $U$ is just the product $A\times B$, and $(f,g):R\to A\times B$ is the upper bound indeed. We can prove $(f,g)$ is an epimorphism by computing tensors to get $(a,b)\otimes_R (1,1)= (1,1)\otimes_R (a,b)$. When the pushout is not zero, then we don't have $(1,0)\in U$ and cannot separate the tensor into a sum of simpler terms. As another possible definition of unions, observe that epimorphisms out of $R$ have arbitrary intersections (infinite tensor products), so we could think of the intersection of all epimorphisms out of $R$ that are greater than both $f$ and $g$. However those epimorphisms form a proper class, not a set, so this union is not well defined, unless we manage to reduce it to a set. If this fails too, is there still another proof of existence of unions?
For the complement of an epic $f:R\to A$, my first tentative was searching for an epic $g:R\to B$ such as $f\lor g =\text{id}_R$ and $f\land g=0$. However, from what we just said, $f\land g=0$ yields $f\lor g = (f,g) : R\to A\times B$. And the product $A\times B$ is never an integral domain, because $(1,0)(0,1)=0$, so when $R$ is integral, they cannot be isomorphic. Therefore Boolean complements fail. We can still search for Heyting complements, i.e. the greatest $g:R\to B$ such as $f\land g=0$. But those probably fail too, because the punctured plane is not an affine scheme. Can we prove the epimorphism $K[X,Y] \to \frac{K[X,Y]}{\langle X,Y\rangle}$ does not have a Heyting complement?
I imagine the answers to those questions give some of the motivations of the upgrade from affine schemes to general schemes.