Database Design Dr. M.E. Fayad, Professor

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 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.
© 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 Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José.
© 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.
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.
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.
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.
Fundamental Concepts of Algebra
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.
Chapter 2 Functions and Graphs
3.3 Dividing Polynomials.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Chapter 4 Systems of Linear Equations; Matrices
Splash Screen.
Equations Quadratic in form factorable equations
College Algebra Chapter 3 Polynomial and Rational Functions
Solving Compound Inequalities
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.
CALCULUS AND ANALYTIC GEOMETRY CS 001 LECTURE 02.
Copyright © Cengage Learning. All rights reserved.
Discrete Structure II: Introduction
CS100: Discrete structures
Splash Screen.
Component-Based & Software Reuse
Learning Resource Services
Software System Engineering
Object-Oriented Analysis & Design
Precalculus Mathematics for Calculus Fifth Edition
Splash Screen.
Copyright © Cengage Learning. All rights reserved.
Chapter 7 Logic, Sets, and Counting
Systems of Linear Equations and Matrices
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
Object-Oriented Analysis & Design
Presentation transcript:

Database Design Dr. M.E. Fayad, Professor 5/1/2019 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 95192-0180 http://www.engr.sjsu.edu/~fayad © 2003-2006 M.E. Fayad SJSU -- CmpE

Lesson 11: Constraint Databases 5/1/2019 Lesson 11: Constraint Databases 2 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

3 Lesson Objectives Understand Constraint Databases 5/1/2019 Lesson Objectives 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 3 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

View and Logical Levels 5/1/2019 View and Logical Levels 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

5 Constraint Databases Next level of data abstraction: 5/1/2019 Constraint Databases Next level of data abstraction: Constraint level – finitely represents by constraints the logical level 5 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Two Most Common Types of Constraints 5/1/2019 Two Most Common Types of Constraints 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

7 Constraints (1) Assume u and v are variables or constants 5/1/2019 Constraints (1) Assume u and v are variables or constants B and ci are constants Let ± denote + or - Let p be a polynomial function over variables X1, …., Xn 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

8 Constraints (2) Arithmetic Atomic Constraints Inequality: u ≠ v 5/1/2019 Constraints (2) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

9 Constraints (3) Half-Addition: ± u ± v ≥ b where b ≥ 0 5/1/2019 Constraints (3) Half-Addition: ± u ± v ≥ b where b ≥ 0 Addition: ± u ± v ≥ b Linear: c1x1 + ……+ cnxn ≥ b Polynomial: p( x1,……..,xn ) ≥ 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. ci is a coefficient in the linear constraint. 9 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

5/1/2019 Constraints (4) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Boolean Atomic Constraints (1) 5/1/2019 Boolean Atomic Constraints (1) Boolean Algebra < D, Λ, V, ‘, 0, 1 > D – domain, 0 – zero element, 1 – one element. such that the following axioms hold: 11 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Boolean Atomic Constraints (2) 5/1/2019 Boolean Atomic Constraints (2) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Boolean Atomic Constraints (3) 5/1/2019 Boolean Atomic Constraints (3) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Constraint Formulas (1) 5/1/2019 Constraint Formulas (1) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Constraint Formulas (2) 5/1/2019 Constraint Formulas (2) Let F(x1,…,xn) be a formula with n rows, t = (c1,…,cn) a tuple with n constants. t satisfies F (t F) – substituting each xi by ci makes F true. 15 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Interpretation of free Boolean algebra 5/1/2019 Interpretation of free Boolean algebra 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Constants in constraints are also interpreted 5/1/2019 Constants in constraints are also interpreted 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (1) 5/1/2019 The Constraint Data Model (1) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (2) 5/1/2019 The Constraint Data Model (2) 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,000. 19 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (3) 5/1/2019 The Constraint Data Model (3) Income Tax i t 0 ≤ i , i ≤ 24000, t = 0.15 i 24000 < i , i ≤ 58150, t = 3600 + 0.28 (i – 24000) 58150 < i , i ≤ 121300 t = 13162 + 0.31(i – 58150) 121300 < i , i ≤ 263750, t = 32738.5 + 0.36 (i – 121300) 263750 < i , t = 84020.5 + 0.396 (i – 263750) 20 Taxtable © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (4) 5/1/2019 The Constraint Data Model (4) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (5) 5/1/2019 The Constraint Data Model (5) 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 t2 – t1 ≥ m 22 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (6) 5/1/2019 The Constraint Data Model (6) City 1 time1 City 2 Time2 Omaha t1 Lincoln t2 t2 – t1 ≥ 60 Mpls t2 – t1 ≥ 650 De_Moines t2 – t1 ≥ 400 Chicago t2 – t1 ≥ 370 t2 – t1 ≥ 600 Kansas_City t2 – t1 ≥ 180 23 Go © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (7) 5/1/2019 The Constraint Data Model (7) In Go, we represent each connection between two cities by two constraint tuples. 24 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (8) 5/1/2019 The Constraint Data Model (8) Radio X Y 1 x y (x – 8)2 + (y – 9)2 ≤ 25 2 (x – 8)2 / 52 + (y – 3)2/32 ≤ 1 3 (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. 25 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

The Constraint Data Model (9) 5/1/2019 The Constraint Data Model (9) Corn Rye Sunflower Wheat x1 x2 x3 x4 15x1 + 8x2 + 10x3 + 15x4 ≤ 3000 30x1 + 25x2 + 5x3 + 10x4 ≤ 8000 The data can be represented in the Crops relation using linear inequality constraints over rational numbers. 26 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

5/1/2019 Data Abstraction (1) 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Data Abstraction: View Level 5/1/2019 Data Abstraction: View Level 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 20. 28 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Data Abstraction: Logical Level 5/1/2019 Data Abstraction: Logical Level Logical level – infinite relation r, tuple t Describes what data are stored in terms of sets of infinite relations. Discussed in Chapter 1 29 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Data Abstraction: Constraint Level 5/1/2019 Data Abstraction: Constraint Level 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Data Abstraction: Physical Level 5/1/2019 Data Abstraction: Physical Level Physical level – the way the data is actually stored in the computer system We will see example of this in Chapter 17 31 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

32 Discussion Questions T/F 5/1/2019 Discussion Questions 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 level 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 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

5/1/2019 Discussion Questions Exercise 2.1 Represent the Constraint relation Free in a relational form assuming that d is an integer. Person Day Andrew d 3 ≤ d, d ≤ 6 16 ≤ d, d ≤ 26 Barbara 6 ≤ d, d ≤ 18 25 ≤ d, d ≤ 30 33 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

34 Solution Person Free Andrew 3, 4, 5, 6 5/1/2019 Solution Person Free Andrew 3, 4, 5, 6 Andrew 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 Barbara 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 Barbara 25, 26, 27, 28, 29, 30 34 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

5/1/2019 Discussion Questions Exercise 2.3 Using a constraint relation represent the street map shown in Figure 1.3 As following 35 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

36 Solution Name X Y Willow x y y=19, x<=20, x>=4 Hare x y 5/1/2019 Name X Y   Willow x y y=19, x<=20, x>=4 Hare x y y=-2x+29, y>=11, y<=20 Bear x y y=1/3 *x + 10 1/3, 2<=x, x<=17 Vine x y x=5, y>=2, y<=14 Oak x y x=11, y>=2, y<=12 36 Maple x y y=5, x<=20, x>=7   © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad

Questions for the Next Lecture 5/1/2019 Questions for the Next Lecture Relational Algebra SQL 37 © 2003-2006 M.E. Fayad SJSU – CmpE M.E. Fayad