Functions and relations have a long mathematical history, and can be approached from many sides (e.g. category theory, set theories). From a standard set-theoretic perspective, we begin with the notion of an ordered pair (a, b), which can either be taken as a primitive or defined in terms purely of sets. Either way, the explication is only to satisfy the following condition: (a, b) = (c, d) iff a = c and b = d. Once we have ordered pairs, we can define relations of arbitrary arity as follows:
Def 2. (Relations over multiple sets) An n-ary relation over sets A1,...,An is any subset of A1 × ... × An.
Informally, this means that n-ary relation is a set of n-tuples of elements selected from a bunch of sets. A special type of relation used often in introductory logic courses is that of the predicate, which is simply a 1-ary or unary relation over the domain of individuals. In single-sorted logics such as classical first-order logic, the domain of individuals is some set D, so we have a simpler definition of relations:
Def 3. (Relations over a single set) An n-ary relation on set A is any subset of An.
As examples of such relations take the relations LeftOf, SmallerThan, LessThan, and so on. For 3-ary relations Between, CloserThan come to mind. For 1-ary relations or predicates we have Small, Even, Prime, and so on. Now that we have defined relations, we can define functions in terms of them:
Def 4. (Functions) An n-ary function from A to B is a total deterministic n-ary relation on A × B.
Relation R ⊆ A × B is total iff for all x ∈ A, there exists a y ∈ B s.t. (x, y) ∈ R. In other words, every element of A is mapped to some element of B. Relation R ⊆ A × B is deterministic iff there is no x ∈ A for which there are y, z ∈ B s.t. (x, y) ∈ R and (x, z) ∈ R. In other words, every element of A is mapped to no more than one element of B.
These notions are applied to natural language semantics exactly in the way you described. Consider:
(5) Joe is the son of Mary.
If we let 'j' denote Joe, 'm' Mary, we'll have two possible explications of (5): one using a binary relation symbol 'S' (which holds of (x,y) just in case x is the sone of y) and one using the identity relation on the domain of individuals and the unary function symbol 's' (which refers to the unique individual that is the son of x). Following the first way we get:
(6) S(j, m) ∧ ∀x : S(x,m) → x = j.
This says that John is a son of Mary and every person x who is a son of Mary is John, which is the intended meaning of (5) I assume.
Following the second approach we get:
(7) j = s(m).
It's easy to check that (6) is true exactly when (7) is true. After all, S is a set of pairs (x, y) s.t. x is a son of y, and the second conjunct of (6) implies that x is j which according to (7) is s(m).
Remark. The distinction between (6) and (7) roughly corresponds to the famous distinction between Russelian and Fregean views of definite descriptions. According to the Fregean view, 'the φ' denotes the unique individual satisfying condition φ, if such an individual exists. The Russellian view, on the other hand, regards 'the φ' as meaningful only in a context of a complete sentence (e.g. (6)). That, however, is another discussion.
Halmos, P. (1960) Naive Set Theory; Chapters 6–8.
Heim, I., Kratzer, A. (1998) Semantics in Generative Grammar; §4.4.