Why is every ideal in the ring of algebraic integers $\mathcal{O}_K$ of a numberfield $K$ finitely generated? We supposedly proved that by the argument, that since $K$ is an $n$-dimensional $\mathbb{Q}$-vectorspace for a $n\in\mathbb{N}$ it follows that every ideal $I$ is finitley generated with at most $n$ generators.
My problem is, that I don't see how these two different kinds of generating should be related:


*

*An ideal $I \subseteq \mathcal{O}_K$ is generated by a basis $\{w_1, ..., w_m\} \subseteq \mathcal{O}_K$ if $I = w_1 \mathcal{O}_K + ... + w_m \mathcal{O}_K$

*The number field $K$ is generated by a basis $\{\alpha_1, ..., \alpha_n\} \subseteq K$ if $K = \alpha_1 \mathbb{Q} + ... + \alpha_n \mathbb{Q}$.
Furthermore, $\mathcal{O}_K$ seems to have a basis consisting of exactly $n$ elements. Of couse I also don't understand this, but it seems to fall in line with the question above.
 A: It looks like you are confusing generators over $\mathcal O_K$ and generators over $\mathbb Z$.
If you proved that $\mathcal O_K$ has a $\mathbb Z$-basis consisting of exactly (or even at most) $n$ elements, then your claim about $I$ follows in a straightforward fashion: because $I$ is an ideal of $\mathcal O_K$, it is certainly an additive subgroup of $\mathcal O_K$ viewed as an abelian group. The fact about $\mathcal O_K$ tells us that it is a $\mathbb Z$-module (i.e. abelian group) of rank $n$, and so all of its $\mathbb Z$-submodules (subgroups) have rank at most $n$.
Edit based on comments below:
Generators of $I$ over $\mathbb Z$ are also generators over $\mathcal O_K$. To see this, say we have generators $\{w_1,...,w_m\}$ of $I$ over $\mathbb Z$ so that
$$I = w_1 \mathbb Z + ... + w_m \mathbb Z$$
Since $I$ is an ideal, it is closed under multiplication by $\mathcal O_K$ and in fact $I\mathcal O_K = I$. So we can write
$$I = \mathcal O_K I = \mathcal O_K(w_1 \mathbb Z + ... + w_m \mathbb Z) = w_1 \mathbb Z\mathcal O_K + ... + w_m \mathbb Z\mathcal O_K = w_1 \mathcal O_K + ... + w_m\mathcal O_K$$
Basically, when we pass from generators over $\mathbb Z$ to $\mathcal O_K$, we have at worst made our abelian group ($I$) bigger by allowing more coefficients in the linear combination, but because $I$ is also closed under multiplication from $\mathcal O_K$, it doesn't actually get larger.
A: If you grant that $\mathcal{O}_K$ is finitely generated as a $\mathbb{Z}$-module, then since by the classification of finitely generated modules over a PID (e.g $\mathbb{Z}$), we have that as $\mathbb{Z}$-modules we have
$$\mathcal{O}_K \simeq \mathbb{Z}^r$$ 
for some $r$ (there  is no torsion part since $\mathcal{O}_K \subseteq K$ is in a char $0$ field). 
Tensoring with $\mathbb{Q}$ gives that as $\mathbb{Q}$-vector spaces 
$$\mathcal{O}_K \otimes_{\mathbb{Z}}  \mathbb{Q} \simeq \mathbb{Q}^r$$ 
and since every element of $K$ can be written as $a/b$ with $a \in \mathcal{O}_K$ and $b  \in \mathbb{Z}$, we have that $K \simeq \mathcal{O}_K \otimes_{\mathbb{Z}} \mathbb{Q}$.
So $r=n$
To show that $\mathcal{O}_K$ is finitely generated as a $\mathbb{Z}$-module, pick a $\mathbb{Q}$-basis of $K$, say $\alpha_1, \ldots, \alpha_n$ and rescale them so that there are in $\mathcal{O}_K$, and then show that for $d$ the discriminant of the basis, that $d \mathcal{O}_K \subseteq \mathbb{Z} \alpha_1 + \cdots + \mathbb{Z}\alpha_n$, so  $\mathcal{O}_K \subseteq \mathbb{Z} \alpha_1/d + \cdots + \mathbb{Z}\alpha_n/d$ is a submodule of a Noetherian module and hence is finitely generated. This is a few lines in Neukirch p. 12 but I find it very tricky. 
