Lemma 26.6.7. The category of affine schemes has finite products, and fibre products. In other words, it has finite limits. Moreover, the products and fibre products in the category of affine schemes are the same as in the category of locally ringed spaces. In a formula, we have (in the category of locally ringed spaces)

$\mathop{\mathrm{Spec}}(R) \times \mathop{\mathrm{Spec}}(S) = \mathop{\mathrm{Spec}}(R \otimes _{\mathbf{Z}} S)$

and given ring maps $R \to A$, $R \to B$ we have

$\mathop{\mathrm{Spec}}(A) \times _{\mathop{\mathrm{Spec}}(R)} \mathop{\mathrm{Spec}}(B) = \mathop{\mathrm{Spec}}(A \otimes _ R B).$

Proof. This is just an application of Lemma 26.6.4. First of all, by that lemma, the affine scheme $\mathop{\mathrm{Spec}}(\mathbf{Z})$ is the final object in the category of locally ringed spaces. Thus the first displayed formula follows from the second. To prove the second note that for any locally ringed space $X$ we have

\begin{eqnarray*} \mathop{\mathrm{Mor}}\nolimits (X, \mathop{\mathrm{Spec}}(A \otimes _ R B)) & = & \mathop{\mathrm{Hom}}\nolimits (A \otimes _ R B, \mathcal{O}_ X(X)) \\ & = & \mathop{\mathrm{Hom}}\nolimits (A, \mathcal{O}_ X(X)) \times _{\mathop{\mathrm{Hom}}\nolimits (R, \mathcal{O}_ X(X))} \mathop{\mathrm{Hom}}\nolimits (B, \mathcal{O}_ X(X)) \\ & = & \mathop{\mathrm{Mor}}\nolimits (X, \mathop{\mathrm{Spec}}(A)) \times _{\mathop{\mathrm{Mor}}\nolimits (X, \mathop{\mathrm{Spec}}(R))} \mathop{\mathrm{Mor}}\nolimits (X, \mathop{\mathrm{Spec}}(B)) \end{eqnarray*}

which proves the formula. See Categories, Section 4.6 for the relevant definitions. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).