A binary relation $R\subset X\times Y$ can be classified as a function
if it suffices:
$\forall x\in X\;\exists!y\in Y\;\left(x,y\right)\in R$
(in words: for every $x\in X$ there is exactly one $y\in Y$ such
that $\left(x,y\right)\in R$).
This unique $y$ is denoted as $R(y)$. Now let $S\subset Y\times Z$ be a binary relation and define $S\circ R$ by:
$\left(x,z\right)\in S\circ R$ iff $\left(x,y\right)\in R\wedge\left(y,z\right)\in S$
for some $y\in Y$.
It can be proved that $S\circ R$ is a function
if $S$ and $R$ are functions. Starting with $x\in X$ there is a
unique $y\in Y$ with $\left(x,y\right)\in R$ (this because $R$
is a function). For this unique $y$ there is a unique $z\in Z$ with
$\left(y,z\right)\in S$ (this because $S$ is a function). Then $\left(x,z\right)\in S\circ R$ and $z\in Z$ is unique. Here $S\circ R$ is the composite function and $z=S\circ R(x)=S(R(x))=S(y)$.
Warning1: Sometimes $S\circ R$ is denoted as $R\circ S$
Warning2: Actually functions are often defined as triples $f=\left(X,G,Y\right)$
where $G\subset X\times Y$ is a binary relation having the mentioned property.
Here $X$ is the domain, $Y$ is the codomain and
$G$ is the graph of $f$.