*I had asked something very similar before on math.se (deleted now) but unfortunately it hadn't received a lot of attention. I decided to re-ask here.*

Let $S$ be a fixed scheme. Is the following true?

Theorem(?):The category of affine schemes over $S$ is contra-equivalent to the category of quasi-coherent $\mathcal{O}_S$-algebras

Here the category of affine scheme over $S$ is one whose objects are arrows $\operatorname{Spec} A \to S$ where $A$ ranges over all possible rings and whose morphisms are morphisms of schemes above $S$. Here's the construction:

Let $\varphi: \mathcal{O}_S \to \mathcal{F}$ be an $\mathcal{O}_S$-algebra.

- Let $X$ be the set of all prime ideal sub-sheafs $\mathcal{P} \subset \mathcal{F}$. That is $\mathcal{P}(U)$ is either a prime or a unit on every open set $U \subset S$.
- Define a topology with open sets of the form $V_{U,s} = \{\mathcal{P} \in X: s \notin \mathcal{P}(U)\}$ for open sets $U \subset S$ and $s \in \mathcal{F}(U)$.
- Define the structure sheaf by localizing $\mathcal{O}_X (V_{U,s})=\mathcal{F}(U)_s$.
- The morphism $X \to S$ that sends a prime sheaf to its pullback by $\varphi$ can be seen to satisfy the requirements.

The inverse functor is the obvious one that sends structure sheafs to their pushforwards.

Recently I found that this equivalence supports a very slick argument that the intersection of affines are affine - which I very much suspect is not true. Here is the (probably false) argument:

Let $\operatorname{Spec} A \hookrightarrow S$ and $\operatorname{Spec} B \hookrightarrow S$ be affine subschemes. Being affine schemes over $S$ they can be considered as $\mathcal{O}_S$-algebras. Their intersection is the pullback which corresponds to their tensor product as $\mathcal{O}_S$-algebras. This gives another $\mathcal{O}_S$-algebra i.e. an affine scheme over $S$. We're done.

**What are the flaws in the argument/theorem?**