Tuple Relational Calculus

Similar documents
Database Systems SQL. A.R. Hurson 323 CS Building

INF1383 -Bancos de Dados

Database Design and Normalization


Database Systems Relational Algebra. A.R. Hurson 323 CS Building

CS5300 Database Systems

Relational Algebra SPJRUD

Relational Algebra and Calculus 29

But RECAP. Why is losslessness important? An Instance of Relation NEWS. Suppose we decompose NEWS into: R1(S#, Sname) R2(City, Status)

Relations. Relations of Sets N-ary Relations Relational Databases Binary Relation Properties Equivalence Relations. Reading (Epp s textbook)

α-acyclic Joins Jef Wijsen May 4, 2017

CSE 132B Database Systems Applications

Introduction to Data Management. Lecture #12 (Relational Algebra II)

(! "! # ) T *+!, &'( ) % -.* / *3 '!'1 2 .=! =&6 0 * ' ) 4 50 *6 7 ) 8 ) 9 :; )!'

Constraints: Functional Dependencies

Relational Algebra and Calculus

General Overview - rel. model. Carnegie Mellon Univ. Dept. of Computer Science /615 DB Applications. Motivation. Overview - detailed

Database Applications (15-415)

Desirable properties of decompositions 1. Decomposition of relational schemes. Desirable properties of decompositions 3

Constraints: Functional Dependencies

Databases 2011 The Relational Algebra

From Constructibility and Absoluteness to Computability and Domain Independence

Database Applications (15-415)

1 First-order logic. 1 Syntax of first-order logic. 2 Semantics of first-order logic. 3 First-order logic queries. 2 First-order query evaluation

Review of Functions. Functions. Philippe B. Laval. Current Semester KSU. Philippe B. Laval (KSU) Functions Current Semester 1 / 12

Relational Algebra 2. Week 5

Relational Algebra & Calculus

IV. Turing Machine. Yuxi Fu. BASICS, Shanghai Jiao Tong University

Equational Logic. Chapter Syntax Terms and Term Algebras

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

Movies Title Director Actor

Completeness for coalgebraic µ-calculus: part 2. Fatemeh Seifan (Joint work with Sebastian Enqvist and Yde Venema)

Computational Logic. Relational Query Languages with Negation. Free University of Bozen-Bolzano, Werner Nutt

Overview of Topics. Finite Model Theory. Finite Model Theory. Connections to Database Theory. Qing Wang

Relational operations

Control Systems. System response. L. Lanari

Section 2: Classes of Sets

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

Lecture #7 (Relational Design Theory, cont d.)

1. Model existence theorem.

L RO N LEVLND GENERAL NOTES: /' ROA S PROPOSED LAND AREAS OPEN SPA CE- E AC. EARTH DITCH TOTAL PHASE V OPEN SPACE =

Introduction to Data Management. Lecture #7 (Relational DB Design Theory II)

Annotation algebras for RDFS

1 2 3 style total. Circle the correct answer; no explanation is required. Each problem in this section counts 5 points.

Relational completeness of query languages for annotated databases

22m:033 Notes: 1.3 Vector Equations

Přednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1

An Extended Relational Algebra for Declarative Programming *

arxiv: v1 [cs.db] 21 Sep 2016

Homework 3/ Solutions

A Universal Calculus for Stream Processing Languages

Query answering using views

Database Design and Implementation

INTRODUCTION TO RELATIONAL DATABASE SYSTEMS

GAV-sound with conjunctive queries

Correctness of depiction in planar diagrams of spatial figures

Definition Existence CG vs Potential Games. Congestion Games. Algorithmic Game Theory

QSQL: Incorporating Logic-based Retrieval Conditions into SQL

THE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16)

The Euclidean Topology

Cosets, Lagrange s Theorem, and Normal Subgroups

On Strongly Prime Semiring

Introduction to Data Management. Lecture #6 (Relational DB Design Theory)

Normal Description Logic Programs as Default Theories

Non-Approximability Results (2 nd part) 1/19

Advanced Engineering Mathematics Prof. Pratima Panigrahi Department of Mathematics Indian Institute of Technology, Kharagpur

Regular Expression Unit 1 chapter 3. Unit 1: Chapter 3

Adding ternary complex roles to ALCRP(D)

Solution to Homework 8, Math 2568

Chapter 2. Assertions. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011

1.2 Functions What is a Function? 1.2. FUNCTIONS 11

Propositional logic (revision) & semantic entailment. p. 1/34

Functions of Several Variables

Stat 451: Solutions to Assignment #1

Kleene Algebras and Algebraic Path Problems

chapter 12 MORE MATRIX ALGEBRA 12.1 Systems of Linear Equations GOALS

FIRST-ORDER QUERY EVALUATION ON STRUCTURES OF BOUNDED DEGREE

4 The semantics of full first-order logic

Cosets, Lagrange s Theorem, and Normal Subgroups

8.2 Geometric Distributions Traits of the geometric setting: 1. Each observation has just 2 outcomes: a success and a failure. 2. The n observations

Math 3013 Problem Set 4

An introduction to Parameterized Complexity Theory

CS632 Notes on Relational Query Languages I

Reasoning under Uncertainty: Intro to Probability

AN INTRODUCTION TO SEPARATION LOGIC. 2. Assertions

Enhancing the Updatability of Projective Views

Author: Vivek Kulkarni ( )

Integral Extensions. Chapter Integral Elements Definitions and Comments Lemma

Logic, Set Theory and Computability [M. Coppenbarger]

Basic Linear Algebra Ideas. We studied linear differential equations earlier and we noted that if one has a homogeneous linear differential equation

CHAPTER 1. Preliminaries. 1 Set Theory

Notes on Satisfiability-Based Problem Solving. First Order Logic. David Mitchell October 23, 2013

Behavioural theories and the proof of. LIENS, C.N.R.S. U.R.A & Ecole Normale Superieure, 45 Rue d'ulm, F{75230 Paris Cedex 05, France

First-Order Predicate Logic. Basics

A linear equation in two variables is generally written as follows equation in three variables can be written as

Databases. Exercises on Relational Algebra

Query Processing. 3 steps: Parsing & Translation Optimization Evaluation

CMPS 277 Principles of Database Systems. Lecture #9

Complete Partial Orders, PCF, and Control

Schema Refinement. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Transcription:

Tuple Relational Calculus Université de Mons (UMONS) May 14, 2018

Motivation S[S#, SNAME, STATUS, CITY] P[P#, PNAME, COLOR, WEIGHT, CITY] SP[S#, P#, QTY)] Get all pairs of city names such that a supplier located in the first city supplies a part stored in the second city. SELECT s.city, p.city FROM S AS s, SP AS r, P AS p WHERE s.s# = r.s# AND r.p# = p.p# ; {s.4, p.5 S(s) P(p) r(sp(r) s.1 = r.1 r.2 = p.1)} {s.4, p.5 r(s(s) P(p) SP(r) s.1 = r.1 r.2 = p.1)}

Motivation Get supplier names for suppliers who supply all red parts. SELECT s.sname FROM S AS s WHERE NOT EXISTS ( SELECT * FROM P AS p WHERE p.color = Red AND NOT EXISTS ( SELECT * FROM SP AS r WHERE r.s# = s.s# AND r.p# = p.p# ) ) ; {s.2 S(s) p P ( p.3 = red r SP(r.1 = s.1 r.2 = p.1) ) } {s.2 S(s) p P ( p.3 = red r SP(r.1 = s.1 r.2 = p.1) ) }

Formulas Alphabet Relation names R, S, T,..., each of fixed arity in {1, 2,... }. Tuple variables r, s, t,..., each of fixed arity. Terms Every constant is a term. If r is a tuple variable of arity n and i {1, 2,..., n}, then r.i is a term. Atomic formulas If R is a relation name and r a tuple variable, both of the same arity, then R(r) is an atomic formula. If u 1 and u 2 are terms, then u 1 = u 2 is an atomic formula. Formulas Every atomic formula is a formula. If ϕ 1 and ϕ 2 are formulas, then ϕ 1, ϕ 1 ϕ 2, ϕ 1 ϕ 2 are formulas. If ϕ is a formula with free tuple variable r, then rϕ and rϕ are formulas.

Formulas Alphabet Relation names R, S, T,..., each of fixed arity in {1, 2,... }. Tuple variables r, s, t,..., each of fixed arity. Terms Every constant is a term. If r is a tuple variable of arity n and i {1, 2,..., n}, then r.i is a term. Atomic formulas If R is a relation name and r a tuple variable, both of the same arity, then R(r) is an atomic formula. If u 1 and u 2 are terms, then u 1 = u 2 is an atomic formula. Formulas Every atomic formula is a formula. If ϕ 1 and ϕ 2 are formulas, then ϕ 1, ϕ 1 ϕ 2, ϕ 1 ϕ 2 are formulas. If ϕ is a formula with free tuple variable r, then rϕ and rϕ are formulas.

Formulas Alphabet Relation names R, S, T,..., each of fixed arity in {1, 2,... }. Tuple variables r, s, t,..., each of fixed arity. Terms Every constant is a term. If r is a tuple variable of arity n and i {1, 2,..., n}, then r.i is a term. Atomic formulas If R is a relation name and r a tuple variable, both of the same arity, then R(r) is an atomic formula. If u 1 and u 2 are terms, then u 1 = u 2 is an atomic formula. Formulas Every atomic formula is a formula. If ϕ 1 and ϕ 2 are formulas, then ϕ 1, ϕ 1 ϕ 2, ϕ 1 ϕ 2 are formulas. If ϕ is a formula with free tuple variable r, then rϕ and rϕ are formulas.

Formulas Alphabet Relation names R, S, T,..., each of fixed arity in {1, 2,... }. Tuple variables r, s, t,..., each of fixed arity. Terms Every constant is a term. If r is a tuple variable of arity n and i {1, 2,..., n}, then r.i is a term. Atomic formulas If R is a relation name and r a tuple variable, both of the same arity, then R(r) is an atomic formula. If u 1 and u 2 are terms, then u 1 = u 2 is an atomic formula. Formulas Every atomic formula is a formula. If ϕ 1 and ϕ 2 are formulas, then ϕ 1, ϕ 1 ϕ 2, ϕ 1 ϕ 2 are formulas. If ϕ is a formula with free tuple variable r, then rϕ and rϕ are formulas.

Queries A query is an expression of the form {L ϕ} where L is a list of terms; ϕ is a formula; whenever r.i is a term in L, then r is a free tuple variable of ϕ.

Abbreviations Abbreviations ϕ 1 ϕ 2 is an abbreviation for ϕ 1 ϕ 2 r R(ϕ) is an abbreviation for r(r(r) ϕ) r R(ϕ) is an abbreviation for r(r(r) ϕ) u 1 u 2 is an abbreviation for (u 1 = u 2 ) Notice that these abbreviations make sense: r R(ϕ) r R(ϕ) r(r(r) ϕ) r ( R(r) ϕ) r(r(r) ϕ) r R( ϕ)

Semantics A tuple variable of arity n ranges over dom n. R(r) is true if tuple r belongs to relation R. rϕ is true if there exists r dom n that makes ϕ true (where n is the arity of r).... In tuple relational calculus, we also have the problem of domain dependence. {r.1 R(r) s ( S(s) ) } {r.1 R(r)} How to express {r.1 R(r) S(r)} in SQL? SQL is a mix of tuple relational calculus and relational algebra.

Semantics A tuple variable of arity n ranges over dom n. R(r) is true if tuple r belongs to relation R. rϕ is true if there exists r dom n that makes ϕ true (where n is the arity of r).... In tuple relational calculus, we also have the problem of domain dependence. {r.1 R(r) s ( S(s) ) } {r.1 R(r)} How to express {r.1 R(r) S(r)} in SQL? SQL is a mix of tuple relational calculus and relational algebra.

Exercise Get pairs (n 1, n 2 ) of supplier names such that the parts supplied by n 1 is a subset of the parts supplied by n 2. {s 1.2, s 2.2 S(s 1 ) S(s 2 ) r 1 SP ( r1.1 = s 1.1 r 2 SP(r 2.1 = s 2.1 r 2.2 = r 1.2) ) } {s 1.2, s 2.2 S(s 1 ) S(s 2 ) r 1 SP ( r1.1 = s 1.1 r 2 SP(r 2.1 = s 2.1 r 2.2 = r 1.2) ) } SELECT s1.sname, s2.sname FROM S AS s1, S AS s2 WHERE NOT EXISTS ( SELECT * FROM SP AS r1 WHERE r1.s# = s1.s# AND NOT EXISTS ( SELECT * FROM SP AS r2 WHERE r2.s# = s2.s# AND r2.p# = r1.p# ) ) ;