Gluing schemes

In algebraic geometry, a new scheme (e.g. an algebraic variety) can be obtained by gluing existing schemes through gluing maps.

Statement
Suppose there is a (possibly infinite) family of schemes $$\{ X_i \}_{i \in I}$$ and for pairs $$i, j$$, there are open subsets $$U_{ij}$$ and isomorphisms $$\varphi_{ij} : U_{ij} \overset{\sim}\to U_{ji}$$. Now, if the isomorphisms are compatible in the sense: for each $$i, j, k$$, then there exists a scheme X, together with the morphisms $$\psi_i : X_i \to X$$ such that
 * 1) $$\varphi_{ij} = \varphi_{ji}^{-1}$$,
 * 2) $$\varphi_{ij}(U_{ij} \cap U_{ik}) = U_{ji} \cap U_{jk}$$,
 * 3) $$\varphi_{jk} \circ \varphi_{ij} = \varphi_{ik}$$ on $$U_{ij} \cap U_{ik}$$,
 * 1) $$\psi_i$$ is an isomorphism onto an open subset of X,
 * 2) $$X = \cup_i \psi_i(X_i),$$
 * 3) $$\psi_i(U_{ij}) = \psi_i(X_i) \cap \psi_j(X_j),$$
 * 4) $$\psi_i = \psi_j \circ \varphi_{ij}$$ on $$U_{ij}$$.

Projective line
Let $$X = \operatorname{Spec}(k[t]) \simeq \mathbb{A}^1, Y = \operatorname{Spec}(k[u]) \simeq \mathbb{A}^1$$ be two copies of the affine line over a field k. Let $$X_t = \{ t \ne 0 \} = \operatorname{Spec}(k[t, t^{-1}])$$ be the complement of the origin and $$Y_u = \{ u \ne 0 \}$$ defined similarly. Let Z denote the scheme obtained by gluing $$X, Y$$ along the isomorphism $$X_t \simeq Y_u$$ given by $$t^{-1} \leftrightarrow u$$; we identify $$X, Y$$ with the open subsets of Z. Now, the affine rings $$\Gamma(X, \mathcal{O}_Z), \Gamma(Y, \mathcal{O}_Z)$$ are both polynomial rings in one variable in such a way
 * $$\Gamma(X, \mathcal{O}_Z) = k[s]$$ and $$\Gamma(Y, \mathcal{O}_Z) = k[s^{-1}]$$

where the two rings are viewed as subrings of the function field $$k(Z) = k(s)$$. But this means that $$Z = \mathbb{P}^1$$; because, by definition, $$\mathbb{P}^1$$ is covered by the two open affine charts whose affine rings are of the above form.

Affine line with doubled origin
Let $$X, Y, X_t, Y_u$$ be as in the above example. But this time let $$Z$$ denote the scheme obtained by gluing $$X, Y$$ along the isomorphism $$X_t \simeq Y_u$$ given by $$t \leftrightarrow u$$. So, geometrically, $$Z$$ is obtained by identifying two parallel lines except the origin; i.e., it is an affine line with the doubled origin. (It can be shown that Z is not a separated scheme.) In contrast, if two lines are glued so that origin on the one line corresponds to the (illusionary) point at infinity for the other line; i.e, use the isomrophism $$t^{-1} \leftrightarrow u$$, then the resulting scheme is, at least visually, the projective line $$\mathbb{P}^1$$.

Fiber products and pushouts of schemes
The category of schemes admits finite pullbacks and in some cases finite pushouts; they both are constructed by gluing affine schemes. For affine schemes, fiber products and pushouts correspond to tensor products and fiber squares of algebras.