Example of a flat module that is neither projective nor injective We knew that some counter-examples: $\mathbb{Q}$ is a flat $\mathbb{Z}$-module but not a projective $\mathbb{Z}$-module; $\mathbb{Z}$ is a flat $\mathbb{Z}$-module but not an injective $\mathbb{Z}$-module.
So, is there a flat module but neither projective nor injective?
 A: Yes, your example is pointing in the right direction. The fact that $\mathbb{Q}$ is flat over $\mathbb{Z}$ follows from the general theorem that if $A$ is a commutative ring and $S$ is some multiplicative system in $A$, for example the complement of some prime ideal, then the localization $S^{-1}A$ is a flat $A$-module. It doesn't need to be, however, injective or projective.  
To be concrete, let $S$ be all the integers coprime to $p$ and let $Z _{(p)} = S^{-1} \mathbb{Z}$ be the localization. We have 
$$Z _{(p)} = \left\{ \frac{a}{b} : b \text{ non-zero, coprime to }p \right\} \subseteq \mathbb{Q}$$
as a subring of the rationals. Now, $Z _{(p)}$ is flat, as it is a localization, but it is not injective. This can be proved by the classification of injective modules over $\mathbb{Z}$, which have to be rational vector spaces if they are torsion free, but to give a concrete proof that it is the case consider the inclusion $\mathbb{Z} \hookrightarrow \mathbb{Z} _{(p)}$. One sees that this map cannot be extended to $\mathbb{Q}$. (Hint: Where would $\frac{1}{p}$ go under the extension?)  
To observe it's not projective, one can again use the general theorem that projective modules over principal ideal domains must be free and $\mathbb{Z} _{(p)}$ is not (Hint: Show that it is not generated by a single element and that any two elements in it are linearly dependant.) For a direct proof, consider the surjection 
$$\phi: \bigoplus_{\substack{q \text{ prime distinct from p}\\ n \in \mathbb{N}}} \mathbb{Z} \rightarrow \mathbb{Z} _{(p)}$$
where the $(q, n)$-th copy of $\mathbb{Z}$ is taken to $\phi (1_{n}) = q^{-n}$. If $\mathbb{Z} _{(p)}$ were projective, there should exist a map $\psi: \mathbb{Z} _{(p)} \rightarrow \oplus \mathbb{Z}$ such that $\phi \psi = \text{id}$. However, there are no non-zero maps in this direction. (Hint: Let $\psi: \mathbb{Z} _{(p)} \rightarrow \oplus \mathbb{Z}$ be a homomorphism. Note that $\psi(1)$ has the property that for all $k \in \mathbb{N}$ there exists some $a \in \oplus _{n \in \mathbb{N}} \mathbb{Z}$ such that $q^{k}a = \psi(1)$, because this is true for $1 \in \mathbb{Z} _{(p)}$. Are there any non-zero elements like this in any direct sum of $\mathbb{Z}$?)
A: Here is a simple example based on your given examples, in the category of $\mathbb{Z}$-modules: $\mathbb{Q}$ is flat but not projective, $\mathbb{Z}$ is flat but not injective, so put them together: $\mathbb{Q}\oplus\mathbb{Z}$ is flat, since the direct sum of flat modules is flat. It is not projective, since a direct summand of it is not projective, and it is not injective, since it is not divisible.
A: Another example is $\mathbb{Z}[\frac{1}{2}]$ over $\mathbb{Z}$.


*

*It is torsion-free, hence flat. Alternatively, $\mathbb{Z}[\frac{1}{2}] = \mathrm{colim}(\mathbb{Z} \xrightarrow{2} \mathbb{Z} \xrightarrow{2} \dotsc)$ is a directed colimit of free modules, hence flat.

*Since $2 \notin \mathbb{Z}^*$, there is no homomorphism $\mathbb{Z}[\frac{1}{2}] \to \mathbb{Z}$ extending the inclusion. Hence $\mathbb{Z}[\frac{1}{2}]$ is not projective.

*Since $3 : \mathbb{Z}[\frac{1}{2}] \to \mathbb{Z}[\frac{1}{2}]$ is not surjective, it follows that $\mathbb{Z}[\frac{1}{2}]$ is not divisible, hence not injective.

