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

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

Jan 14, 2016

Download

Documents

Mary Bishop
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Set Theory Foundation of Relational Database Systems E.F. Codd.

1

Set Theory

Foundation of Relational Database Systems

E.F. Codd

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

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

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

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

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

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

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

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: {}

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

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)

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

7

Subsets

For two sets A and B and any element x,if x A then x B

Then A is a subset of BA 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)

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

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 BThere is an element x such that

x A and x B

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

9

Subsets (II)

For any set X,

X

No element e such that

e and e X

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

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

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

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)

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

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

{}}

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

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

}

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

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|

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

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

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

16

Example II

X = {x0, x1, x2, x3, x4, x5, x6, x7} |X| = 8 |P(X)| = 28

x0 x1 x2 x3 x4 x5 x6 x7 1 0 0 1 1 0 0 0

The same as a byte with 8 bits.

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

17

Set Operations

Set UnionA 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|

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

18

Set IntersectionA 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|)

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

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 - AB – A = {5}

Range of |A – B|?

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

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|

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

21

Cartesian Product (II) Multiple sets A1, A2, A3, …, AnA1 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)}

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

22

Assignment 1

Due Wednesday, January 30At beginning of classType your work and submit a hard copy.