TITLE: Categorical construction of the category of schemes?
QUESTION [30 upvotes]: The answer to the following question is probably well known or the question itself is well known not to have a reasonable answer. In the latter case could you please let me know what the "right" question may be (rather then stating that the answer is 42;))
Is there a purely categorical procedure that takes the category of commutative rings as input and produces the category of schemes (over $\mathbf{Z}$) as output?
A possible place to start would be to consider a scheme $X$ as a functor from the category $CommRing$ of commutative rings to the category of sets: $A\mapsto Hom_{Sch}(Spec(A),X)$ where $A$ a commutative ring. If we instead of $Spec(A)$'s we consider all schemes, then we simply get the Yoneda embedding. But some questions arise.

Does this give a fully faithful functor from schemes to functors from commutative rings to sets? Or loosely speaking, do $Spec(A)$-valued points ($A$ a commutative ring) suffice to determine a scheme? (My guess is that the answer is yes and this is classical.)
Is there a way to characterize those functors that actually come from schemes? For example one can introduce a Grothendieck topology on $CommRing$ (or its opposite) and require that the functor should be a sheaf in that topology. But in that case, can one describe the topology without referring to the fact that the objects of $CommRing$ are commutative rings? (Here my guess is the first question is probably too complicated but there are some necessary conditions.)
Regardless whether the answer to 2. is positive or negative, is there a way to describe algebraic spaces or stacks as presheaves on $CommRing^{op}$ that satisfy some conditions?

REPLY [3 votes]: It's worth pointing out Zhen Lin Low's thesis

Low, Z. L. (2016). Categories of spaces built from local models (doctoral thesis). doi:10.17863/CAM.384

with abstract

Many of the classes of objects studied in geometry are defined by first choosing a class of nice spaces and then allowing oneself to glue these local models together to construct more general spaces. The most well-known examples are manifolds and schemes. The main purpose of this thesis is to give a unified account of this procedure of constructing a category of spaces built from local models and to study the general properties of such categories of spaces. The theory developed here will be illustrated with reference to examples, including the aforementioned manifolds and schemes. For concreteness, consider the passage from commutative rings to schemes. There are three main steps: first, one identifies a distinguished class of ring homomorphisms corresponding to open immersions of schemes; second, one defines the notion of an open covering in terms of these distinguished homomorphisms; and finally, one embeds the opposite of the category of commutative rings in an ambient category in which one can glue (the formal duals of) commutative rings along (the formal duals of) distinguished homomorphisms. Traditionally, the ambient category is taken to be the category of locally ringed spaces, but following Grothendieck, one could equally well work in the category of sheaves for the large Zariski site—this is the so-called ‘functor of points approach’. A third option, related to the exact completion of a category, is described in this thesis. The main result can be summarised thus: categories of spaces built from local models are extensive categories with a class of distinguished morphisms, subject to various stability axioms, such that certain equivalence relations (defined relative to the class of distinguished morphisms) have pullback-stable quotients; moreover, this construction is functorial and has a universal property.

That last sentence is perhaps stronger than other answers here, which in all likelihood give the construction that Zhen Lin does, albeit in the special case of only schemes.