Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Set Theory Foundation of Relational Database Systems E.F. Codd.

Similar presentations


Presentation on theme: "1 Set Theory Foundation of Relational Database Systems E.F. Codd."— Presentation transcript:

1 1 Set Theory Foundation of Relational Database Systems E.F. Codd

2 2 Basic Concepts A set is a collection of elements From a known background “Universe” A definition we are satisfied with Everything is in the “Universe” An element could be any thing

3 3 Examples All UWP students in CS363 this semester A = {UWP students in CS363 this semester} B = {All UWP students who play Bridge} C = {1, 2, 3, 4} I = {i: i is an integer} Number of elements of each set

4 4 No repeating elements {1, 2, 3, 4, 2} Not a set in classic set theory Elements are not ordered {1, 2, 3, 4} {2, 4, 1, 3} The same set

5 5 Empty Set A = {UWP students in CS363 this semester} D = {s | s in A and has attended Turing Award ceremony} D = {} =  This is not empty set: {  }

6 6 Sets and Elements S is a set X is an element in the “Universe” Two possibilities: x is in S (x  S) or x is not in S (x  S)

7 7 Subsets For two sets A and B and any element x, if x  A then x  B Then A is a subset of B A  B or B  A (similar to A A) A could be the same as B A  B or B  A (similar to A = A)

8 8 Subsets For two sets A and B and any element x, if x  A then x  B Then A is a subset of B A is not a subset of B There is an element x such that x  A and x  B

9 9 Subsets (II) For any set X,   X No element e such that e   and e  X

10 10 Proper Subsets For any set X,   X X  X A is a proper subset of B, if all the three conditions are true: A  B (A  B) A  B A  

11 11 Cardinality C = {1, 2, 3, 4} |C| = 4 A = {UWP students in CS363 this semester} |A| = 55 I = {i: i is an integer} |I| =  (Number of elements of finite sets)

12 12 Power Set For any set X, P(X) = {S | S is a subset of X} = {S | S  X} C = {1, 2, 3, 4} P(C) = {{1}, {2}, {3}, {4}, {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4}, {}}

13 13 Power Set C = {1, 2, 3, 4} P(C) = {{1}, {2}, {3}, {4}, {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4}, {}} P(C) = {{1}, {2}, {3}, {4}, {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4},  }

14 14 The cardinality of the power set X is a set and its cardinality is |X| The power set of X is P(X) and its cardinality is |P(X)| = 2 |X|

15 15 Example I C = {1, 2, 3, 4} |C| = 4 P(C) = {{1}, {2}, {3}, {4}, {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4},  } |P(C)| = 2 4 = 16

16 16 Example II X = {x0, x1, x2, x3, x4, x5, x6, x7} |X| = 8 |P(X)| = 2 8 x0 x1 x2 x3 x4 x5 x6 x7 1 0 0 1 1 0 0 0 The same as a byte with 8 bits.

17 17 Set Operations Set Union A  B = {x: x  A or x  B} A = {1, 2, 3, 4} B = {2, 5} A  B = {x: x  A or x  B} = {1, 2, 3, 4, 5} = B  A Range of |A  B|? Max (|A|, |B|) <= |A  B| <= |A| + |B|

18 18 Set Intersection A  B = {x: x  A and x  B} A = {1, 2, 3, 4} B = {2, 5} A  B = {x: x  A and x  B} = {2} = B  A Range of |A  B| ? 0 <= |A  B| <= Min(|A|, |B|)

19 19 Set Difference A – B = {x: x  A but x  B} A = {1, 2, 3, 4} B = {2, 5} A – B = {x: x  A but x  B} = {1, 3, 4}  B - A B – A = {5} Range of |A – B|?

20 20 Cartesian Product A  B = {(a, b): a  A and b  B} A = {1, 2, 3, 4} B = {2, 5} A  B = {(a, b): a  A and b  B} = {(1, 2), (1, 5), (2, 2), (2, 5), (3, 2), (3, 5), (4, 2), (4, 5)} A  B  B  A |A  B| = |A|  |B|

21 21 Cartesian Product (II) Multiple sets A1, A2, A3, …, An A1  A2  A3  …  An = {(x1, x2, x3, …, xn): xi  Ai} It is possible for some i and j, Ai = Aj. A = {1, 2, 3, 4} B = {2, 5} A  B  B = {(a, b, c): a  A and b  B and c  B} = {(1, 2, 2), (1, 5, 2), (2, 2, 2), (2, 5, 2), (3, 2, 2), (3, 5, 2), (4, 2, 2), (4, 5, 2), (1, 2, 5), (1, 5, 5), (2, 2, 5), (2, 5, 5), (3, 2, 5), (3, 5, 5), (4, 2, 5), (4, 5, 5)}

22 22 Assignment 1 Due Wednesday, January 30 At beginning of class Type your work and submit a hard copy.


Download ppt "1 Set Theory Foundation of Relational Database Systems E.F. Codd."

Similar presentations


Ads by Google