In

**mathematics**, an

**n-ary relation**(or often simply

**relation**) is a generalization of binary relations such as "=" and "<" which occur in statements such as "5 < 6" or "2 + 2 = 4". It is the fundamental notion in the relational model for databases.

Formally, a relation over the sets *X*_{1}, ..., *X*_{n} is an *n*+1-ary tuple *R*=(*X*_{1}, ..., *X*_{n}, G(*R*)) where G(*R*) is a subset of *X*_{1} × ... × *X*_{n} (the Cartesian product of these sets). G(*R*) is called the *graph* of *R* and, similar to the case of binary relation, *R* is often identified as its graph.

An n-ary **predicate** is a truth-valued function of n variables.

Because a relation as above defines uniquely an n-ary predicate that holds for *x*_{1}, ..., *x*_{n} iff (*x*_{1}, ..., *x*_{n}) is in *R*, and vice versa, the relation and the predicate are often denoted with the same symbol. So, for example, the following two statements are considered to be equivalent:

- ( x
_{1}, x_{2}, ... ) ∈*R* *R*( x_{1}, x_{2}, ... )

- unary relation:
*R*(*x*) - binary relation:
*R*(*x*,*y*) or*x**R**y* - ternary relation:
*R*(*x*,*y*,*z*) - quarternary relation:
*R*(*x*,*y*,*z*,*w*)

*n*-ary; for example "a 5-ary relation".