โ”€โ”€โ”€โœฑ*.๏ฝก:๏ฝกโœฑ*.:๏ฝกโœง*.๏ฝกโœฐ*.:๏ฝกโœง*.๏ฝก:๏ฝก*.๏ฝกโœฑ โ”€โ”€โ”€

A relation is a subset of the cartesian product of two or more sets based on a rule or definition. It is typically denoted with ๐‘…(๐‘ฅ,๐‘ฆ), ๐‘…๐‘ฅ๐‘ฆ, ๐‘ฅ๐‘…๐‘ฆ, or ๐‘…๐‘ฅ๐‘ฆ.

A relationship ๐‘… between two sets ๐ด and ๐ต is a subset of ๐ดร—๐ต, meaning it contains some ordered pairs from the cartesian product.

Examples

  • Given ๐ป={Lyla,Alex,Connie} and ๐ด={pig,dog,snake}
    • A relation, ๐‘…, on ๐ปร—๐ด is defined as to whether a human owns the Animal.
    • ๐‘…={(Lyla,pig),(Alex,dog),(Connie,snake)}
  • Relations can also be across a single set
    • Given ๐ด={1,2}, ๐‘…=๐ดร—๐ด={(1,1),(1,2),(2,1),(2,2)}

Domain

  • The domain of a relation is written as Dom(๐‘…).
  • If ๐‘… is a relation on ๐ดร—๐ต, then Dom(๐‘…) is the subset of all ๐‘ฅ in ๐ด where (๐‘ฅ,๐‘ฆ)โˆˆ๐‘… and ๐‘ฅโˆˆ๐ด.
    • Dom({(1,2),(3,4),(5,6)})={1,3,5}

Range

  • The range of a relation is written as Ran(๐‘…).
  • If ๐‘… is a relation on ๐ดร—๐ต, then Ran(๐‘…) is the subset of all ๐‘ฆ in ๐ด where (๐‘ฅ,๐‘ฆ)โˆˆ๐‘… and ๐‘ฅโˆˆ๐ด.
    • Ran({(1,2),(3,4),(5,6)})={2,4,6}

Matrix Representation

  • Place a 1 where the relation is included in the cartesian product, otherwise place a 0.
  • Given ๐ด={๐‘Ž,๐‘,๐‘} and ๐ต={1,2,3} and the relation ๐‘…={(๐‘Ž,1),(๐‘,2),(๐‘,3)} [[[123a100b010c001]]]

Directed Graph Representation

  • A way to represent a relation visually
  • Left nodes represent elements of ๐ด and right nodes represent elements ๐ต
  • A directed edge (โ†’) from ๐‘Žโˆˆ๐ต to ๐‘โˆˆ๐ต if and only if (๐‘Ž,๐‘)โˆˆ๐‘…

In-Degree

  • The number of times an element is the second element in an ordered pair
  • Visually, the number of arrows pointing inwards

Out-Degree

  • The number of times an element is the first element in an ordered pair
  • Visually, the number of arrows pointing outwards

Properties of Relations

Reflexive

  • โˆ€๐‘ฅโˆˆ๐ด,(๐‘ฅ,๐‘ฅ)โˆˆ๐‘… [[[12311โˆ—โˆ—2โˆ—1โˆ—3โˆ—โˆ—1]]]

Symmetric

  • (๐‘ฅ,๐‘ฆ)โˆˆ๐‘…โ†’(๐‘ฆ,๐‘ฅ)โˆˆ๐‘… [[[1231โˆ—1โˆ—21โˆ—13โˆ—1โˆ—]]]

Transitive

  • (๐‘ฅ,๐‘ฆ)โˆˆ๐‘…โˆง(๐‘ฆ,๐‘ง)โˆˆ๐‘…โ†’(๐‘ฅ,๐‘ง)โˆˆ๐‘…

Equivalence

  • A relationship is equivalent if the reflective, symmetric, and transitive properties are all true.

โ”€โ”€โ”€โœฑ*.๏ฝก:๏ฝกโœฑ*.:๏ฝกโœง*.๏ฝกโœฐ*.:๏ฝกโœง*.๏ฝก:๏ฝก*.๏ฝกโœฑ โ”€โ”€โ”€