Q:

Are integers mod n a unique factorization domain?

I am trying to learn abstract algebra from scratch, jolly stuff, but in the process of doing so this puzzles me:
Having a ring of integers mod $n$, where $n=pq$ is composite, as I understand we have that  $\mathbb{Z}/n\mathbb{Z}$ is a Principal Ideal Domain (PID) (by this question). Therefore by the pretty chain of inclusions located here, it is also a unique factorization domain. 
And this is where I am lost, as I keep thinking of for example $\mathbb{Z}/8\mathbb{Z}$ where I can have $4\equiv 2\cdot2 \equiv 2\cdot2\cdot5 \bmod 8$. Also, $p\cdot q \equiv 0 \bmod n$ which gives two non-zero divisors of zero. In my world, this means that $\mathbb{Z}/8\mathbb{Z}$ is not a UFD and not even integral domain.
I feel like I am missing something very simple yet crucial :-).

A:

When $\,n\,$ is composite $\,\Bbb Z/n\,$ is not an integral domain. Factorization theory is much more complicated in non-domains, e.g. $\rm\:x = (3+2x)(2-3x)\in \Bbb Z_6[x].\:$ Basic notions such as associate and irreducible bifurcate into a few inequivalent notions, e.g. see
When are Associates Unit Multiples?
D.D. Anderson, M. Axtell, S.J. Forman, and Joe Stickles.
Rocky Mountain J. Math. Volume 34, Number 3 (2004), 811-828. 
Factorization in Commutative Rings with Zero-divisors.
D.D. Anderson, Silvia Valdes-Leon.
Rocky Mountain J. Math. Volume 28, Number 2 (1996), 439-480

A:

You have misinterpreted the question to which you linked. What is asserted there is that all ideals of $\mathbb Z/n$ are principal.  But that does not make $\mathbb Z/n$ a PID unless it is an integral domain, and, as Bill Dubuque said, that happens only when $n$ is prime.

