Is \mathrel always needed?

You can figure out what is going on using the table on page 170 of the TeXbook.

enter image description here

Here 0, 1, 2, and 3 stand for no space, thin space, medium space, and thick space, respectively; the table entry is parenthesized if the space is to be inserted only in display and text styles, not in script and scriptscript styles.

First we look at the definitions of \models, \mid, \!, and \joinrel. For simplicity I use the definitions from Plain TeX (the LaTeX definitions are similar but with some extra \protect and stuff).

\def\models{\mathrel|\joinrel=}
\mathchardef\mid="326A
\def\!{\mskip-\thinmuskip} % \thinmuskip=3mu
\def\joinrel{\mathrel{\mkern-3mu}}

Checking in the table the spacing between a Rel and a Rel atom we find 0, i.e. no spacing at all. That means that there will be no space inserted between any of the atoms in any of the following sequences because all the atoms are Rel (except \mskip which is not an atom)

\models\!\mid
\models\joinrel\mid

Because the leftmost and rightmost atoms in these sequences are of type Rel, the whole sequence will behave like a Rel atom (with respect to spacing). So in this case the enclosing \mathrel is redundant.


The ugly

\newcommand{\mymodel}{\mathrel{\models\joinrel\mid}} 

The bad

\newcommand{\mymod}{\mathrel{\models\!\mid}} 
\newcommand{\mymode}{\models\!\mid} 

The good

\newcommand{\foo}{\models\joinrel\mid}

The best™

\DeclareRobustCommand{\xjoinrel}{\mathrel{\mkern-3.5mu}}
\let\models\relax % undefine \models
\DeclareRobustCommand{\models}{\mathrel{|}\xjoinrel\Relbar} %% YES!
\DeclareRobustCommand{\mymod}{\mathrel{|}\xjoinrel\Relbar\xjoinrel\mathrel{|}}

Explanations

TeX never adds space between two consecutive relation symbols. Since \models is defined as \mathrel{|}\joinrel\Relbar and all three are relation symbols, the first method has a redundant \mathrel.

The command \joinrel is \mathrel{\mkern-3mu}. Using \mid and \mathrel{|} is the same, but in this context \mathrel{|} is better because \mid might be used for a different symbol.

Why are the other two bad? Because \! is not the right spacing.

The good is just what's needed, because it gives a relation and adds no spaces in between.

The best method avoids the little gap between the \Relbar and \mid. Look closely in the table below.

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}

\DeclareRobustCommand{\xjoinrel}{\mathrel{\mkern-3.5mu}}

\renewcommand{\models}{%
  \mathrel{|}
  \xjoinrel
  \Relbar 
}
\newcommand{\modeledby}{%
  \Relbar 
  \xjoinrel
  \mathrel{|}
}
\newcommand{\doublemodels}{%
  \mathrel{|}
  \xjoinrel
  \Relbar 
  \xjoinrel
  \mathrel{|}
}

\begin{document}

\begin{tabular}{cc}
\toprule
New & Old \\
\midrule
$A\models B$ & $A\mid\joinrel\Relbar B$ \\
$A\modeledby B$ & $A \Relbar\joinrel\mid B$ \\
$A\doublemodels B$ & $A \mid\joinrel\Relbar\joinrel\mid B$ \\
\bottomrule
\end{tabular}

\end{document}

enter image description here