Prove that every rational number $r$ can be written as $r=\frac{p}{q}$, where $p$, $q$ $\in \mathbb{Z}$, $q \gt 0$ and $p$, $q$ are relatively prime. Moreover the integers $p$ and $q$ are uniquely determined by $r$.
My try: Let $R$ be a relation on $Z \times Z$ such that $(m,n) \sim (m',n')$ if $mn'=nm'$ where $n \ne 0$ and so is $n'$.
This is an equivalence relation. Now I denote such a class by $[m,n]=\frac{m}{n}$, where $m$ and $n$ are in its lowest form.