Professional Documents
Culture Documents
CIS3530L02
CIS3530L02
& Concepts
CIS3530
L02
Topics to be covered
Outline
Intro to dBs – Mathematical Background
Data Modeling Using ER-Mod
Constraints
Relational Algebra & Relational Calculus
Structured Query Language
Optimization
Concurrency Control and Recovery
Object & Object-Relational Databases
Database Security, Adv. Modeling & Distribution
2
Outline
Set Theory
– Set Operations
Functions & Relations
Propositional Logic
– Atoms & Formulas
– Interpretation of Formulas
– Normal Forms
First-Order Logic
Graph Theory
– Undirected & Directed Graphs
3
Set Theory
Definition: Well-defined collection of distinct
objects
Members (or Elements): part of the collection.
Roster Method: Description of a set by listing the
elements, enclosed with braces.
– Examples:
• Vowels = {a,e,i,o,u}
• Primary colors = {red, blue, yellow}
Membership examples
– “a belongs to the set of Vowels” is written as:
a ∈ Vowels
– “j does not belong to the set of Vowels: j ∉ Vowels
4
Sets
Set-builder method
– A = {x|x ∈ S, P(x)} ˅ A = {x ∈ S| P(x) }
• A is the set of all elements x of S, such
that x satisfies the property P
• Example:
– If X = {2,4,6,8,10}, then in set-builder
notation, X can be described as
– X = {n ∈ N | n is even and n ≤ 10}
5
Sets
Standard Symbols which denote sets of numbers
– N : The set of all natural numbers (i.e.,all positive integers)
– Z : The set of all integers
– Z* : The set of all nonzero integers
– E : The set of all even integers
– Q : The set of all rational numbers
– Q* : The set of all nonzero rational numbers
– Q+ : The set of all positive rational numbers
– R : The set of all real numbers
– R* : The set of all nonzero real numbers
– R+ : The set of all positive real numbers
– C : The set of all complex numbers
6
– C* : The set of all nonzero complex numbers
Sets
Subsets
– “X is a subset of Y” is written as X ⊆ Y
– “X is not a subset of Y” is written as X ⊆ Y
– Example:
• X = {a,e,i,o,u}, Y = {a, i, u}
and Z = {b,c,d,f,g}
– Y ⊆ X, since every element of Y is an element of X
– Y ⊆ Z, since a ∈ Y, but a ∉ Z
7
Sets
Set Equality
– X and Y are sets. They are said to be equal if every
element of X is an element of Y and every element of
Y is an element of X, i.e. X ⊆ Y and Y ⊆ X
– Examples:
• {1,2,3} = {2,3,1}
• Let X = {red, blue, yellow} and Y = {c | c is a primary color}
Then X=Y
Empty (Null) Set
– A Set is Empty (Null) if it contains no elements.
– The Empty Set is written as ∅
– The Empty Set is a subset of every set
8
Sets
Cardinality of Sets
– Let S be a finite set with n distinct elements, where n ≥ 0.
Then |S| = n , where the cardinality (number of elements)
of S is n
– Example:
• If P = {red, blue, yellow}, then |P| = 3
Power Set
– For any set X ,the power set of X ,written P(X),is the
set of all subsets of X
– Example:
• If X = {1,2}, then P(X) = { ∅ , {1}, {2}, {1,2}}
9
Set Operations
Union of Sets
Example:
If X = {1,2,3,4,5} and Y = {5,6,7,8,9}, then
X∪Y = {1,2,3,4,5,6,7,8,9}
Set Operations
Intersection of Sets
Example:
If X = {1,2,3,4,5} and Y = {5,6,7,8,9}, then X ∩ Y = {5}
Set Operations
Difference
• Example:
Let X = {a, b, c, d} and
Y = {c, d, e, f},
then X – Y = {a,b}
and Y – X = {e,f}
Set Operations
Ordered Pair
– X and Y are sets. If x ∈ X and y ∈ Y, then an ordered pair
is written (x,y)
– Order of elements is important. (x,y) is not necessarily
equal to (y,x)
Cartesian Product
– The Cartesian product of two sets X and Y ,written X × Y,
is the set
– X × Y ={(x,y)|x ∈ X , y ∈ Y}
• For any set X, X × ∅ = ∅ = ∅ × X
– Example:
• X = {a,b}, Y = {c,d}
– X × Y = {(a,c), (a,d), (b,c), (b,d)}
– Y × X = {(c,a), (d,a), (c,b), (d,b)} 13
Hands On Exercises
1. Draw a Venn Diagram to illustrate the
following relation on sets: (A ∪ B )∩ (C − B )
14
Set Identity Laws
Name Identity
1. Idempotent (a) A∪A=A
(b) A∩A=A
2. Commutative (a) A∪B=B∪A
(b) A∩B=B∩A
3. Associative (a) (A ∪ B) ∪ C = A ∪ (B ∪ C)
(b) (A ∩ B) ∩ C = A ∩ (B ∩ C)
4. Distributive (a) A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
(b) A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩C)
Set Identity Laws
Name Identity
5. Identity (a) A∪∅=A (c) A∩∅=∅
(b) A∩A=A (d) A∩A=A
6. Complement (a) A ∪ A' = ξ (c) ξ' = ∅
(b) A ∩ A' = ∅ (d) ∅' = ξ
7. DeMorgan’s (a) (A ∪ B)' = A' ∩ B'
(b) (A ∩ B)' = A' ∪ B'
8. Absorption (a) A ∪ (A ∩ B) = A
(b) A ∩ (A ∪ B) = A
9. Set Difference (a) A - B = A ∩ B'
Hands On Exercises
2. Use set Identities to simplify the expression:
((A ∪ B )∩ (A ∪ C ))∩ (A ∪ B )
17
Hands On Exercises
3. Use set Identities to simplify the expression:
( A ∪ B ) ∩ ( ( A ∩ B ) ∪ B' )
18
Hand On Exercises
a. element of 2S.
b. subset of 2S.
c. both element of and subset of 2S.
d. None of the above. 19
Ex 1: In the ICT Dept at GCUC there are 40
students in the first year. The students in the school
take Discrete Math, S/W Engineering, and
Programming in C. These courses for simplicity
are called DM, SE, and C respectively. We have
been provided with the following information:
7 take none of the courses
16 take Software Engineering
10 take Programming in C
5 take Discrete Math and Software Engineering
4 take Discrete Math and Programming in C
3 take Software Engineering and Programming in C
2 take Discrete Math, Software Engineering, and
Programming in C.
Ass”For the expressions in Questions 10 to 12, use the
following Information:
In CIS Program at GCUC there are 40 students in the first year.
The students in the Program take Discrete Math, Software
Engineering, and Programming in C. We have been provided
with the following information:
5 take none of the courses
16 take Discrete Math
22 take Programming in C
10 take Discrete Math and Software Engineering
13 take Discrete Math and Programming in C
15 take Software Engineering and Programming in C
9 take Discrete Math, Software Engineering, and 21
Programming in C.
10. How many students take Software Engineering?
(a) 10 (b) 18 (c) 22 (d) 26
(e) None of the Above
n-ary relation
– An n-ary relation on X 1 , X 2 ,..., X nis
a subset of X 1 ⋅ X 2 ⋅...⋅ X n
24
Example: Scissors-Paper-Stone Game
SPS = {Scissors, Paper, Stone}
Scissors F T F
Paper F F T
Stone T F F
26
Propositional Logic
Σ = {∧, ∨, ¬, (, ), ∀, ∃, x, R1, …, Rk}
Ri – denotes relations.
A formula is a well-formed string over Σ.
A string of the form Ri(x1,…, xj) is an atomic formula. j is
the arity of the relation symbol Ri.
Thus φ is formula if it
1. is an atomic formula.
2. has the form φ1 ∨ φ2, φ1 ∧ φ2 , ¬φ1, where φ1 and φ2
are formulas,
3. has the form ∃xj[φ1], or ∀xj[φ1], where φ1 is a formula.
27
Quantifiers
Two different roles for variables:
Recall from high-school algebra:
(x + y)(x - y) = x2 - y2 x2 -7x + 12 = 0
Universal statement: Existential statement:
(∀x,y)[(x + y)(x - y) = x2 - y2] (∃x)[x2 -7x + 12 = 0]
Example:
A B
D C
30
Write the previous graph as a symmetric
binary matrix.
A B
A B C D
A
B D C
C
D
31
Directed Graphs
Directed graph (V, E) - single directed edges between vertices
A B
D C
32
Directed Graphs
Directed graph (V, E) - single directed edges between vertices
A B
A B C D
A
B D C
C
D
33
If G is a directed graph or digraph then the
elements of E are ordered pairs of vertices, i.e.
E is a subset of V × V .
Therefore, the edge (u,v) is not the same as
(v,u) unless u = v.
An edge is said to be from u to v.
An edge that joins a vertex to itself is called a
self-loop or loop
34
Nondirected Graph Directed Graph
V = {v1, v2, v3, v4} V = {v1, v2, v3, v4}
E = { {v1, v2},{v1, v3}, E = {{v1, v3},{v3, v4},
{v2, v3},{v3, v4}} {v4, v3},{v4, v2}}
v1 v2 v1 v2
v3 v4
v4 v3