Download presentation
Presentation is loading. Please wait.
Published byEaster Welch Modified over 8 years ago
1
CS 3630 Database Design and Implementation
2
2 Set Theory Foundation of Relational Database Systems E.F. Codd
3
3 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
4
4 Examples All UWP students in CS363 this semester A = {UWP students in CS363 this semester} B = {All UWP students who play Bridge} –Specifying the conditions of the elements in the set C = {1, 2, 3, 4} –Listing all elements I = {i: i is an integer}
5
5 Number of Elements of a Set A = {UWP students in CS363 this semester} 50 B = {All UWP students who play Bridge} ? C = {1, 2, 3, 4} 4 I = {i: i is an integer} ?
6
6 Cardinality C = {1, 2, 3, 4} |C| = 4 A = {UWP students in CS363 this semester} |A| = 50 I = {i: i is an integer} |I| = (Number of elements of finite sets)
7
7 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
8
8 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: { } It’s a set with one element and the only element is an empty set
9
9 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)
10
10 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) They are the same: and
11
11 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
12
12 Subsets For any set X, X No element e such that e and e X
13
13 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
14
14 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}, {}}
15
15 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}, }
16
16 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|
17
17 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
18
18 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.
19
19 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|
20
20 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|)
21
21 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|?
22
22 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|
23
23 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)}
24
24 Assignment 1 Due Friday (week 2), January 29 at noon Download a copy of the assignment and re-name it as UserName_A1.doc(x) For example, YangQ_A1.doc Complete the assignment and drop it to K:\Courses\CSSE\yangq\CS3630\DropBox
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.