Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3630 Database Design and Implementation

Similar presentations


Presentation on theme: "CS 3630 Database Design and Implementation"— Presentation transcript:

1 CS 3630 Database Design and Implementation

2 Foundation of Relational Database Systems
Set Theory Foundation of Relational Database Systems E.F. Codd 40 minutes for S1 50 minutes for S2

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 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 Number of Elements of a Set
A = {UWP students in CS363 this semester} 56 B = {All UWP students who play Bridge} ? C = {1, 2, 3, 4} 4 I = {i: i is an integer}

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

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 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 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 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 < B or B > A) A could be the same as B A  B or B  A (similar to A <= B or B >= A) They are the same:  and 

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 Subsets For any set X,   X No element e such that e   and e  X

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 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 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}, {}} }

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 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)| = 24 = 16

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

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

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

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

22 A  B = {(a, b): a  A and b  B}
Cartesian Product A  B = {(a, b): a  A and b  B} A = {1, 2, 3, 4} B = {2, 5} = {(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 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 Assignment 1 Due Wednesday (week 2), February 1 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\1DropBox


Download ppt "CS 3630 Database Design and Implementation"

Similar presentations


Ads by Google