I was wondering whether $\mathbb{Q}/\mathbb{Z}$ can be decomposed into a direct sum of its subgroups and I thought of the following decomposition: $$\mathbb{Q}/\mathbb{Z} = \bigoplus_{p \text{ prime}}\left(\mathbb{Z}\left[\frac{1}{p}\right]\Big/\mathbb{Z}\right).$$
The isomorphism is quite obvious as via CRT any fraction $\frac{m}{p_1^{\alpha_1}...p_k^{\alpha_k}}$ can be uniquely written as a sum $\frac{m_1}{p_1^{\alpha_1}} + ... + \frac{m_k}{p_1^{\alpha_k}} \:\mathrm{mod}\,\mathbb{Z}$. Firstly, I want to ask: is this reasoning correct and this is indeed how $\mathbb{Q}/\mathbb{Z}$ is decomposed?
Afterwards, I got a feeling that this somehow seems like something more general and not linked to this particular example. I figured that each summand in the decomposition above is in fact a localization of $\mathbb{Q}/\mathbb{Z}$ at a prime ideal $(p) \subset \mathbb{Z}$. So, if we consider $M = \mathbb{Q}/\mathbb{Z}$ as an $R$-module where $R = \mathbb{Z}$, we get the following decomposition: \begin{align}M = \bigoplus_{\mathfrak{p} \in \mathrm{Spec}R \setminus \{(0)\}} M_\mathfrak{p}.\end{align}
So, my question is quite vague but I am too curious not to ask: $$\textbf{under which conditions can a module be decomposed in the above fashion?}$$
For finitely generated modules over principal ideal domains to me this feels very much Structure Theorem-ish. That is, we know that if $M$ is a f.g. module over a principal domain $R$ it can be decomposed as $$M = R^{\oplus s} \oplus R/(p_1^{\alpha_{11}}) \oplus ... \oplus R/(p_1^{\alpha_{1r_1}}) \oplus ... \oplus R/(p_k^{\alpha_{k1}}) \oplus ... \oplus R/(p_k^{\alpha_{kr_k}}).$$
Then the localization of $M$ at a prime ideal $(p_i)$ is $R_{(p_i)}^{\oplus s} \oplus R_{(p_i)}/(p_i^{\alpha_{i1}})R_{(p_i)} \oplus ... \oplus R_{(p_i)}/(p_i^{\alpha_{ir_i}})R_{(p_i)}$.
So to me it seems that the necessary condition for the decomposition to work is
1. that the module is equal to its torsion submodule;
also it seems that we also have to require that
2. for each prime ideal $\mathfrak{p}$ in $R$ and each nonnegative integer $\alpha$ we have equality $R/\mathfrak{p}^\alpha = R_\mathfrak{p}/\mathfrak{p}^\alpha R_\mathfrak{p}$.
Under which conditions does the second assumption hold? Will this two conditions be sufficient for a desired decomposition to occur, not necessarily if $M$ is f.g. and $R$ is a PID? Under which conditions such decomposition is possible?
I would really appreciate any help or advice. Thank you in advance!
And I apologize if my question is flawed in some way. I tried to express my understanding of the problem as much as possible and I hope I haven't missed anything.