Relations CSC2259 Discrete Structures Konstantin Busch LSU 1
Relations CSC-2259 Discrete Structures Konstantin Busch - LSU 1
Relations and Their Properties A binary relation from set to is a subset of Cartesian product Example: A relation: Konstantin Busch - LSU 2
A relation on set is a subset of Example: A relation on set Konstantin Busch - LSU : 3
Reflexive relation on set : Example: Konstantin Busch - LSU 4
Symmetric relation : Example: Konstantin Busch - LSU 5
Antisymmetric relation : Example: Konstantin Busch - LSU 6
Transitive relation : Example: Konstantin Busch - LSU 7
Combining Relations Konstantin Busch - LSU 8
Composite relation: Note: Example: Konstantin Busch - LSU 9
Power of relation: Example: Konstantin Busch - LSU 10
Theorem: A relation if an only if for all is transitive Proof: 1. If part: 2. Only if part: use induction Konstantin Busch - LSU 11
1. If part: We will show that if then is transitive Assumption: Definition of power: Definition of composition: Therefore, is transitive Konstantin Busch - LSU 12
2. Only if part: We will show that if then for all is transitive Proof by induction on Inductive basis: It trivially holds Konstantin Busch - LSU 13
Inductive hypothesis: Assume that for all Konstantin Busch - LSU 14
Inductive step: We will prove Take arbitrary We will show Konstantin Busch - LSU 15
definition of power definition of composition inductive hypothesis is transitive End of Proof Konstantin Busch - LSU 16
n-ary relations An n-ary relation on sets is a subset of Cartesian product Example: A relation on All triples of numbers Konstantin Busch - LSU with 17
Relational data model n-ary relation is represented with table fields records R: Teaching assignments Professor Department Course-number Cruz Zoology 335 Cruz Zoology 412 Farber Psychology 501 Farber Psychology 617 Rosen Comp. Science 518 Rosen Mathematics 575 primary key (all entries are different) Konstantin Busch - LSU 18
Selection operator: keeps all records that satisfy condition Example: Result of selection operator Professor Department Course-number Farber Psychology 501 Farber Psychology 617 Konstantin Busch - LSU 19
Projection operator: Keeps only the fields of Example: Professor Department Cruz Zoology Farber Psychology Rosen Comp. Science Rosen Mathematics Konstantin Busch - LSU 20
Join operator: Concatenates the records of and where the last fields of are the same with the first fields of Konstantin Busch - LSU 21
S: Class schedule Department Course-number Room Time Comp. Science 518 N 521 2: 00 pm Mathematics 575 N 502 3: 00 pm Mathematics 611 N 521 4: 00 pm Psychology 501 A 100 3: 00 pm Psychology 617 A 110 11: 00 am Zoology 335 A 100 9: 00 am Zoology 412 A 100 8: 00 am Konstantin Busch - LSU 22
J 2(R, S) Professor Department Course Number Room Time Cruz Zoology 335 A 100 9: 00 am Cruz Zoology 412 A 100 8: 00 am Farber Psychology 501 A 100 3: 00 pm Farber Psychology 617 A 110 11: 00 am Rosen Comp. Science 518 N 521 2: 00 pm Rosen Mathematics N 502 3: 00 pm 575 Konstantin Busch - LSU 23
Representing Relations with Matrices Relation Matrix Konstantin Busch - LSU 24
Reflexive relation on set : Diagonal elements must be 1 Example: Konstantin Busch - LSU 25
Symmetric relation : Matrix is equal to its transpose: Example: For all Konstantin Busch - LSU 26
Antisymmetric relation : Example: For all Konstantin Busch - LSU 27
Union : Intersection : Konstantin Busch - LSU 28
Composition : Boolean matrix product Konstantin Busch - LSU 29
Power : Boolean matrix product Konstantin Busch - LSU 30
Digraphs (Directed Graphs) Konstantin Busch - LSU 31
Theorem: if and only if there is a path of length from to in Konstantin Busch - LSU 32
Connectivity relation: if and only if there is some path (of any length) from to in Konstantin Busch - LSU 33
Theorem: Proof: if for some then Repeated node Konstantin Busch - LSU 34
Closures and Relations Reflexive closure of : Smallest size relation that contains and is reflexive Easy to find Konstantin Busch - LSU 35
Symmetric closure of : Smallest size relation that contains and is symmetric Easy to find Konstantin Busch - LSU 36
Transitive closure of : Smallest size relation that contains and is transitive More difficult to find Konstantin Busch - LSU 37
Theorem: Proof: is the transitive Closure of is transitive Part 1: Part 2: If and is transitive Then Konstantin Busch - LSU 38
- Slides: 38