Condition on ideal of ring of integers being prime Let $K=\mathbb{Q}(\sqrt{d})$ for $d$ square free integer and let $p$ be a rational prime such that $p$ does not divide $2d$. Prove that $p\mathcal{O}_K$ is a prime ideal $\iff x^2\equiv_p d$ has no solution.
I'm completely stuck with this. I know that for $\mathbb{Q}(\sqrt{d})$, the ring of integers $$\mathcal{O}_K= \begin{cases}\mathbb{Z}[\sqrt{d}]\qquad \quad d\equiv_4 2,3\\ \mathbb{Z}\left[\frac{1+\sqrt{d}}{2}\right]\quad d\equiv_4 1\end{cases}$$ and also that the ring of integers of a number field is Dedekind.
I also know that for an ideal $\mathfrak{a}$ of a ring $A$ to be prime, $xy \in \mathfrak{a} \implies x \in \mathfrak{a}$ or $y \in \mathfrak{a}$ for all $x,y \in A$.
I just don't see how this corresponds to congruences of $x$. If $p$ does not divide $2d$ and $p$ generates the ideal $p\mathcal{O}_K$, then does this imply the result? I feel like the $2$ in $2d$ is relevant to the $2$ in $x^2$ but I just can't piece this problem together.
For instance, I start with the forward direction: If $z \in \mathcal{O}_K$, then $pz \in p\mathcal{O}_K$. But if $p\mathcal{O}_K$ is prime, that means $p \in p\mathcal{O}_K$ or $z \in p\mathcal{O}_K$. I have no idea where to go from here!



EDIT: I have found a result that states $\left(\frac{d}{p}\right)=-1$ (i.e. $x^2 \neq d \mod p$) $\iff$ odd $p$ remains prime, since: 
$$\frac{\mathbb{Z}\left[\frac{1+\sqrt{d}}{2}\right]}{p\mathbb{Z}\left[\frac{1+\sqrt{d}}{2}\right]} \cong \frac{\mathbb{Z}\left[\sqrt{d}\right]}{p\mathbb{Z}\left[\sqrt{d}\right]} \cong \frac{\mathbb{Z}[x]}{(p,x^2-d)} \cong \frac{\mathbb{F}_p[x]}{(x^2-d)}$$ 
Thus I think this reduces the problem to proving $p\mathcal{O}_K$ is a prime ideal $\iff$ $p$ prime in $K=(\mathbb{Q}\sqrt{d})$. 
Is this a fair assumption?
If so, I have the proof for the backward direction as: $ab \in p\mathcal{O}_K \implies p|ab$ since $p$ is prime $\implies p|a$ or $p|b \implies a \in p\mathcal{O}_K$ or $b \in p\mathcal{O}_K$ and the forward direction as analogous.
Is this a correct approach?
 A: Use the following useful result (cf. Lang, Algebraic Number Theory):
Theorem: Let $K$ be a number field and $B = \mathcal{O}_K$, and assume that $B = \mathbb{Z}[\alpha]$ for some $\alpha \in B$. Let $f(X)$ be the irreducible polynomial of $\alpha$ over $\mathbb{Q}$ (it has coefficients in $\mathbb{Z}$). Let $(p)$ be an non-zero ideal of $\mathbb{Z}$ and $\overline{f}$ be the reduction of $f(X)$ modulo $(p)$. Within the field $\mathbb{F}_p$ factorize, 
$$ f(X) = p_1(X)^{e_1} \cdot ... \cdot p_r(X)^{e_r} $$
Where each is irreducible and distinct factors. Then in the Dedekind domain $B$ we can factorize 
$$pB = \mathfrak{b}^{e_1} \cdot ... \cdot \mathfrak{b}^{e_r} $$
Now apply this result to the polynomial $X^2-d$ and reduce it mod $p$. This explains why we care about whether $d$ is a quadratic residue or non-residue mod $p$. 
A: The result given by Nicolas Bourbaki is a rather sophisticated tool for the question you ask (but could we expect any less from Bourbaki?).  A simpler (but less general) answer can be given if you know the following:
1) In $\mathbb{Q}(\sqrt{d})$, the principal ideal $(p)$ generated by a rational prime number $p$ that does not divide $2d$ is either itself a prime ideal in $\mathcal{O}_K$ or else factors as the product of two distinct prime ideals in $\mathcal{O}_K$. (In the first case, $p$ is inert in $K$, and in the second, $p$ splits in $K$.)
2) If $p$ splits in $K$, then each of the prime ideals dividing $(p)$ in $\mathcal{O}_K$ has the form $(p,\alpha)$, for some $\alpha \in \mathcal{O}_K$.  Furthermore, if $N_{K/\mathbb{Q}}$ denotes the field norm, then $N_{K/\mathbb{Q}}(\alpha)$ is an element of $\mathbb{Z}$ divisible by $p$ but no higher power of $p$.
Assuming these, assume first that you are in the case where $p$ splits in $K$ (that is, $(p)$ is not a prime ideal in $\mathcal{O}_K$).  Then choosing an element $\alpha = a + b \sqrt{d}$ as in 2), we have
$N_{K/\mathbb{Q}} \alpha = a^2 - b^2 d \equiv 0 \pmod{p}$.
Furthermore, $b$ is relatively prime to $p$, since if it wasn't, then $a$ would not be either, and then $N_{K/\mathbb{Q}} \alpha$ would be divisible by $p^2$. 
Let then $c$ be an inverse for $b$ modulo $p$. From $a^2 \equiv b^2 d \pmod{p}$, we find that $(ac)^2 \equiv d \pmod{p}$, so the congruence $x^2 \equiv d \pmod{p}$ has a solution.
Conversely, if the congruence has the solution $x=a$, then $a+\sqrt{d}$ is an element of $\mathcal{O}_K$ with norm divisible by $p$.  Factoring the ideal $(a+\sqrt{d})$ in $\mathcal{O}_{K}$, we find that it shares a prime ideal factor with the ideal $(p)$.  If $(p)$ itself were prime, then $a+\sqrt{d}$ would be an element of $(p)$.  But this cannot be true, since an element of $(p)$ must have the form $k+l\sqrt{d}$ with both $k$ and $l$ divisible by $p$.  Thus, if the congruence $x^2 \equiv d \pmod{p}$ is solvable, then $(p)$ cannot be prime.
A: Here is another method that perhaps you will like more? (It is a method I learned from P. Samuel.) 
We start with $K=\mathbb{Q}(\sqrt{d})$. We use the fact that $\mathcal{O}_K = \mathbb{Z} + \mathbb{Z}\sqrt{d}$ (notation used here: $\mathcal{O}_K$ is a free module over $\mathbb{Z}$ with basis $1$ and $\sqrt{d}$) if $d\equiv 2,3 ~ (4)$, and $\mathcal{O}_K = \mathbb{Z} + \mathbb{Z} \tfrac{1+\sqrt{d}}{2}$ if $d\equiv 1 ~ (4)$. 
Let $p$ be an odd prime and consider $p\mathcal{O}_K$, the ideal generated by $p$ in the ring of integers. Let us examine the quotient ring $\mathcal{O}_K/p\mathcal{O}_K$, depending on the two cases of $d$. 
In the first case, (use the map $X\mapsto \sqrt{d}$ , to get the ring isomorphism) 
$$ \mathcal{O}_K \simeq \mathbb{Z}[X]/(X^2-d) $$
Therefore, as you said, 
$$ \mathcal{O}_K/p\mathcal{O}_K \simeq \mathbb{Z}[X]/(p,X^2-d) \simeq \mathbb{F}_p[X]/(X^2-\overline{d}) $$
On the other hand, if $p\mathcal{O}_K = \mathfrak{b}_1^{e_1} .\mathfrak{b}_2^{e_2}$ is the factorization of this ideal in the ring of integers, then by the Chinese remainder theorem, 
$$ \mathcal{O}_K/p\mathcal{O}_K \simeq \mathcal{O}_K/\mathfrak{b}_1^{e_1} \times \mathcal{O}_K/\mathfrak{b}_2^{e_2} \implies \mathbb{F}_p[X]/(X^2-\overline{d}) \simeq \mathcal{O}_K/\mathfrak{b}_1^{e_1} \times \mathcal{O}_K/\mathfrak{b}_2^{e_2}$$
(The only possibilities is that: (i) either $e_1=e_2=1$, (ii) either there is no $e_2$, only $e_1=2$, (iii) either there is no $e_2$, only $e_1$, with $e_1=1$).
If $\overline{d} = 0 \in \mathbb{F}_p$ then $\mathbb{F}_p[X]/(X^2-\overline{d}) = \mathbb{F}_p[X]/(X^2)$, in particular this ring has nilpotent elements. Comparing it with the isomorphic ring, this can only happen in case (ii). But then that is saying that $p$ ramifies. 
If $\overline{d} \not \in \mathbb{F}_p^{\times 2}$ then $\mathbb{F}_p[X]/(X^2-\overline{d})$ is a field. Therefore, the only such possibility is that of case (iii). (Because a product of two fields is never a field). But then that is saying that $p$ is inert. 
If $\overline{d}  \in \mathbb{F}_p^{\times 2}$ then $(X^2-\overline{d}) = (X-\overline{a})(X-\overline{b})$, hence $\mathbb{F}_p[X]/(X^2-\overline{d})$ is isomorphic to $ \mathbb{F}_p[X]/(X-\overline{a}) \times \mathbb{F}_p[X]/(X-\overline{b})$, which is a product of two fields (without any nilpotent elements). The only such possible case is therefore (i), as $\mathfrak{b}_1$ and $\mathfrak{b}_2$ are maximal primes (remember, we are in a Dedekind ring). But then that is saying that $p$ splits. 
I think the case $d\equiv 1 ~ (4)$ is treated similarly. 
