For any binary relation $\rho$ between sets A and B, $$\rho=\{ (a,b)\,|\, a\in A\; \wedge\; b\in B \}$$ we define A as the domain and B as the codomain of the relation.
But in case of a finitary n-ary relation (for any arbitrary n) between n sets $A_1,A_2, \ldots ,A_n$, $$\psi =\{ (a_1,a_2,\ldots ,a_n)\,|\,a_1\in A_1 \wedge a_2\in A_2 \wedge \ldots \wedge a_n\in A_n\}\quad \& \quad \psi\subseteq A_1\times A_2\times\ldots\times A_n$$ How to define domain and codomain?
The formula you gave for an arbitary relation, namely A×B, is incorrect.
The domain of a relation R is
{ x : exists y with xRy }.
The range of R is
{ y : exists x with xRy }.
A codomain can be any set that includes the range.
As for an n-ary relation, if you must insist to unadvisely think in terms of functions, then view it like a function of n - 1 variables.
A fruitful concept is the k-th component or projection, { x$_k$ : x in R }