\def\djoin{d_1}
\def\mjoin{m_1}
Without loss of generality, assume that the join column is the first column in both input tables and in the result table.
Let $T'$ and $T''$ be the two input tables, and let $s'$ and $s''$ be their sizes,
and let $\djoin'$, $\djoin''$, $\mjoin'$, and $\mjoin''$ be the distinctness and multiplicity of their respective join columns.

Then, we can estimate the distinctness and multiplicity of the join column of the result table as follows, where $\alpha$ is a correction factor in the range $[0, 1]$ explained below
$$ \djoin = \alpha \cdot \min(\djoin', \; \djoin'') \text{ and } \mjoin = \mjoin' \cdot \mjoin'' \: .$$
Using this, we get the following estimation for the size of the result table
$$s = \djoin \cdot \mjoin = \alpha \cdot \min(\djoin', \; \djoin'') \cdot \mjoin' \cdot \mjoin'' \: .$$
Let us explain the intuition behind these formulas.

\def\joincol#1{\textcolor{darkblue}{\textbf{#1}}}
\newcommand{\eqal}{\hspace{-2pt}=}

\para{Distinctness}
Assume that all values of the join column of one table (without loss of generality, let us call it $T''$) occur in the join column of the other table (without loss of generality $T'$).
Then, the distinctness $\djoin''$ of table $T''$ cannot be larger than the distinctness $\djoin'$ of table $T'$ and
the distinctness of the result table $T$ is equal to the distinctness of $T''$.
In other words, $d = \min(\djoin', \djoin'')$, which matches the formula with $\alpha = 1$.
The result table might be smaller when the join column of $T''$ contains values that do not occur in $T'$.
This is reflected by the tuning constant $\alpha$.
The QLever SPARQL engine uses $\alpha = 0.7$.
The following tables show an example where $\mjoin' = \mjoin'' = 1$.

\vspace{3mm}
    \begin{tabular}{p{75pt}p{75pt}p{75pt}}
    \centering
      \begin{tabular}[t]{ll}
        \multicolumn{2}{c}{$T'$ \; \footnotesize{$s' = 3$}} \\[5pt]
        \joincol{\#14}            & \#15 \\
        \joincol{\#38}            & \#42 \\
        \joincol{\#57}            & \#13 \\ \hline
        \scriptsize{$d'_1\eqal3$} & \scriptsize{$d'_2\eqal3$} \\[-2pt]
        \scriptsize{$m'_1\eqal1$} & \scriptsize{$m'_2\eqal1$} \\
      \end{tabular}
      &
      \begin{tabular}[t]{ll}
        \multicolumn{2}{c}{$T''$ \; \footnotesize{$s'' = 2$}} \\[5pt]
        \joincol{\#14}             & \#97 \\
        \joincol{\#57}             & \#55 \\ \hline
        \scriptsize{$d''_1\eqal2$} & \scriptsize{$d''_2\eqal2$} \\[-2pt]
        \scriptsize{$m''_1\eqal1$} & \scriptsize{$m''_2\eqal1$} \\
      \end{tabular}
      &
      \begin{tabular}[t]{lll}
        \multicolumn{3}{c}{$T$ \; \footnotesize{$s = 2$}} \\[5pt]
        \textbf{\#14}            & \#15                     & \#97 \\
        \textbf{\#57}            & \#13                     & \#55 \\ \hline
        \scriptsize{$d_1\eqal2$} & \scriptsize{$d_2\eqal2$} & \scriptsize{$d_3\eqal2$} \\[-2pt]
        \scriptsize{$m_1\eqal1$} & \scriptsize{$m_2\eqal1$} & \scriptsize{$m_3\eqal1$} \\
      \end{tabular}
    \end{tabular}
\vspace{3mm}

\para{Multiplicity}
Assume that each value in the join column of $T'$ has multiplicity $\mjoin'$ and each value in the join column of $T''$ has multiplicity $\mjoin''$.%
\footnote{Note that, by definition, this is true \textit{on average}.
The closer all these multiplicities are to the average, the better our estimation tends to be.}
Then, the number of rows in $T$ for each value contained in the join columns of both input tables is $\mjoin' \cdot \mjoin''$.
Since \textit{all values} in the result table occur $\mjoin' \cdot \mjoin''$, this is also true on average, i.e. $\mjoin = \mjoin' \cdot \mjoin''$.
The following tables show an example where $\djoin' = \djoin'' = 1$.

\vspace{3mm}
\begin{tabular}{p{75pt}p{75pt}p{75pt}}
	\begin{tabular}[t]{ll}
		\multicolumn{2}{c}{$T'$ \; \footnotesize{$s' = 3$}} \\[5pt]
		\joincol{\#57}            & \#15 \\
		\joincol{\#57}            & \#42 \\
		\joincol{\#57}            & \#13 \\ \hline
		\scriptsize{$d'_1\eqal1$} & \scriptsize{$d'_2\eqal3$} \\[-2pt]
		\scriptsize{$m'_1\eqal3$} & \scriptsize{$m'_2\eqal1$} \\
	\end{tabular}
	&
	\begin{tabular}[t]{ll}
		\multicolumn{2}{c}{$T''$ \; \footnotesize{$s'' = 2$}} \\[5pt]
		\joincol{\#57} & \#97 \\
		\joincol{\#57} & \#55 \\ \hline
		\scriptsize{$d''_1\eqal1$}          & \scriptsize{$d''_2\eqal2$} \\[-2pt]
		\scriptsize{$m''_1\eqal2$}          & \scriptsize{$m''_2\eqal1$} \\
	\end{tabular}
	&
	\begin{tabular}[t]{lll}
		\multicolumn{3}{c}{$T$ \; \footnotesize{$s = 6$}} \\[5pt]
		\textbf{\#57}            & \#15                     & \#97 \\
		\textbf{\#57}            & \#15                     & \#55 \\
		\textbf{\#57}            & \#42                     & \#97 \\
		\textbf{\#57}            & \#42                     & \#55 \\
		\textbf{\#57}            & \#13                     & \#97 \\
		\textbf{\#57}            & \#13                     & \#55 \\ \hline
		\scriptsize{$d_1\eqal1$} & \scriptsize{$d_2\eqal3$} & \scriptsize{$d_3\eqal2$} \\[-2pt]
		\scriptsize{$m_1\eqal6$} & \scriptsize{$m_2\eqal2$} & \scriptsize{$m_3\eqal3$} \\
	\end{tabular}
\end{tabular}
\vspace{3mm}

%\noindent
\para{Other columns}
Since $T$ itself can be the input to another JOIN operation on any column,
we also need an estimation of the distinctness $d_j$ and multiplicity $m_j$ for each column $j$ (not just of the join column).
In the following, we will explain how to estimate $d_j$, which also gives us an estimation for $m_j$
% Note that estimating one of them is sufficient,
since we already have an estimation for the total size $s$ of $T$ and $m_j = s / d_j$ for any column $j$.
Again, without loss of generality, we can make the following assumptions (just as illustrated in the examples above):

\begin{enumerate}[label=(\arabic*),topsep=0pt,itemsep=-3pt,leftmargin=20pt]
\item The join column is the first column in both input tables and in the result table.
\item The column we are interested in, originates from the second column of table $T'$.
\item The column we are interested in, is the second column in the result table (that is $j=2$).
\end{enumerate}

\noindent
Then we estimate the distinctness in column $j=2$ of the result table as
$$d_2 = \min(d'_2, \; m'_1 \cdot \alpha \cdot \min(d'_1, \; d''_1))\:.$$
Let us also understand the intuition behind this formula.

\para{Case 1:}
Assume $d_2'$ is small, in particular smaller than $\alpha \cdot m'_1 \cdot \min(d'_1, \; d''_1)$.
Using the above formula, our estimation will be $d_2 = d_2'$.
Note that $d_2$ can never be larger than $d_2'$,
because only two things can happen when column $2$ from $T'$ gets copied to $T$:
values get lost (because not all values in the join column of $T'$ may be contained in the join column of $T''$)
and values get duplicated (because of the ``cross-product effect'', like in the first example above).
Hence, in this case our estimation is good, because $d_2'$ is small by our assumption and it is an upper bound for $d_2$.

\para{Case 2:}
Now assume $d_2'$ is large.
We can estimate the number of distinct elements in the join column of $T'$ that make it to $T$ as $\alpha \cdot \min(d'_1, \; d''_1)$, just like for our distinctness formula above.
Each of these ``bring'' $m_1'$ values from column $2$ on average.
Since $d_2'$ is large, most of them are distinct and $d_2 = m'_1 \cdot \alpha \cdot \min(d'_1, \; d''_1)$ is a good estimation.

%First, $d_2$ cannot be larger than the distinctness $d'_2$ of the original column,
%because only two things can happen when column $2$ from $T'$ gets copied to $T$:
%values get lost (because not all values in the join column of $T'$ may be contained in the join column of $T''$)
%and values get duplicated (because of the ``cross-product effect'', like in the first example above).
%This is the first term in the formula above.
%Second, we can estimate the number of distinct elements in the join column of $T'$ that make it to $T$ as $\alpha \cdot \min(d'_1, \; d''_1)$, just like for our first formula above.
%Each of these ``bring'' $m'_1$ values from column $2$, on average.
%This is the second term in the formula above.
%On one hand, if most values in column $2$ of table $T'$ that get carried over to table $T$ are distinct, the second term in the formula is a good estimation.
%On the other hand, if there are only a few different values in this column (i.e. $d_2'$ is small), then the first term in the formula is a good estimation.