Finite union of affine schemes Let $X$ be a scheme and suppose that $X$ admits a finite open covering $(U_i)_{i\in I }$ of affine schemes, such that $X_i\cap X_j$ is an affine scheme, for all $i,j\in I$. In this case is it true that $X$ is an affine scheme? 
 A: This is not true. Any projective space $\Bbb P_k^n$ for a field $k$ gives a counterexample.
A: Here's another (horrible!) example: the union
$$ \mathbb{A}^2_R \setminus \{ (0,0) \} = \operatorname{Spec}(R[x, y, x^{-1}]) \cup \operatorname{Spec}(R[x, y, y^{-1}]) $$
is not an affine scheme (despite being a subscheme of an affine scheme!). The intersection of the two patches is
$$\operatorname{Spec}(R[x, y, x^{-1}]) \cap \operatorname{Spec}(R[x, y, y^{-1}])
= \operatorname{Spec}(R[x, y, x^{-1}, y^{-1}]) $$
A: A mild generalization of Hurkyl's example is as follows. Consider any scheme $X$ which is:


*

*quasi-compact

*separated

*quasi affine but not affine
A class of such schemes can be constructed as follows: For $k$ a field and $n,m>1$ take $f_1,\ldots,f_n\in k[x_1,\ldots, x_m]$ for which $ht(f_1,\ldots,f_n)>1$ and define the scheme $(X,\mathcal{O}_{\mathbb{A}^n}\mid_X)=D(f_1)\cup \ldots \cup D(f_n)$.
Then $X$, being finite union of quasi-compact spaces, is quasi-compact. Being an open subscheme of an affine scheme, $X$ is separated and quasi-affine. We only need to check that $X$ is not affine. 
The regular functions on $X$ are precisely those $\frac{F}{G}\in k(x_1,\ldots,x_n)$ such that $V(G)\subset V(f_1,\ldots,f_n)$. But this cannot happen due to dimension reasons. Consequently, $\Gamma(X,\mathcal{O}_X)=k[x_1,\ldots,x_m]$. Thus, $X$ cannot be affine.  
