Let $A$ and $B$ be finitely generated $\mathbf{Z}$-algebra. Suppose that there exists two coprime integers $m$ and $n$ and an isomorphism of $\mathbf{Z}$-algebra
$\phi:A\otimes\_{\mathbf{Z}}\mathbf{Z}[1/n]\simeq B\otimes\_{\mathbf{Z}}\mathbf{Z}[1/m] $. Then we can glue $A$ and $B$ along $\phi$ so that we obtain
a scheme $Y$ over $Spec(\mathbf{Z})$. 


**Q1**: Under what general conditions do we have $Y$ affine ? 


**Q2**: In the case where $Y=Spec(C)$ is affine then how do we construct the $\mathbf{Z}$-algebra $C$ from the triple $(A,B,\phi)$?



When is the gluing of two finite type affine Z-schemes affine?
By Zariski glueing on affine schemes,
$$C=\{(a,b)\in A×B\mid\phi(a\otimes1)=b\otimes1\}.$$
Of course the beautiful thing in this story is the answer to Q1: if $f:Y\to X$ is an affine morphism and $X$ is an affine scheme, then $Y$ is affine. Once you know this, the only possible answer to Q2 is the above.


