CS 405G Introduction to Database Systems Lecture 2: Discrete Maths for Database Instructor: Chen Qian Propositions The symbol ∧, called conjunction, and the symbol ∨, called disjunction, are binary connectives, because each of them is used to form a compound proposition from two propositions. We may call ∧ as “and”, ∨ as “or”. Truth table: 7/1/2016 Chen Qian Univ. of Kentucky 2 Implication Implication The binary propositional connective → is called implication. It represents the combination “if . . . then.” For instance, the assertion “the cube of any positive number is positive also” can be written as Is this formula true or false? False, e.g, x=6 is a counter example 7/1/2016 Chen Qian Univ. of Kentucky 3 Truth table of implication Is this proposition true or false? “Penguins live in Arctic → KY is a province of Canada” It is true! “Penguins live in Arctic → KY is a state of the USA” Still true! 7/1/2016 Chen Qian Univ. of Kentucky 4 Sets A set is a collection of objects. We write x ∈ A if object x is an element of set A, and x A otherwise. When we specify which objects belong to a set, this defines the set completely; there is no such thing as the order of elements in a set or the number of repetitions of an element in a set. For instance, If C is a condition, then by {x : C} we denote the set of all objects x satisfying this condition. For instance, 7/1/2016 Chen Qian Univ. of Kentucky 5 Cardinality If a set A is finite then the number of elements of A is also called the cardinality of A and denoted by |A|. What is the cardinality of the student set of this class? What is the cardinality of the set of exam scores of this class? 55 < 55 Cardinality of the natural numbers? 7/1/2016 Chen Qian Univ. of Kentucky 6 Subset We say that a set A is a subset of a set B, and write A ⊆ B, if every element of A is an element of B. For instance, 7/1/2016 Chen Qian Univ. of Kentucky 7 Operations on Sets 1. For any sets A and B, by A ∪ B we denote the set {x : x ∈ A ∨ x ∈ B}, called the union of A and B. 2. By A ∩ B we denote the set {x : x ∈ A ∧ x ∈ B}, called the intersection of A and B. 7/1/2016 Chen Qian Univ. of Kentucky 8 Operations on Sets By A - B we denote the set {x : x ∈ A ∧ x the difference of A and B. B}, called For instance, {2, 3} - {3, 5} = ? {2} The Cartesian product of sets A and B is the set of ordered pairs <x, y> such that x ∈ A and y ∈ B: For instance, 7/1/2016 Chen Qian Univ. of Kentucky 9 Power set By we denote the power set of a set A, that is, the set of all subsets of A: For instance 7/1/2016 Chen Qian Univ. of Kentucky 10 Relation Any condition on a pair of elements of a set A defines a binary relation, or simply relation, on A. A relation R can be characterized by the set of all ordered pairs <x, y> such that xRy For instance, we can say that the relation < on the set {1, 2, 3, 4} is the set 7/1/2016 Chen Qian Univ. of Kentucky 11 Relation A relation R on a set A is said to be reflexive if, for all elements x of A, xRx. We say that R is irreflexive if there is no element x of A such that xRx. Are they reflexive or irreflexive? =, ≤, < A relation R on a set A is said to be symmetric if, for all x, y ∈ A, xRy implies yRx. Are they symmetric? 7/1/2016 =, ≤, < Chen Qian Univ. of Kentucky 12 Relation A relation R on a set A is said to be transitive if, for all x, y, z ∈ A, xRy and yRz imply xRz. Are they transitive? =, <, ≤, 7/1/2016 Chen Qian Univ. of Kentucky 13 Exercise 7/1/2016 Chen Qian Univ. of Kentucky 14 7/1/2016 Chen Qian Univ. of Kentucky 15 7/1/2016 Chen Qian Univ. of Kentucky 16 Consider the relation x = 2y + 1 between real numbers x, y. Is it reflexive? Is it symmetric? Is it transitive? This relation is not reflexive, because the condition 1R1 does not hold. This relation is not symmetric, because the condition 1R3 holds, but the condition 3R1 doesn’t. This relation is not transitive, because the conditions 1R3 and 3R7 hold, but the condition 1R7 doesn’t. 7/1/2016 Chen Qian Univ. of Kentucky 17 Summary Propositions Sets Operations on sets Relations Next class: ER model 7/1/2016 Chen Qian Univ. of Kentucky 18 Credit Some slides are made from the lecture notes of Prof. Vladimir Lifschitz. 7/1/2016 Chen Qian Univ. of Kentucky 19