Relational Calculus Chapter 4, Part B

Slides:



Advertisements
Similar presentations
Relational Algebra Chapter 4, Part A
Advertisements

Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Part B.
Relational Calculus   Logic, like whiskey, loses its beneficial effect when taken in too large quantities. --Lord Dunsany.
1 541: Relational Calculus. 2 Relational Calculus  Comes in two flavours: Tuple relational calculus (TRC) and Domain relational calculus (DRC).  Calculus.
1 Relational Calculus Chapter 4 – Part II. 2 Formal Relational Query Languages  Two mathematical Query Languages form the basis for “real” languages.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4.
1 Relational Algebra & Calculus. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
R ELATIONAL A LGEBRA M ORE POINTERS FROM T UESDAY.
Relational Calculus. Another Theoretical QL-Relational Calculus n Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus.
Relational Calculus CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 Mary Roth   We will occasionally use this arrow notation unless there is danger of.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Relational Calculus R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion. Ronald Graham Elements of Ramsey.
Introduction to Database Systems 1 Relational Calculus Relational Model : Topic 2.
Relational Calculus CS 186, Fall 2003, Lecture 6 R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion.
Rutgers University Relational Calculus 198:541 Rutgers University.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Section 4.3.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4.
1 Relational Algebra. 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of data from a database. v Relational model supports.
Relational Calculus R&G, Chapter 4. Relational Calculus Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus (DRC). Calculus.
Relational Calculus CS 186, Spring 2005, Lecture 9 R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion.
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra)
1 Relational Algebra and Calculas Chapter 4, Part A.
Relational Algebra.
1 Copyright © Kyu-Young Whang Relational Calculus Chapter 4, Part B.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L5_Relational Calculus 1 Relational Calculus Chapter 4 – Part B.
Relational Calculus Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4, Part B.
1 Relational Algebra. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational model supports.
Relational Calculus Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Relational Calculus Chapter 4, Section 4.3.
Relational Algebra & Calculus
CF 1334 Sistem Basis Data (3 SKS)
Diskusi-08 Jelaskan dan berikan contoh penggunaan theta join, equijoin, natural join, outer join, dan semijoin The slides for this text are organized into.
Diskusi-5 Sebutkan perangkat (tools) yang berpotensi mendukung kebutuhan tugas-tugas manajerial (management work) Jelaskan enam karakteristik informasi.
MODELS OF DATABASE AND DATABASE DESIGN
Tree-Structured Indexes
Storage and Indexes Chapter 8 & 9
Query-by-Example (QBE)
Diskusi-1 Bacalah materi chapter-01, lalu buatlah ringkasan yang berisi tentang : Definisi EUIS Siapa end user Dampak euis pada lingkungan kerja Perencanaan.
Relational Calculus Chapter 4, Part B
Latihan Answer the following questions using the relational schema from the Exercises at the end of Chapter 3: Create the Hotel table using the integrity.
Diskusi-16 Buatlah ringkasan tentang pertimbangan dalam desain yang ergonomis pada tiga perangkat utama komputer yaitu monitor, keyboard dan mouse (lihat.
Latihan Create a separate table with the same structure as the Booking table to hold archive records. Using the INSERT statement, copy the records from.
Tugas-05 a. Sebutkan primary key masing-masing tabel
Introduction to Query Optimization
Relational Algebra Chapter 4, Part A
Modeling Your Data Chapter 2 cs542
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 Mary Roth
External Sorting The slides for this text are organized into chapters. This lecture covers Chapter 11. Chapter 1: Introduction to Database Systems Chapter.
File Organizations and Indexing
File Organizations and Indexing
Team Project, Part II NOMO Auto, Part II IST 210 Section 4
Relational Calculus.
Selected Topics: External Sorting, Join Algorithms, …
Relational Algebra Chapter 4, Sections 4.1 – 4.2
B+Trees The slides for this text are organized into chapters. This lecture covers Chapter 9. Chapter 1: Introduction to Database Systems Chapter 2: The.
CS 186, Fall 2002, Lecture 8 R&G, Chapter 4
Evaluation of Relational Operations: Other Techniques
Distributed Databases
CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 Mary Roth
Introduction to Database Systems
Tree-Structured Indexes
Relational Algebra & Calculus
Relational Calculus Chapter 4, Part B 7/1/2019.
File Organizations and Indexing
COSC 3480 Projects & Homeworks Fall 2003
Relational Calculus Chapter 4 – Part II.
Presentation transcript:

Relational Calculus Chapter 4, Part B The slides for this text are organized into chapters. This lecture covers relational calculus from Chapter 4. The relational algebra part can be found in Chapter 4, Part A. Chapter 1: Introduction to Database Systems Chapter 2: The Entity-Relationship Model Chapter 3: The Relational Model Chapter 4 (Part A): Relational Algebra Chapter 4 (Part B): Relational Calculus Chapter 5: SQL: Queries, Programming, Triggers Chapter 6: Query-by-Example (QBE) Chapter 7: Storing Data: Disks and Files Chapter 8: File Organizations and Indexing Chapter 9: Tree-Structured Indexing Chapter 10: Hash-Based Indexing Chapter 11: External Sorting Chapter 12 (Part A): Evaluation of Relational Operators Chapter 12 (Part B): Evaluation of Relational Operators: Other Techniques Chapter 13: Introduction to Query Optimization Chapter 14: A Typical Relational Optimizer Chapter 15: Schema Refinement and Normal Forms Chapter 16 (Part A): Physical Database Design Chapter 16 (Part B): Database Tuning Chapter 17: Security Chapter 18: Transaction Management Overview Chapter 19: Concurrency Control Chapter 20: Crash Recovery Chapter 21: Parallel and Distributed Databases Chapter 22: Internet Databases Chapter 23: Decision Support Chapter 24: Data Mining Chapter 25: Object-Database Systems Chapter 26: Spatial Data Management Chapter 27: Deductive Databases Chapter 28: Additional Topics

Relational Calculus Comes in two flavours: Tuple relational calculus (TRC) and Domain relational calculus (DRC). Calculus has variables, constants, comparison ops, logical connectives and quantifiers. TRC: Variables range over (i.e., get bound to) tuples. DRC: Variables range over domain elements (= field values). Both TRC and DRC are simple subsets of first-order logic. Expressions in the calculus are called formulas. An answer tuple is essentially an assignment of constants to variables that make the formula evaluate to true.

First-Order Predicate Logic Predicate: is a feature of language which you can use to make a statement about something, e.g., to attribute a property to that thing. Peter is tall. We predicated tallness of peter or attributed tallness to peter. A predicate may be thought of as a kind of function which applies to individuals and yields a proposition. Proposition logic is concerned only with sentential connectives such as and, or, not. Predicate Logic, where a logic is concerned not only with the sentential connectives but also with the internal structure of atomic propositions.

First order predicate logic First-order predicate logic, first-order says we consider predicates on the one hand, and individuals on the other; that atomic sentences are constricted by applying the former to the latter; and that quantification is permitted only over the individuals First-order logic permits reasoning about propositional connectives and also about quantification. All men are motal Peter is a man Peter is mortal

Tuple Relational Calculus Query: {T|P(T)} T is tuple variable P(T) is a formula that describes T Result, the set of all tuples t for which P(t) evaluates True. Find all sailors with a rating above 7. Atomic formula R.a op S.b , op is one of R.a op constant

TRC Formula Example Any atomic formula Find the names and ages of sailors with a rating above 7

TRC Find the names of sailors who have reserved all boats Find sailors S such that for all boats B there is a Reserves tuple showing that sailor S has reserved boat B

Domain Relational Calculus Query has the form: Answer includes all tuples that make the formula be true. Formula is recursively defined, starting with simple atomic formulas (getting tuples from relations or making comparisons of values), and building bigger and better formulas using the logical connectives.

DRC Formulas Atomic formula: Formula: an atomic formula, or , or X op Y, or X op constant op is one of Formula: an atomic formula, or , where p and q are formulas, or , where variable X is free in p(X), or , where variable X is free in p(X)

Free and Bound Variables The use of quantifiers and in a formula is said to bind X. A variable that is not bound is free. Let us revisit the definition of a query: There is an important restriction: the variables x1, ..., xn that appear to the left of `|’ must be the only free variables in the formula p(...).

Find all sailors with a rating above 7 The condition ensures that the domain variables I, N, T and A are bound to fields of the same Sailors tuple. The term to the left of `|’ (which should be read as such that) says that every tuple that satisfies T>7 is in the answer. Modify this query to answer: Find sailors who are older than 18 or have a rating under 9, and are called ‘Joe’.

Find sailors rated > 7 who’ve reserved boat #103 We have used as a shorthand for Note the use of to find a tuple in Reserves that `joins with’ the Sailors tuple under consideration.

Find sailors rated > 7 who’ve reserved a red boat Observe how the parentheses control the scope of each quantifier’s binding. This may look cumbersome, but with a good user interface, it is very intuitive. (Wait for QBE!)

Find sailors who’ve reserved all boats Find all sailors I such that for each 3-tuple either it is not a tuple in Boats or there is a tuple in Reserves showing that sailor I has reserved it.

Find sailors who’ve reserved all boats (again!) Simpler notation, same query. (Much clearer!) To find sailors who’ve reserved all red boats: .....

Unsafe Queries, Expressive Power It is possible to write syntactically correct calculus queries that have an infinite number of answers! Such queries are called unsafe. e.g., It is known that every query that can be expressed in relational algebra can be expressed as a safe query in DRC / TRC; the converse is also true. Relational Completeness: Query language (e.g., SQL) can express every query that is expressible in relational algebra/calculus.

Summary Relational calculus is non-operational, and users define queries in terms of what they want, not in terms of how to compute it. (Declarativeness.) Algebra and safe calculus have same expressive power, leading to the notion of relational completeness.