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