Problem Solving with Constraints CSPs and Relational DBs1 Problem Solving with Constraints CSCE496/896, Fall 2011 www.cse.unl.edu/~choueiry/F11-496-896/

Slides:



Advertisements
Similar presentations
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Advertisements

Relational Algebra Dashiell Fryer. What is Relational Algebra? Relational algebra is a procedural query language. Relational algebra is a procedural query.
Foundations of Constraint Processing More on Constraint Consistency 1 Foundations of Constraint Processing CSCE421/821, Spring
Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra.
CS4432: Database Systems II Query Operator & Algebraic Expressions 1.
1 Relational Algebra & Calculus. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
Problem Solving with Constraints, Fall 2011 Odds and Ends: Modeling Examples & Graphical Representations 1Odds & Ends Problem Solving with Constraints.
Foundations of Constraint Processing, Fall 2005 October 21, 2005CSPs and Relational DBs1 Foundations of Constraint Processing CSCE421/821, Fall 2005:
Constraint Processing Techniques for Improving Join Computation: A Proof of Concept Anagh Lal & Berthe Y. Choueiry Constraint Systems Laboratory Department.
A Constraint Satisfaction Problem (CSP) is a combinatorial decision problem defined by a set of variables, a set of domain values for these variables,
Foundations of Constraint Processing, Fall 2005 November 16, 2005nFCi1 Foundations of Constraint Processing CSCE421/821, Fall 2005:
A Constraint Satisfaction Problem (CSP) is a combinatorial decision problem defined by a set of variables, a set of domain values for these variables,
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Foundations of Constraint Processing, Fall 2005 November 2, 2005Weak Commitment1 Foundations of Constraint Processing CSCE421/821, Fall 2005:
One More Normal Form Consider the dependencies: Product Company Company, State Product Is it in BCNF?
Relational Algebra.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
Relational Algebra Instructor: Mohamed Eltabakh 1.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Constraint Satisfaction Basics strongly influenced by Rina Dechter, “Constraint Processing”, 2003.
CSE314 Database Systems The Relational Algebra and Relational Calculus Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
Relational Algebra A presentation for CS 457 By Dawn Haddan.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra)
1 Relational Algebra and Calculas Chapter 4, Part A.
1.1 CAS CS 460/660 Introduction to Database Systems Relational Algebra.
The Relational Algebra and Calculus
From Relational Algebra to SQL CS 157B Enrique Tang.
Advanced Relational Algebra & SQL (Part1 )
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
CSC271 Database Systems Lecture # 7. Summary: Previous Lecture  Relational keys  Integrity constraints  Views.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Foundations of Constraint Processing, Fall 2004 October 3, 2004Interchangeability in CSPs1 Foundations of Constraint Processing CSCE421/821, Fall 2004:
Foundations of Constraint Processing, Fall 2012 Odds and Ends: Modeling Examples & Graphical Representations 1Odds & Ends Foundations of Constraint Processing.
N-ary Relations & Their Applications. 2 n-ary Relations Let A 1, A 2, …, A n be sets. An n-ary relation on these sets is a subset of A 1 x A 2 x … x A.
Foundations of Constraint Processing Constraint Graphical Models 1Odds & Ends Foundations of Constraint Processing CSCE421/821, Fall
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
LECTURE THREE RELATIONAL ALGEBRA 11. Objectives  Meaning of the term relational completeness.  How to form queries in relational algebra. 22Relational.
Relational Algebra COMP3211 Advanced Databases Nicholas Gibbins
Query Languages Language in which user requests information from the database. Categories of languages Procedural Non-procedural, or declarative “Pure”
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 6 th Edition Chapter 8: Relational Algebra.
Ritu CHaturvedi Some figures are adapted from T. COnnolly
Automatic Test Generation
Module 2: Intro to Relational Model
Chapter # 6 The Relational Algebra and Calculus
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
Relational Algebra - Part 1
Relational Algebra at a Glance
Chapter 2: Intro to Relational Model
The Relational Algebra and Relational Calculus
Foundations of Constraint Processing
CSPs and Relational DBs
Problem Solving with Constraints
Graphing systems of linear equations and inequalities
Data Manipulation using Relational Algebra
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Example of a Relation attributes (or columns) tuples (or rows)
Chapter 2: Intro to Relational Model
Odds and Ends Modeling Examples & Graphical Representations
Problem Solving with Constraints
Problem Solving with Constraints
Relational Model B.Ramamurthy 5/28/2019 B.Ramamurthy.
Presentation transcript:

Problem Solving with Constraints CSPs and Relational DBs1 Problem Solving with Constraints CSCE496/896, Fall All questions to Berthe Y. Choueiry (Shu-we-ri) Avery Hall, Room 360 Tel: +1(402) CSPs & Relational DBs

Problem Solving with Constraints CSPs and Relational DBs2 Background Strong historical & conceptual connections exist between: Constraint Databases & Constraint Logic Programming Query processing in Relational DBs & Solving CSPs Indeed: Constraint databases (deductive BD, Datalog) and constraint logic programming (CLP) share the representation language (restricted forms of FOL) Relational databases and Constraint Satisfaction share computation mechanisms

Problem Solving with Constraints CSPs and Relational DBs3 Relations Binary relation: Given two sets D a and D b, a set of any 2-tuples with  D a and y  D b defines a relation R ab R a,b = {(x, y)}  D a x D b Function: (special binary relation) For any element x in D a there is at most one tuple  R ab D a is called the domain of the the function D b is called the co-domain of the function k-ary relation: Given k sets D 1, D 2, …, D k, any set of k-tuples with x 1  D 1, x 2  D 2, …, x k  D k defines a k-ary relation: R 1, 2,..., k = {(x 1, x 2,..., x k )}  D 1 x D 2 x … x D k

Problem Solving with Constraints CSPs and Relational DBs4 Representation of relations Binary arrays:  2-dim binary array (i.e., bit matrix):  more generally, k-dimensional binary arrays Tables: A B V C 1 D V C 2 E F G C 3 V

Problem Solving with Constraints CSPs and Relational DBs5 Comparison of terminology DB terminologyCSP terminology Table, relationConstraint Relation arityConstraint arity AttributeCSP variable Value of an attributeValue of a variable Domain of an attributeDomain of a variable Tuple in a tableTuple in a constraint Tuple allowed by an constraint Tuple consistent with a constraint Constraint relation (in constraint databases) Constraint of linear (in)equality

Problem Solving with Constraints CSPs and Relational DBs6 Relational Algebra: operations on relations Database: Intersection Union Difference Selection Projection Join (Cartesian product), etc. CSP: The above and composition (= combination of join and projection)

Problem Solving with Constraints CSPs and Relational DBs7 Operators in Relational Algebra Selection, projection –unary operators, defined on one relation Intersection, union, difference –binary operators –relations must have same scope Join –binary operator –relations have different scopes

Problem Solving with Constraints CSPs and Relational DBs8 Intersection Input: two relations of the same scope Output: a new more restrictive relation with the same scope, made of tuples that are in all the input relations (simultaneously) Bit-matrix operation: logical AND R R ' R ’’ R  R ’ ? R  R '’ ? x + y > 10 x - y > 10 Okay Not defined

Problem Solving with Constraints CSPs and Relational DBs9 Union Input: two relations of the same scope Output: a new less restrictive relation with the same scope made of tuples that are in any of the input relations Bit-matrix operation: logical OR R R ' R ’’ R  R '? R  R ''? Okay Not defined

Problem Solving with Constraints CSPs and Relational DBs10 Difference Input: two relations R and R' of the same scope Output: a new more restrictive relation than R made of tuples that are in R but not in R ' Bit-matrix operation: Boolean difference R R ' R ’’ R - R '? R - R ''? Okay Not defined

Problem Solving with Constraints CSPs and Relational DBs11 Selection Input: A relation R and some test/predicate on attributes of R Output: A relation R ', same scope as R but containing only a subset of the tuples in R (those that satisfy the predicate) Relation operation: row selection R Select such that x 1 > x 2,  x1> x2 ( R )?

Problem Solving with Constraints CSPs and Relational DBs12 Projection Input: A relation R and a subset s of the scope (attributes) Output: A relation R ' of scope s with the tuples rewritten such that positions not in s are removed Relation operation: column elimination R Project R on x 1, x 2,  x1, x2 ( R )?

Problem Solving with Constraints CSPs and Relational DBs13 Join (natural join) Input: Two relations R and R ' Output: A relation R '', whose scope is union of scopes of R and R ' and tuples satisfy both R and R '.  R and R' have no attribute common: Cartesian product  R and R' have an attribute in common, compute all possibilities Operation: Compute all solutions to a CSP. R R " Join R and R '', R R '' ?

Problem Solving with Constraints CSPs and Relational DBs14 Composition of relations Montanari'74 Input: two binary relations R ab and R bc with 1 variable in common. Output: a new induced relation R ac (to be combined by intersection to a pre-existing relation between them, if any). Bit-matrix operation: matrix multiplication Note: - generalization as constraint synthesis [Freuder, 1978] - Direct (explicit) vs. induced (implicit) relations

Problem Solving with Constraints CSPs and Relational DBs15 Questions 1.Given two variables V 1 and V 2 and two constraints C 1 and C 2 between them How do the two expressions C 1  C 2 and C 1 C 2 relate? 2.Given three variables V 1, V 2, V 3 and the binary constraints C V1, V2 and C V2, V3 write the induced C V1, V3, in relational algebra 3.Given three variables V 1, V 2, V 3 and the binary constraints C V1, V2, C V1, V3, and C V2, V3, write the new induced C’ V1, V3 in relational algebra

Problem Solving with Constraints CSPs and Relational DBs16 Comparison of Terminology DatabasesCSPs (Natural, inner) joinSynthesized constraint Left/right outer joinSynthesized constraint including (some) inconsistent tuples Projection of a joinInduced constraint (Composition of two constraints) Computing r 1 r 2 … r i Finding all solutions to the conjunction of the constraints r k

Problem Solving with Constraints CSPs and Relational DBs17 DB versus CSP DB: Relations –Few relations in a query –Usually, high arity relations –Usually, selective relations Domains –Large domains, many, many tuples –Mostly finite (CDB introduce continuous domains, restricted to linear constraints) Seeking (almost) all tuples Cost model: I/O disk access, memory size CSPs: Relations –Many, many relations –Mostly low-arity relations (binary) –Typically, much looser than in DB Domains –Small-size domains –Finite (frequent), but also continuous (with arbitrary relations). Seeking (in general) one solution Cost model: computational cost