The relation is defined as R = {(a, b), (b, a), (a, a), (b, b)}
It seems to be two sets, but in that case, which terms go where in the relation definition?
The relation is defined as R = {(a, b), (b, a), (a, a), (b, b)}
It seems to be two sets, but in that case, which terms go where in the relation definition?
A relation is one set. On the set $D:= \{a, b,c, d\}$ as you defined in your question, a relation is a subset of the set $D \times D$, where $D \times D$ is the cartesian product set defined as:
$$D \times D := \{ (x,y) \mid x \in D \text{ and } y \in D \} $$
(In general, if you have two sets $X$ and $Y$, then the cartesian product $X \times Y$ is the set of ordered pairs $\{(x,y) \mid x \in X \text{ and } y \in Y \}$.)
For example, consider the set $A = \{1,2,3 \}$. Consider the relation $<$ ("less than"). You already know how elements in the set $A$ are related to each other. You know $1 < 2$, $1 < 3$, and $2 < 3$, and that's pretty much it. So the relation $<$ can be thought of as the following subset of $A \times A$:
$$\{(1,2), (1,3), (2,3)\}$$
Since the element $(1,2)$ is in this "relation" (set), it means $1 < 2$. The element $(2,1)$ is not in the relation (set) above because we know $2 < 1$ is false. $2$ is not related to $1$ in the way $2 < 1$.