Skip to content

Relations ​

A relation is a structure that is used to represent the relationships between elements

Category of relations ​

  • Binary relations
  • N-ary relations

Binary Relations ​

A binary relation R from the set A to the set B is a subset of A×B.

R is a set of ordered pairs in the form (a,b) where a is from A and b is from B.

aRb denotes (a,b)∈R, called a is related to b by R.

Functions and Relations ​

  • Are all the functions relations? Yes
  • Are all relations functions? No

Relation on the Set ​

  • A relation on the set is a relation from A to A.

Properties of Relations ​

Reflexive ​

A relation R on a set A is called reflexive if (a,a)∈R for every element a∈A.

Symmetric ​

A relation R on a set A is called symmetric if (b,a)∈R whenever (a,b)∈R.

Anti-symmetric ​

A relation R on a set A is called anti-symmetric if whenever (a,b)∈R and (b,a)∈R, then a=b.

Transitive ​

A relation R on a set A is called transitive if whenever (a,b)∈R and (b,c)∈R, then (a,c)∈R.

Combining Relations ​

The composite of R and S (S∘R): consisting of all ordered pairs (a,c) where a∈A, and c∈C if there exists b such that (a,b)∈R and (b,c)∈S.

E.g.,
▪ A={1}, B={0,1}, C={2,3}
▪ R={(1,0),(1,1)} (a relation from A to B)
▪ S={(0,2),(1,3)} (a relation from B to C)
▪ S∘R={(1,2),(1,3)}

Powers of a Relation ​

Let R be a relation on the set A. The powers Rn for integer n with n>0 are defined recursively by R1=R
Rn=Rn−1∘R

Theorem: The relation R on a set A is transitive if and only if Rn⊆R for n=1,2,3,…

n-ary Relations ​

  • Let A1,A2,…,An be sets.
  • An n-ary relation on these sets is a subset of A1×A2×…×An
  • Domain: A1×A2×…×An
  • Degree: n

Relations and Database ​

  • Currently, the most commonly used databases are relational databases.
  • Each database consists of multiple relations.
  • Each relation is presented as a table.

Operations on n-ary Relations ​

Selection operator σ: ​

  • n-ary relation R
  • condition c
  • Selection operator σc: maps R to an n-ary relations T, where all the tuples in T satisfy the condition c.
    i.e. σmajor="Computer Science" GradeReport={(John,001,Computer Science,3.5)}

Projection operator π: ​

  • the input relation is on n tuples (a1,a2,…,an) ,
  • the output relation is on m tuples (ai1,ai2,…,aim), m<n.
  • Projection operator πi1,i2,…,im: removes the tuples not in the m-tuple (ai1ai2,…,aim) list i.e. πname,GPA(GradeReport)={(John,3.5),(Tony,3.2),(Jonas,3.3)}

Equivalence Relations ​

  • A relation on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive. Let R be an equivalence relation on A.

Equivalent class ​

Equivalent class -> Equivalent relations

Partition ​

  • All the equivalent classes obtained from A through an equivalent class are either same or disjoint.
  • These disjoint classes are subsets of A.
  • The union of these subsets is A.
  • These subsets are called a partition of A In general, (A1,A2,…,An) is a partition of A if:
  1. Ai≠∅ for all 1≤i≤n
  2. Ai∩Aj=∅ for all 1≤i,j≤n
  3. A1∪A2∪…∪An=A

Theorem: Let R be an equivalence relation on a nonempty set A. ​

The following statements are equivalent:

  • aRb
  • [a]=[b]
  • a∩[b]≠∅