- PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Description:

Reflexivity and relatives. A relation R on A is reflexive. iff a A(aRa) ... Let R:A B, and S:B C. Then the composite S R of R and S is defined as: ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 29
Provided by: michae1479
Learn more at: https://cis.temple.edu
Category:
Tags:

less

Transcript and Presenter's Notes

Title:


1
7.1 Binary Relations (2nd pass)and 7.2 n-ary
Relations Longin Jan Latecki
  • Slides adapted from Kees van Deemter who adopted
    them from Michael P. Franks Course Based on the
    TextDiscrete Mathematics Its Applications
    (5th Edition)by Kenneth H. Rosen

2
7.1 Binary Relations (2nd pass)
  • Let A, B be any sets. A binary relation R from A
    to B is a subset of AB.
  • E.g., lt can be seen as (n,m) n lt m
  • (a,b)?R means that a is related to b (by R)
  • Also written as aRb also R(a,b)
  • E.g., altb and lt (a,b) both mean (a,b)? lt
  • A binary relation R corresponds to a
    characteristic function PRAB?T,F

3
Complementary Relations
  • Let RA,B be any binary relation.
  • Then, RAB, the complement of R, is the binary
    relation defined by R(a,b)?AB
    (a,b)?R(AB) - R
  • Note this is just R if the universe of discourse
    is U AB thus the name complement.
  • Note the complement of R is R.

Example lt (a,b) (a,b)?lt (a,b) altb

4
Inverse Relations
  • Any binary relation RAB has an inverse relation
    R-1BA, defined by R-1 (b,a) (a,b)?R.
  • E.g., lt-1 (b,a) altb (b,a) bgta gt.
  • E.g., if RPeople x Foods is defined by a
    R b ? a eats b, then b R-1 a ? b is eaten
    by a. (Passive voice.)

5
Relations on a Set
  • A (binary) relation from a set A to itself is
    called a relation on the set A.
  • E.g., the lt relation from earlier was defined
    as a relation on the set N of natural numbers.

6
Reflexivity and relatives
  • A relation R on A is reflexive iff ?a?A(aRa).
  • E.g., the relation (a,b) ab is
    reflexive.
  • R is irreflexive iff ?a?A(?aRa)
  • Note irreflexive does NOT mean not reflexive,
    which is just ??a?A(aRa).

7
Reflexivity and relatives
  • Theorem A relation R is irreflexive iff its
    complementary relation R is reflexive.
  • Example lt is irreflexive is reflexive.
  • Proof trivial

8
  • Can you think of
  • Reflexive relations
  • Irreflexive relations
  • Involving numbers, propositions or sets?

9
Some examples
  • Reflexive
  • , have same cardinality, ?
  • lt, gt, ?, ?, etc.
  • Irreflexive
  • lt, gt, have different cardinality, ?

10
Symmetry relatives
  • A binary relation R on A is symmetric iff
    ?a,b((a,b)?R ? (b,a)?R).
  • E.g., (equality) is symmetric. lt is not.
  • is married to is symmetric, likes is not.
  • A binary relation R is asymmetric if
    ?a,b((a,b)?R ? (b,a)?R).
  • Examples lt is asymmetric, likes is not.

11
Some direct consequences
  • Theorems
  • R is symmetric iff R R-1,
  • R is asymmetric iff R?R-1 is empty.

12
Symmetry relatives
  • 1. R is symmetric iff R R-1
  • Suppose R is symmetric. Then (x,y) ? R ? (y,x)
    ? R ? (x,y) ? R-1
  • ? Suppose R R-1 Then (x,y) ? R ? (x,y) ?
    R-1 ? (y,x) ? R

13
Symmetry relatives
  • 2. R is asymmetric iff R?R-1 is
    empty.(Straightforward application of the
    definitions of asymmetry and R-1)

14
Antisymmetry
  • Consider the relation x?y
  • It is not symmetric. (For instance, 5?6 but not
    6?5)
  • It is not asymmetric. (For instance, 5 ?5)
  • You might say its nearly symmetric, since the
    only symmetries occur when xy
  • This is called antisymmetry

15
Antisymmetry
  • A binary relation R on A is antisymmetric iff
    ?a,b((a,b)?R ? (b,a)?R? ab).
  • Examples ?, ?, ?

16
Transitivity
  • A relation R is transitive iff (for all
    a,b,c) ((a,b)?R ? (b,c)?R) ? (a,c)?R.
  • Example is an ancestor of is transitive.

17
Composite Relations
  • Let RAB, and SBC. Then the composite S?R of
    R and S is defined as
  • S?R (a,c) ?b aRb ? bSc
  • Function composition is an example writing fT
    for the function-version of the relation T, we
    have
  • S?R(a,c) iff ?b aRb ? bSc iff fR(a)b
    and fS(b)ciff fS?fR(a)c

18
Composite Relations
  • The nth power Rn of a relation R on a set A can
    be defined recursively by R0 IA Rn1
    Rn?R for all n0.
  • E.g., R1 R R2 R?R R3 R?R?R

e
d
a
c
b
19
Composite Relations
  • R2 R?R (a, c) (e, c) (b, d) (d, d) (c, c)

e
e
d
d
a
a
c
c
b
b
20
7.2 n-ary Relations
  • An n-ary relation R on sets A1,,An, is a
    subset R ? A1 An.
  • The sets Ai are called the domains of R.
  • The degree of R is n.
  • A relational database is essentially just a set
    of relations.

21
7.2 n-ary Relations
  • An n-ary relation R is a straightforward
    generalisation of a binary relation. For example
  • 3-ary relations
  • a is between b and c
  • a gave b to c

22
Relational Databases
  • A domain Ai is a primary key for the database if
    the relation R is functional in Ai.
  • R is functional in the domain Ai if it contains
    at most one n-tuple (, ai ,) for any value ai
    within domain Ai.
  • A composite key for the database is a set of
    domains Ai, Aj, such that R contains at most
    1 n-tuple (,ai,,aj,) for each composite value
    (ai,aj,)?AiAj

23
Selection Operators
  • Let A be any n-ary domain AA1An, and let
    CA?T,F be any condition (predicate) on
    elements (n-tuples) of A.
  • Then, the selection operator sC is the operator
    that maps any (n-ary) relation R on A to the
    n-ary relation consisting of all n-tuples from R
    that satisfy C. That is,
  • sC(R) a?R C(a) T

24
Selection Operator Example
  • Suppose we have a domain A StudentName
    Standing SocSecNos
  • Suppose we define a condition Upperlevel on A
    UpperLevel(name,standing,ssn) (standing
    junior) ? (standing senior)
  • Then, sUpperLevel is the selection operator that
    takes any relation R on A (database of students)
    and produces a relation consisting of just the
    upper-level students (juniors and seniors).

25
Projection Operators
  • Let A A1An be any n-ary domain, and let
    ik(i1,,im) be a sequence of indices all
    falling in the range 1 to n,
  • That is, 1 ik n for all 1 k m.
  • Then the projection operator on n-tuplesis
    defined by

26
Projection Example
  • Suppose we have a ternary (3-ary) domain
    CarsModelYearColor. (note n3).
  • Consider the index sequence ik 1,3. (m2)
  • Then the projection P maps each tuple
    (a1,a2,a3) (model,year,color) to its image
  • This operator can be usefully applied to a whole
    relation R?Cars (a database of cars) to obtain a
    list of the model/color combinations available.

ik
27
Join Operator
  • Puts two relations together to form a combined
    relation.
  • If the tuple (A,B) appears in R1, and the tuple
    (B,C) appears in R2, then the tuple (A,B,C)
    appears in the join J(R1,R2).
  • A, B, and C can also be sequences of elements.

28
Join Example
  • Suppose R1 is a teaching assignment table,
    relating Lecturers to Courses.
  • Suppose R2 is a room assignment table relating
    Courses to Rooms,Times.
  • Then J(R1,R2) is like your class schedule,
    listing (lecturer,course,room,time).
  • (For precise definition, see Rosen, p.486)
Write a Comment
User Comments (0)
About PowerShow.com