I am slightly confused about following definition:
Suppose R is a relation from A to B and S is a relation from B to C. Then the composition of S and R is the relation S ◦ R from A to C defined as follows: $$S \circ R = \{(a,c) \in A \times C \mid \exists b \in B((a,b) \in R \text{ and } (b,c) \in S\}$$
I struggle to explain my question in words, hence I will give you an example to show where I'm confused.
Case 1
Suppose
$A = \{a_1,a_2,a_3\}$, $B = \{b_1,b_2,b_3\}$, $C = \{c_1,c_2,c_3\}$
$R$ is a relation from $A$ to $B$, and $D$ is a relation from $B$ to $C$
$R = \{(a_1,b_1)\}$ and $D = \{(b_1,c_3)\}$
I'm pretty sure that in this case, $R \circ D = \{(a_1,c_3)\}$
But now consider slightly different example:
Case 2
$A = \{a_1,a_2,a_3\}$, $B = \{b_1,b_2,b_3\}$, $C = \{c_1,c_2,c_3\}$
$R$ is a relation from $A$ to $B$, and $D$ is a relation from $B$ to $C$
$R = \{(a_1,b_2)\}$ and $D = \{(b_1,c_3)\}$ (Note that each subsets of $R$ and $D$ now have $b$'s with different indices)
In this case, is $R \circ D = \{(a_1,c_3)\}$ or $R \circ D = \emptyset$ ?
Note that your definition is understand by right to left:
First you take $(a, \color{red}b) \in R$ and if $( \color{red}b,c) \in S$, then add $(a,c)$ to $S \circ R$
So your computation in case 1 is wrong!, since $(\color{red}{c_3}, ?) \notin R $
For case 2, it is empty!
Note that a relation from $A$ to $C$ is any subset of $A \times C$, so empty set is also a relation. See here