5. In $\triangle A B C$, $\angle C=90^{\circ}$. If $\sin A$ and $\sin B$ are the two roots of the quadratic equation $x^{2}+p x+q=0$, then which of the following relationships is correct? ( ).
(A) $p= \pm \sqrt{1+2 q}$ and $q>-\frac{1}{2}$
(B) $p=\sqrt{1+2 q}$ and $q>-\frac{1}{2}$
(C) $p=-\sqrt{1+2 q}$ and $q>-\frac{1}{2}$
(D) $p=-\sqrt{1+2 q}$ and $0<q \leqslant \frac{1}{2}$
5. (D).

By Vieta's formulas, we have
$$
\left\{\begin{array}{l}
\sin A+\sin B=-p>0, \\
\sin A \sin B=q>0 .
\end{array}\right.
$$

That is, 
$$
\left\{\begin{array}{l}
\sin A+\cos A=-p>0, \\
\sin A \cdot \cos A=q>0 .
\end{array}\right.
$$
Thus, 
$$
\left\{\begin{array}{l}
p^{2}-2 q=1, \\
p^{2}-4 q \geqslant 0, \\
p<0 .
\end{array}\right.
$$
Therefore, 
$$
0<q=\sin A \cdot \cos A=\frac{1}{2} \sin 2 A \leqslant \frac{1}{2},
$$
$$
p=-\sqrt{1+2 q} .
$$