In algebraic number theory, one constructs for each number field $K$ a subring $\mathcal{O}\_K$, the integral closure of $\mathbb{Z}$ inside $K$, which carries many of the properties which make $\mathbb{Z}$ a nice ring- it is a Dedekind Domain.


Hence, for a number field $K$, we have assigned an integral $\mathcal{O}\_K$-algebra to each finite étale $K$-algebra. I am looking to see if there is some categorical formality behind this construction. More precisely, given a number ring $K$, what formal operation are we doing to the category of finite étale-$K$-algebras so as to pass to the category of $\mathcal{O}\_K$-algebras?


By the way, one way of describing this assignment of $\mathcal{O}\_L$, with $\mathcal{O}\_K \subset K$ given, is to stipulate that (i) $\phi (\mathcal{O}\_L ) = \mathcal{O}\_L$ for each $K$-algebra map $\phi : L \rightarrow L$, (ii) $\mathcal{O}\_L \cap K = \mathcal{O}\_K$, and (iii) $\mathcal{O}\_L$ is maximal as such. This is enough to show that $\mathcal{O}\_L$ is the ring of integers of $L$ when $L$ is Galois over $K$. A modification gives a similar result for non Galois extensions. This may give some kind of hint.



What is the formality behind passing from Number Fields to Number Rings
Let me expand on my comment, with thanks to Daniel Loughran for corrections.


Of course,



> 
> If $K$ is a number field, then $\mathcal{O}\_K$ is the unique ring with the following universal property:
> 
> 
> 1. $\mathcal O\_K$ is an integral domain.
> 2. The fraction field of $\mathcal O\_K$ is $K$
> 3. $\mathcal O\_K$ is integrally closed in $K$
> 4. Any other integral domain $R$ with field of fractions $K$ in which $R$ is integrally closed, the canonical inclusion $\mathcal O\_K \to K$ factors uniquely through the canonical inclusion $R \to K$.
> 
> 
> 


Seeking a geometric interpretation of this statement, we need a geometric interpretation of each of the above properties.


1. A commutative ring $R$ is an integral domain if and only if $Spec(R)$ is an irreducible scheme.
2. Any irreducible scheme $X$ has a field of fractions $k(X)$, and if $X,Y$ are irreducible schemes, then a field homomorphism $k(X) \to k(Y)$ is known as a [birational morphism](https://en.wikipedia.org/wiki/Birational_geometry). These are closed under composition and so form a category; isomorphism in this category is known as *birational equivalence*. This is a loosening of the notion of isomorphism of schemes; schemes which are birationally equivalent are "sort of the same, but not exactly". Given a field $K$, an irreducible scheme $X$ with $k(X) = K$ is known as a *model* of $K$. So $X$ is a model of $K$ if and only if $K$ is the stalk of the structure sheaf of $X$ at the generic point.
3. A [normal scheme](https://en.wikipedia.org/wiki/Normal_scheme) is "scheme language for being integrally closed". That is, a scheme is defined to be normal if and only if all of its local rings are integrally closed (in their fields of fractions). For affine schemes, this definition "globalizes": if $R$ is an integral domain, then $Spec(R)$ is normal if and only if $R$ is integrally closed (in its field of fractions).
4. Thus, $Spec(\mathcal O\_K)$ is a normal model of $K$ with the following universal property: for any other normal model $X$ of $K$, the canonical morphism $Spec(K) \to Spec(\mathcal O\_K)$ factors uniquely through the canonical morphism $Spec(K) \to X$.


Now, what is the relationship of normality to smoothness? In algebraic geometry, there are basically two notions of "smoothness". One is the relative notion of a [smooth morphism](https://en.wikipedia.org/wiki/Smooth_morphism). The other is the absolute notion of a [regular scheme](https://en.wikipedia.org/wiki/Regular_scheme). The connection is that if $X$ is a scheme defined over a [perfect field](https://en.wikipedia.org/wiki/Perfect_field) $k$, then the map $X \to Spec(k)$ is smooth if and only if $X$ is a regular scheme. But we are working over $Spec(\mathbb Z)$ and $\mathbb Z$ is not a field, so this is not true in our case.


Anyway, as explained on the wikipedia page for [normal scheme](https://en.wikipedia.org/wiki/Normal_scheme), Zariski showed that a scheme is normal if and only if it is regular outside a subset of codimension at least two. So normality is a "weak smoothness condition". But since $Spec(\mathcal O\_K)$ only has dimension one, the only codimension two set is the empty set. Thus in this case, normality coincides with regularity, and in the above characterization, "regular" can be replaced by "normal".


