There are six cases for the characteristic polynomial $\;p(x)\;$ and for the minimal one $\;m(x)\;$:
$$\begin{align*}\bullet&p(x)=(x-a)(x-b)(x-c)=m(x)\;,\;a,b,c\;\;\text {different. In this case the matrices are diagonalizable:}\\
\begin{pmatrix}a&0&0\\0&b&0\\0&0&c\end{pmatrix}\\{}\\
\bullet&p(x)=(x-a)^2(x-b)=m(x)\;,\;\;a\neq b. \;\text{In this case, the JCF for both}\\
\text{ matrices is }\\{}\\\begin{pmatrix}a&1&0\\0&a&0\\0&0&b\end{pmatrix}\\{}\\
\bullet&p(x)=(x-a)^2(x-b)\;,\;\;m(x)=(x-a)(x-b)\;,\;\;a\neq b. \text{ Here, the JCF}\\
\text{in both cases is}\\{}\\\begin{pmatrix}a&0&0\\0&a&0\\0&0&b\end{pmatrix}\\{}\\
\bullet&p(x)=(x-a)^3...\text{Check the three cases for}\;\;m(x)\end{align*}$$
For a matrix $A$ the invariant factors are determined by finding the Smith canonical form equivalent to $(xI - A)$. Let's say $$S(x) = \text{Dg}[1,\ldots,1,f_1(x),\ldots,f_k(x)]$$ is the Smith canonical form. As mentioned elsewhere $f_1(x),f_2(x),\ldots,f_k(x)$ are all monic and each lower index monic polynomial divides the following. These are the invariant factors. (Also note that $f_k(x)$ is the minimum polynomial)
Now, it is true that $A$ is similar to Dg$[C(f_1(x)),\ldots,C(f_k(x))]$ where $C(f_i(x))$ indicates the companion matrix associated with $f_i(x)$, but this is not the Rational Canonical Form, to the best of my knowledge, not according to my textbook anyway.
The rational canonical form is derived by finding the elementary divisors of $A$. Take any invariant factor $f_i(x)$, then we can write it as $p_1(x)^{ei1}p_2(x)^{ei2}\ldots p_t(x)^{eit}$ where the $p_i(x)$ are distinct, monic and irreducible. These are then the elementary divisors of $A$. The rational canonical form is constructed from these elementary divisors as $$\text{Dg}[\ldots,H(p_1(x)^{ei1}),H(p_2(x)^{ei2}),\ldots,H(p_t(x)^{eit}),\ldots]$$ where $$H(p(x)^e) = \begin{bmatrix} C(p(x)) & 0 & \cdots & 0 & 0 \\
N & C(p(x)) & \cdots & 0 & 0 \\ \vdots & & & & \vdots \\ 0 & 0 & \cdots & N & C(p(x)) \end{bmatrix}.$$ Here $N$ is a matrix that is all zero except for a 1 in the upper right hand corner, and the companion matrix $C(p(x))$ is repeated $e$ times. This is known as a hypercompanion matrix. Note that the rational canonical form reduces to Jordan canonical form when the field is algebraically closed.
Let's look at an example: suppose you have invariant factors $f_1(x) = (x^2 + 4)(x^2 - 3)$ and $f_2(x) = (x^2 + 4)^2(x^2 - 3)^2$, and suppose the field we are considering is $\mathbb{Q}$. Then the elementary divisors are $(x^2 + 4),(x^2 - 3),(x^2 + 4)^2$ and $(x^2 - 3)^2$ and so the rational canonical form is $$\text{Dg}\left [ \begin{bmatrix}0&-4\\1&0 \end{bmatrix}, \begin{bmatrix}0&3\\1&0 \end{bmatrix},\begin{bmatrix}0&-4&0&0\\1&0&0&0\\0&1&0&-4\\0&0&1&0 \end{bmatrix},\begin{bmatrix}0&3&0&0\\1&0&0&0\\0&1&0&3\\0&0&1&0 \end{bmatrix}\right ].$$
My source material for this theory: CG Cullen, Matrices and linear transformations (2nd edition), the chapter named: Similarity: Part II. There are more examples and in-depth discussion there...
Best Answer
If $A\in M_3$ has one eigenvalue $a$, then its characteristic polynomial is $(x-a)^3$, and its minimal polynomial is $x-a$, $(x-a)^2$, or $(x-a)^3$. The only corresponding possibilities for Jordan form are, respectively, 3 blocks of size 1 ($A=aI$), a block of size 2 and hence another of size 1, and one block of size 3. Similarly, the possibilities are determined if there is more than one eigenvalue.
In $M_4$, consider the matrices $\begin{bmatrix}0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1\\0 & 0 & 0 & 0\end{bmatrix}$ and $\begin{bmatrix}0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{bmatrix}$.
From the characteristic polynomial $(x-a_1)^{n_1}\cdots (x-a_k)^{n_k}$ of a matrix $A\in M_n$ with distinct eigenvalues $a_1,\ldots,a_k$, you can see that the Jordan blocks for the eigenvalue $a_j$ have to have sizes adding to $n_j$. The largest size of one of these blocks is the exponent of $(x-a_j)$ appearing in the minimal polynomial of $A$. In case $n_j=3$, the only sizes possible for the blocks are $1+1+1$, $2+1$, and $3$, so the highest size of a block (the exponent in the minimal polynomial) determines the decomposition for $a_j$. If $n_j=2$ you have $1+1$ and $2$ as possible Jordan structure, so again it is determined by the largest size of a block. But when $n_j>3$, there are always decompositions like $2+2+[n-4\text{ ones}]$ and $2+1+1+[n-4\text{ ones}]$ which have the same largest size block (same exponent in the minimal polynomial), but are different Jordan forms.