Relations - 10
All the relations we have been looking at so far have been binary relations however this can be generalised for greater numbered relations.
$n$-ary Relations
The Cartesian product $A_1\times A_2\times \ldots \times A_n$ of sets $A_1,A_2,\ldots,A_n$ is defined by:
\[\begin{aligned} A_1\times A_2\times \ldots \times A_n=&\\ \{(a_1,\ldots,a_n)\ \vert\ a_1\in A_1,\ldots,a_n\in A_n\}& \end{aligned}\]Here $(a_1,\ldots,a_n)=(b_1,\ldots,b_n$ if and only if $a_i=b_i$ for all $1\leq i\leq n$.
An $n$-ary relation is a subset of $A_1\times\ldots A_n$
Databases and Relations
A database table $\approx$ relation.
Table 1 $\text{Students}$
Student_name | ID_number | Major | GPA |
---|---|---|---|
Ackermann | 231455 | Computer Science | 3.88 |
Adams | 888323 | Physics | 3.45 |
Chou | 102147 | Computer Science | 3.49 |
Goodfriend | 453876 | Mathematics | 3.45 |
Rao | 678543 | Mathematics | 3.9 |
Stevens | 786576 | Psychology | 2.99 |
This student table is a subset of the Cartesian product of four sets containing names, ID numbers, subject and GPA. We can then write these properties in tuples in the subset: $\text{Students}=\{\text{(Ackerman, 231455,}$$\text{ Computer Science, 3.88)}\ldots\}$.
Unary Relations
Unary relation are just subsets of a set.
Example
The unary relation $\text{EvenPositiveIntegers}$ on the set $\Bbb{Z^+}$ of positive integers is:
\[\{x\in\Bbb{Z^+}\ \vert\ x \text{ is even}\}\]This shows that a unary relation is just a list of items in a set the satisfy a property.