ICOM 5016 - Introduction To Database Systems
ICOM 5016 - Introduction To Database Systems
Database Systems
Lecture 2
Dr. Manuel Rodriguez
Department of Electrical and Computer Engineering
University of Puerto Rico, Mayagez
Silberschatz, Korth and Sudarshan 2.2 Database System Concepts
Objectives
Introduce Set Theory
Describe Entity Relationship Model (E-R) Model
Entity Sets
Relationship Sets
Design Issues
Mapping Constraints
Keys
E-R Diagram
Extended E-R Features
Design of an E-R Database Schema
Reduction of an E-R Schema to Tables
Silberschatz, Korth and Sudarshan 2.3 Database System Concepts
On Sets and Relations
A set S is a collection of objects, where there are no
duplicates
Examples
A = {a, b, c}
B = {0, 2, 4, 6, 8}
C = {Jose, Pedro, Ana, Luis}
The objects that are part of a set S are called the
elements of the set.
Notation:
0 is an element of set B is written as 0 e B.
3 is not an element of set B is written as 3 e B.
Silberschatz, Korth and Sudarshan 2.4 Database System Concepts
Cardinality of Sets
Sets might have
0 elements called the empty set C.
1 elements called a singleton
N elements a set of N elements (called a finite set)
Ex: S = {car, plane, bike}
elements an infinite number of elements (called infinite
set)
Integers, Real,
Even numbers: E = {0, 2, 4, 6, 8, 10, }
Dot notation means infinite number of elements
The cardinality of a set is its number of elements
Notation: cardinality of S is denoted by |S|
Could be an integer number or infinity symbol .
Silberschatz, Korth and Sudarshan 2.5 Database System Concepts
Cardinality of Sets (cont.)
Some examples:
A = {a,b,c}
|A| = 3
R set of real numbers
|R| =
E = {0, 2, 3, 4, 6, 8, 10, }
|E| =
C the empty set
| C | = 0
Silberschatz, Korth and Sudarshan 2.6 Database System Concepts
Set notations and equality of Sets
Enumeration of elements of set S
A = {a,b c}
E = {0, 2, 4, 6, 8, 10, }
Enumeration of the properties of the elements in S
E = {x : x is an even integer}
E = {x: x e I and x/2=0, where I is the set of integers.}
Two sets are said to be equal if and if only they both
have the same elements
A = {a, b, c}, B = {a, b, c}, then A = B
if C = {a, b, c, d}, then A =C
Because d e A
Silberschatz, Korth and Sudarshan 2.7 Database System Concepts
Sets and Subsets
Let A and B be two sets. B is said to be a subsets of A
if and only if every member x of B is also a member of
A
Notation: B _ A
Examples:
A = {1, 2, 3, 4, 5, 6}, B = {1, 2}, then B _ A
D = {a, e, i, o, u}, F = {a, e, i, o, u}, then F _ D
If B is a subset of A, and B =A, then we call B a proper subset
Notation: B c A
A = {1, 2, 3, 4, 5, 6}, B = {1, 2}, then B c A
The empty set C is a subset of every set, including itself
C _ A, for every set A
If B is not a subset of A, then we write B . A
Silberschatz, Korth and Sudarshan 2.8 Database System Concepts
Set Union
Let A and B be two sets. Then, the union of A and B,
denoted by A B is the set of all elements x such that
either x e A or x e B.
A B = {x: x eA or x e B}
Examples:
A = {10, 20 , 30, 40, 100}, B = {1,2 , 10, 20} then A B =
{1, 2, 10, 20, 30, 40, 100}
C = {Tom, Bob, Pete}, then C C = C
For every set A, A A = A
Silberschatz, Korth and Sudarshan 2.9 Database System Concepts
Set Intersection
Let A and B be two sets. Then, the intersection of A and B,
denoted by A B is the set of all elements x such that x e A and
x e B.
A B = {x: x eA and x e B}
Examples:
A = {10, 20 , 30, 40, 100}, B = {1,2 , 10, 20} then A B = {10, 20}
Y = {red, blue, green, black}, X = {black, white}, then Y X = {black}
E = {1, 2, 3}, M={a, b} then, E M = C
C = {Tom, Bob, Pete}, then C C = C
For every set A, A A = A
Sets A and B disjoint if and only if A B = C
They have nothing in common
Silberschatz, Korth and Sudarshan 2.10 Database System Concepts
Set Difference
Let A and B be two sets. Then, the difference
between A and B, denoted by A - B is the set of all
elements x such that x e A and x e B.
A - B = {x: x eA and x e B}
Examples:
A = {10, 20 , 30, 40, 100}, B = {1,2 , 10, 20} then A - B = {30,
40, 100}
Y = {red, blue, green, black}, X = {black, white}, then Y - X =
{red, blue, green}
E = {1, 2, 3}, M={a, b} then, E - M = E
C = {Tom, Bob, Pete}, then C - C = C
For every set A, A - A = C
Silberschatz, Korth and Sudarshan 2.11 Database System Concepts
Power Set and Partitions
Power Set: Given a set A, then the set of all possible
subsets of A is called the power set of A.
Notation:
Example:
A = {a, b, 1} then = {C, {a}, {b}, {1}, {a,b}, {a,1},
{b,1}, {a,b,1}}
Note: empty set is a subset of every set.
Partition: A partition [ of a nonempty set A is a
subset of such that
Each set element P e [ is not empty
For D, F e [, D = F, it holds that D F = C
The union of all P e [ is equal to A.
Example: A = {a, b, c}, then [= {{a,b}, {c}}. Also [ = {{a}, {b},
{c}}. But this is not: M = {{a, b}, {b}, {c}}
A
2
A
2
A
2
Silberschatz, Korth and Sudarshan 2.12 Database System Concepts
Cartesian Products and Relations
Cartesian product: Given two sets A and B, the
Cartesian product between and A and, denoted by A
x B, is the set of all ordered pairs (a,b) such a e A
and b e B.
Formally: A x B = {(a,b): a e A and b e B}
Example: A = {1, 2}, B = {a, b}, then A x B = {(1,a), (1,b),
(2,a), (2,b)}.
A binary relation R on two sets A and B is a subset of
A x B.
Example: A = {1, 2}, B = {a, b}, then A x B = {(1,a), (1,b),
(2,a), (2,b)}, and one possible R _ A x B = {(1,a), (2,a)}
Silberschatz, Korth and Sudarshan 2.13 Database System Concepts
N-ary Relations
Let A1, A2, , An be n sets, not necessarily distinct,
then an n-ary relation R on A1, A2, , An is a sub-set
of A1 x A2 x x An.
Formally: R _ A1 x A2 x x An
R = {(a1, a2, ,an) : a1 e A1 and a2 e A2 and and an e
An}
Example:
R = set of all real numbers
R x R x R = three-dimensional space
P = {(x, y, z): x eR and x > 0 and y eR and y > 0 and y
eR and y > 0} = Set of all three-dimensional points that
have positive coordinates