The domain of a function is the set A — the collection of all allowed inputs. Every element of the domain must be assigned an output. A function is not permitted to leave any input unaccounted for. This totality requirement is part of what makes a function a function.
Specifying a function requires specifying three things: its domain, its codomain, and the assignment rule. Two functions with the same rule but different domains are different functions. “Square each natural number” and “square each real number” are distinct functions, even where they agree, because the domain of the first is and the domain of the second is .
The domain of a binary relation is the set A — the set from which the first components of the ordered pairs are drawn. Unlike a function, a relation does not require every element of A to appear in some pair.
In a category, the domain of a morphism is the source object A. Every morphism has a domain and a codomain. Composition requires the codomain of to equal the domain of — this matching condition is what makes composition possible.