© 2003-2006 M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José.

Slides:



Advertisements
Similar presentations
Splash Screen.
Advertisements

Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
L8-S1 Datalog Queries 2003 SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San.
Chapter 4 Systems of Linear Equations; Matrices Section 6 Matrix Equations and Systems of Linear Equations.
Vocabulary and Properties. Determine the word or phrase described in each slide.
L3-5c-S1 Object Diagrams © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department,
© M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José.
1 9. Evaluation of Queries Query evaluation – Quantifier Elimination and Satisfiability Example: Logical Level: r   y 1,…y n  r’ Constraint.
1 2. Constraint Databases Next level of data abstraction: Constraint level – finitely represents by constraints the logical level.
L16-S1 Object Diagrams 2003 SJSU -- CmpE Software Patterns Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering.
L28-S1 Interaction Diagrams 2003 SJSU -- CmpE Advanced Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
© M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José.
L19-S1 More on Class Diagrams 2003 SJSU -- CmpE Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I.
L3-5d-S1 Class Diagrams © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
Sets 1.
Sets 1.
© M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José.
SJSU -- CmpE © Dr. M. E. Fayad Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San.
L5-S1 Class Diagrams 2003 SJSU -- CmpE Software Patterns Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San.
L8-S1 CRC Cards 2003 SJSU -- CmpE Advanced Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College.
© M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering.
© M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering.
L3-6b-S1 Sequence Diagrams © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
Absolute Value: A number’s distance from zero on a number line. A number’s absolute value is nonnegative.
Preview of Calculus.
Real Numbers and Their Properties รายวิชา ค ความรู้พื้นฐานสำหรับแคลคูลัส 1 ภาคเรียนที่ 1 ปีการศึกษา 2552.
1 Preliminaries Precalculus Review I Precalculus Review II
Math 3121 Abstract Algebra I Lecture 3 Sections 2-4: Binary Operations, Definition of Group.
Relations and Functions Another Foundational Concept Copyright © 2014 – Curt Hill.
1 ENM 503 Block 1 Algebraic Systems Lesson 4 – Algebraic Methods The Building Blocks - Numbers, Equations, Functions, and other interesting things. Did.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 5 Systems and Matrices Copyright © 2013, 2009, 2005 Pearson Education, Inc.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
P.1 Real Numbers. 2 What You Should Learn Represent and classify real numbers. Order real numbers and use inequalities. Find the absolute values of real.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
DISCRETE COMPUTATIONAL STRUCTURES
CompSci 102 Discrete Math for Computer Science
L8-2-S1 Misc Topics © M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of.
Introduction to Real Analysis Dr. Weihu Hong Clayton State University 8/19/2008.
Chapter P Prerequisites: Fundamental Concepts of Algebra 1 Copyright © 2014, 2010, 2007 Pearson Education, Inc. 1 P.1 Algebraic Expressions, Mathematical.
Fundamental Concepts of Algebra
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 9 Boolean Algebras and Combinatorial Circuits.
L6-S1 MLPQ 2003 SJSU -- CmpE-- M.E. Fayad Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
L1-S1 Infinite R-DB 2003 SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
Operations on Real Numbers
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Chapter 4 Systems of Linear Equations; Matrices
Equations Quadratic in form factorable equations
College Algebra Chapter 3 Polynomial and Rational Functions
5 Systems of Linear Equations and Matrices
Advanced Object-Oriented Analysis & Design
Database Design Dr. M.E. Fayad, Professor
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Component-Based & Software Reuse
Learning Resource Services
Software System Engineering
Object-Oriented Analysis & Design
Copyright © Cengage Learning. All rights reserved.
Database Design Dr. M.E. Fayad, Professor
College Algebra Chapter 3 Polynomial and Rational Functions
Inequalities Some problems in algebra lead to inequalities instead of equations. An inequality looks just like an equation, except that in the place of.
Equations Quadratic in form factorable equations
TBF Generall Mathematics - II Lecture – 8 : Linear Inequalities
Database Design Dr. M.E. Fayad, Professor
Find (x3 + 2x2 – 5x – 6) ÷ (x – 2) using synthetic division.
Database Design Dr. M.E. Fayad, Professor
Software System Engineering
Presentation transcript:

© M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State University One Washington Square San José, CA

L7-S2 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad 2 Lesson 07: Constraint Databases

L7-S3 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Lesson Objectives 3 Understand Constraint Databases Learn How to Deal with Constraints î Arithmetic Atomic Constraints î Boolean Atomic Constraints î Constraint Formulas î Interpretations of Free Boolean Constraints Understand the Constraint Data Model Explore Data Abstraction

L7-S4 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad  Are The highest level of data abstraction  Are not suitable for computer to represent data. Why?  Because the allow an infinite number of tuples or points.  In this lecture we discuss constraint data model that is used to represent the logical level of data in a concise way. 4 View and Logical Levels

L7-S5 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Next level of data abstraction: Constraint level – finitely represents by constraints the logical level 5 Constraint Databases

L7-S6 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad  Constraints apply to two or more variables.  Each variable takes its value from a domain  Common domains are: + The set of nonnegative numbers (or natural numbers) N + The set of integer numbers Z + The set of rational number Q + The set of real numbers R  Other domains – Set of English words in the dictionary W 6 Two Most Common Types of Constraints

L7-S7 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Assume u and v are variables or constants B and c i are constants Let ± denote + or - Let p be a polynomial function over variables X 1, …., X n Any valid expression with constants, variables, addition, and multiplication symbols We define the most basic type of constraints, called the atomic constraints over any of the domains N, Z, Q, R as following: 7 Constraints (1)

L7-S8 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Arithmetic Atomic Constraints Equality: u = v Inequality: u ≠ v Lower bound: u ≥ b Upper bound: – u ≥ b Order: u ≥ v Gap-order: u – v ≥ b where b ≥ 0 Difference: u – v ≥ b 8 Constraints (2)

L7-S9 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Half-Addition: ± u ± v ≥ b where b ≥ 0 Addition: ± u ± v ≥ b Linear: c 1 x 1 + ……+ c n x n ≥ b Polynomial: p( x 1,……..,x n ) ≥ b Note: Instead of ≥ we can also use > b is a bound which is restricted to be nonnegative in the case of gap-order and half addition constraints. c i is a coefficient in the linear constraint. 9 Constraints (3)

L7-S10 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad If a constraint C is any of these types of constraints and the domain of the variables is Z and Q we talk of integer C constraints or rational C constraints, respectively. We consider each = constraint as the conjunction of two ≥ constraints. For example: linear equation 5x+7y = 8 can be expressed as the conjunction of the linear inequality constraints: 5x +7y ≥ 8 and 5x +7y ≤ 8 This is why we do not consider linear equality as atomic constraints. Nevertheless, we will write constraints with = signs. 10 Constraints (4)

L7-S11 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Boolean Algebra D – domain, 0 – zero element, 1 – one element. such that the following axioms hold: 11 Boolean Atomic Constraints (1)

L7-S12 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Commutative: x V y = y V x x Λ y = y Λ x Distributive: x V ( y Λ z ) = ( x V y ) Λ ( x V z ) x Λ ( y V z ) = ( x Λ y ) V ( x Λ z ) Inverse: x V x’ = 1 x Λ x’ = 0 Zero and one element properties: x V 0 = x x Λ 1 = x 0 ≠ 1 12 Boolean Atomic Constraints (2)

L7-S13 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Boolean equality constraints: T = B 0 Boolean inequality constraints: T ≠ B 0 where T is a Boolean term built from domain elements and operations of the boolean algebra. Example: ( x’ Λ z ) V ( y Λ z ) V ( x Λ y’ Λ z’ ) = B 0 13 Boolean Atomic Constraints (3)

L7-S14 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad each atomic constraint if F and G are formulas, then (F and G) is a formula and (F or G) is a formula. if F is a formula, then (not F) is a formula. 14 Constraint Formulas (1)

L7-S15 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Let F(x 1,…,x n ) be a formula with n rows, t = (c 1,…,c n ) a tuple with n constants. t satisfies F (t F) – substituting each x i by c i makes F true. 15 Constraint Formulas (2)

L7-S16 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Symbols are interpreted to be concrete operators or values. Example: D – all subsets of 1 Λ – intersection V – union ‘ – complement 0 – emptyset 1 – set of names of all animals {cat, dog, parrot,…} Question: What would be the meaning of the example Boolean constraint under this interpretation ? 16 Interpretation of free Boolean algebra

L7-S17 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Example: Suppose we have the constraint b Λ m = 0 and we interpret b as {canary, parrot, falcon} m as {cat, dog} Question: Is the Boolean constraint true under this interpretation ? 17 Constants in constraints are also interpreted

L7-S18 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Constraint data model provides a finite representation of the infinite relational data model. In constraint data model each attribute is associated with an attribute variable, and the value of the attributes in a relation is specified implicitly using constraints. A constraint database is a finite set of constraint relations. A constraint relation is a finite set of constraint tuples, –Where each constraint tuple is a conjunction of atomic constraints using the same set of attribute variables. 18 The Constraint Data Model (1)

L7-S19 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Constraint relation – a finite set of constraint tuples. Constraint tuples – tuples with variables and constraints that restrict the variables. Example: ( i, t : 0 ≤ i, i ≤ 24000, t = 0.15 i ) is a constraint tuple of Taxtable(Income, Tax). It means that the tax is 15% on any income below $24, The Constraint Data Model (2)

L7-S20 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad 20 The Constraint Data Model (3) IncomeTax it 0 ≤ i, i ≤ 24000, t = 0.15 i it < i, i ≤ 58150, t = (i – 24000) it < i, i ≤ t = (i – 58150) it < i, i ≤ , t = (i – ) it < i, t = (i – ) Taxtable

L7-S21 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad The taxtable constraint relation consists of only five contraint tuples. It represents the infinite relation that we described early. The constraints in the table are order constraints and linear equations over the rational numbers. 21 The Constraint Data Model (4)

L7-S22 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad The Go relation can be presented by the following constraint relation. Assumption: If the shortest path from city1 to city2 is some m minutes, then if we leave city1 at time t1 we may arrive at city2 at some time t2, such that 22 The Constraint Data Model (5) t2 – t1 ≥ m

L7-S23 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad 23 The Constraint Data Model (6) Go City 1time1City 2Time2 Omahat1Lincolnt2t2 – t1 ≥ 60 Omahat1Mplst2t2 – t1 ≥ 650 Omahat1De_Moinest2t2 – t1 ≥ 400 Mplst1Chicagot2t2 – t1 ≥ 370 De_Moinest1Chicagot2t2 – t1 ≥ 600 De_Moinest1Kansas_Cityt2t2 – t1 ≥ 180

L7-S24 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad In Go, we represent each connection between two cities by two constraint tuples. 24 The Constraint Data Model (7)

L7-S25 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad 25 The Constraint Data Model (8) RadioXY 1xy(x – 8) 2 + (y – 9) 2 ≤ 25 2xy(x – 8) 2 / (y – 3) 2 /3 2 ≤ 1 3xy(y – 1) ≥ (x – 3) 2, y ≤ 10 The first radio station broadcasts within a circle with center at location (8, 9) The second in an elliptic area The third in a parabolic area is cut off by a line. The broadcast relation can be expressed as a constraint relation with Quadratic constraints over the real number.

L7-S26 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad The data can be represented in the Crops relation using linear inequality constraints over rational numbers. 26 The Constraint Data Model (9) CornRyeSunflowerWheat x1x2x3x4 15x 1 + 8x x x 4 ≤ x x 2 + 5x x 4 ≤ 8000

L7-S27 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Each data model provides some abstraction about stored data. There are four levels of data abstraction, namely –View level –Logical level –Constraint Level –Physical level The various levels of data abstraction are linked by translation methods. 27 Data Abstraction (1)

L7-S28 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad  How users can view their data  For different sets of users different views can be provided by a database  We will see more examples of visualization used in the MLPQ and PReSTO constarint databases systems in chapter 18 and Data Abstraction: View Level

L7-S29 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad  Logical level – infinite relation r, tuple t  Describes what data are stored in terms of sets of infinite relations.  Discussed in Chapter 1 29 Data Abstraction: Logical Level

L7-S30 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad  Describes the data stored using one or more constraint relations.  There is a natural link between the logical and constraint levels. Let r be the infinite relational model and R be the constraint model of a relation. Then a tuple t is in r iff there is a constraint tuple C in R such that after substitution of the constants in t into the variables of C, we get a true formula, that is t satisfies C.  Constraint level – finite relation R, constraint tuple C, t є r iff t ╞ C for some C є R 30 Data Abstraction: Constraint Level

L7-S31 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad  Physical level – the way the data is actually stored in the computer system  We will see example of this in Chapter Data Abstraction: Physical Level

L7-S32 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad T/F Constraint data model is used to represent the logical level of data in a concise way. Logical level is not suitable for computer to represent data. View view is suitable for computer to represent data. Constraint level describes the data stored using one or more constraint relations. Physical level corresponds to the way the data is actually stored in computer system 32 Discussion Questions

L7-S33 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Exercise 2.1 Represent the Constraint relation Free in a relational form assuming that d is an integer. 33 Discussion Questions PersonDay Andrewd3 ≤ d, d ≤ 6 Andrewd16 ≤ d, d ≤ 26 Barbarad6 ≤ d, d ≤ 18 Barbarad25 ≤ d, d ≤ 30

L7-S34 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad 34 Solution PersonFree Andrew 3, 4, 5, 6 Andrew16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 Barbara6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 Barbara25, 26, 27, 28, 29, 30

L7-S35 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Exercise 2.3 Using a constraint relation represent the street map shown in Figure 1.3 As following 35 Discussion Questions

L7-S36 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad 36 Solution NameXY Willowx yy=19, x =4 Harexy y=-2x+29, y>=11, y<=20 Bearxyy=1/3 *x /3, 2<=x, x<=17 Vinexyx=5, y>=2, y<=14 Oakxyx=11, y>=2, y<=12 Maplexyy=5, x =7

L7-S37 Constraint DB © M.E. Fayad SJSU – CmpE M.E. Fayad Relational Algebra SQL 37 Questions for the Next Lecture