110 likes | 124 Views
CMSC 203 / 0201 Fall 2002. Week #12 – 11/13/15 November 2002 Prof. Marie desJardins Guest lecturer/proctor: Prof. Dennis Frey. MON 11/11 RELATIONS (6.1-6.2). Concepts/Vocabulary. Binary relation R A x B (also written “a R b” or R(a,b)) Relations on a set: R A x A
E N D
CMSC 203 / 0201Fall 2002 Week #12 – 11/13/15 November 2002 Prof. Marie desJardins Guest lecturer/proctor: Prof. Dennis Frey
Concepts/Vocabulary • Binary relation R A x B (also written “a R b” or R(a,b)) • Relations on a set: R A x A • Properties of relations • Reflexivity: (a, a) R • Symmetry: (a, b) R (b, a) R • Antisymmetry: (a, b) R a=b • Transitivity: (a, b) R (b, c) R (a, c) R • Composite relation: • (a, c) SR bB: (a, b)R (b, c) S • Powers of a relation: R1 = R, Rn+1 = Rn R • Inverse relation: (b,a) R-1 (a,b) R • Complementary relation: (a,b) R (a,b) R
Concepts/Vocabulary II • n-ary relation: R A1 x A2 x … x An • Ai are the domain of R; n is its degree (or arity) • In a database, the n-tuples in a relation are called records; the entries in each record (i.e., elements of the ith set in that n-tuple) are the fields • In a database, a primary key is a domain (set Ai) whose value completely determines which n-tuple (record) is indicated – i.e., there is only one n-tuple for a given value of that domain • A composite key is the Cartesian product of a set of domains whose values completely determine which n-tuple is indicated • Projection: delete certain fields in every record • Join: merge (union) two relations using common fields
Examples • Exercise 6.1.4: Determine whether the relation R on the set of all people is reflexive, symmetric, antisymmetric, and/or transitive, where (a,b) R iff • (a) a is taller than b • (b) a and b were born on the same day • (c) a has the same first name as b • (d) a and b have a common grandparent
Examples II • Exercise 6.1.21: Let R be the relation on the set of people consisting of pairs (a, b) where a is a parent of b. Let S be the relation on the set of people consisting of pairs (a, b) where a and b are siblings (brothers or sisters). What are S R and R S? • Exercise 5.1.29: Show that the relation R on a set A is symmetric iff R = R-1. • Exercise 5.1.33: Let R be a relation that is reflexive and transitive. Prove that Rn = R for all positive integers n.
Concepts / Vocabulary • Zero-one matrix representation of [binary] relations • Matrix interpretations of properties of relations on a set: reflexivity, symmetry, antisymmetry, and transitivity • Digraph representation of [binary] relations • Pictorial interpretations of properties of relations on a set • Closure of R with respect to property P • smallest relation containing R that satisfies P • Transitive closure, reflexive closure, … • Path analogy for transitive closures; connectivity relation R*; Algorithm 6.4.1 for computing transitive closure (briefly); Warshall’s algorithm (briefly)
Examples • Exercise 6.3.5: How can the matrix for R be found from the matrix representing R, a relation on a finite set A? • Exercise 6.3.15: List the ordered pairs in the relations represented by the directed graphs: b a d c
Exercise 6.3.18 (partial): Given the digraphs representing two relations, how can the directed graphs of the union and difference of these relations be found? • Exercise 6.4.8: How can the directed graph representing the symmetric closure of a relation on a finite set be constructed from the directed graph for this relation? • Exercise 6.4.23: Suppose that the relation R is symmetric. Show that R* is symmetric.
FRI 11/8MIDTERM #2 Good luck!