Lecture 3 [Self Study] Relational Calculus

Slides:



Advertisements
Similar presentations
The Relational Calculus
Advertisements

Chapter 3 Tuple and Domain Relational Calculus. Tuple Relational Calculus.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Logic Use mathematical deduction to derive new knowledge.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Extended SQL & The Relational Calculus.
Domain Relational Calculus and Query-by-Example CS157a John Eagle.
Relational Calculus. Another Theoretical QL-Relational Calculus n Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Predicate Calculus.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
The Relational Model Codd (1970): based on set theory Relational model: represents the database as a collection of relations (a table of values --> file)
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
Relational Algebra.  Introduction  Relational Algebra Operations  Projection and Selection  Set Operations  Joins  Division  Tuple Relational Calculus.
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
DEDUCTIVE DATABASE.
Knowledge Interchange Format Michael Gruninger National Institute of Standards and Technology
Relational Query Languages. Languages of DBMS  Data Definition Language DDL  define the schema and storage stored in a Data Dictionary  Data Manipulation.
Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.
1 CS 430 Database Theory Winter 2005 Lecture 6: Relational Calculus.
1 CS 430 Database Theory Winter 2005 Lecture 12: SQL DML - SELECT.
Chapter 13 Query Processing Melissa Jamili CS 157B November 11, 2004.
Chapter 8 Relational Calculus. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.8-2 Topics in this Chapter Tuple Calculus Calculus vs. Algebra.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
CSE314 Database Systems The Relational Algebra and Relational Calculus Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4.
ARTIFICIAL INTELLIGENCE Lecture 3 Predicate Calculus.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 14 A First Course in Database Systems.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science Database Applications Lecture#6: Relational calculus.
First-Order Logic Introduction Syntax and Semantics Using First-Order Logic Summary.
Relational Calculus R&G, Chapter 4. Relational Calculus Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus (DRC). Calculus.
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra)
1 Relational Algebra and Calculas Chapter 4, Part A.
1 Predicate (Relational) Logic 1. Introduction The propositional logic is not powerful enough to express certain types of relationship between propositions.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 17 A First Course in Database Systems.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
The Relational Calculus (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
Copyright © 2004 Ramez Elmasri and Shamkant Navathe The Relational Calculus The main reference of this presentation is the textbook and PPT from : Elmasri.
Database System Concepts, 5th Ed. Bin Mu at Tongji University Chapter 5: Other Relational Languages.
Formal Methods in SE Lecture 16 Formal Methods in SE Qaisar Javaid Assistant Professor.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 5 – September 4 th,
Slide 6- 1 Additional Relational Operations Aggregate Functions and Grouping A type of request that cannot be expressed in the basic relational algebra.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
CSC271 Database Systems Lecture # 7. Summary: Previous Lecture  Relational keys  Integrity constraints  Views.
Copyright © Curt Hill The Relational Calculus Another way to do queries.
Lecture 1: Relational Data Models
Restrictions Objectives of the Lecture : To consider the algebraic Restrict operator; To consider the Restrict operator and its comparators in SQL.
SE305 Database System Technology 25/09/2014 Quiz-1.
ARTIFICIAL INTELLIGENCE Lecture 2 Propositional Calculus.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Relational tuple calculus.
PREDICATES AND QUANTIFIERS COSC-1321 Discrete Structures 1.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
CG096 Advanced Database Technologies Lecture 6 Relational Algebra and SQL.
Relational Algebra COMP3211 Advanced Databases Nicholas Gibbins
Relational Calculus. Relational calculus query specifies what is to be retrieved rather than how to retrieve it. – No description of how to evaluate a.
Jun-Ki Min.  Based on predicate calculus ◦ Predicate  a function whose value is true or false  non-procedural ◦ A relational calculus expression creates.
Relational Calculus Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Chapter 8 Relational Calculus.
CSE202 Database Management Systems
By P. S. Suryateja Asst. Professor, CSE Vishnu Institute of Technology
(State) Model-Based Approaches I Software Specification Lecture 35
1-5 Equations Goals: Solve equations with one variable
Introduction to Database Systems, CS420
The Relational Algebra and Relational Calculus
Relational Calculus and QBE
(1.4) An Introduction to Logic
Relational Calculus and QBE
Chapter 27: Formal-Relational Query Languages
Relational Calculus Chapter 4, Part B
Presentation transcript:

Lecture 3 [Self Study] Relational Calculus CM036: Advanced Database Lecture 3 [Self Study] Relational Calculus

Relational Calculus Declarative language based on predicate logic - checks what is true in the database rather then looking to get it The main difference in comparison with the relational algebra is the introduction of variables which range over attributes or tuples Two different variations of the relational calculus: domain calculus - specification of formal properties for different data types, used for describing data tuple calculus - querying and checking formal properties of stored relational data CM036: Advanced Databases Relational Calculus

Predicate Calculus Vocabulary of constant names, functional attributes and predicate properties, used for describing the information Phrases for specification of constant, functionally dependant or predicated properties build using proper vocabulary terms Statements about the world, formulated as meaningful phrases, connected through logical connectives in logical sentences conjunction () disjunction () negation () implication () equivalence () Possible quantification of the sentences using existential () or universal () quantifiers, ranging over variables Example: All units registered in the database have unit leaders among the lecturers (x).(Unit (x)  (y).(Lecturer(y)  Leader(y,x))) CM036: Advanced Databases Relational Calculus

Relational DB as a Predicate Calculus model Semantic interpretation of the calculus is given in a set, so either all type domains of the relational schema (domain calculus), or the set of all relations in the database (tuple calculus) can serve a model for it All meaningful sentences in the model are true or false, so the relation tuples can be interpreted as truthful facts describing the world The constraints describe logical regularities among the attribute values, so they can be expressed as logical sentences Example: All records of unit leaders have primary keys Relation names are predicates with a place for each attribute Leader(Lno:INTEGER,Lname:CHAR,Uname:CHAR) - Lno, Lname and Uname are attributes of Leader Data values in the relation tuples are constants from the domains Leader(2,‘Johnson’,’CS234’) - 2,Johnson and CS234 are constants forming one Leader tuple Constraints can be stated using quantified variables over domains (x)(y,z) .(Leader(x,y,z)) - x stands for the primary key of Leader CM036: Advanced Databases Relational Calculus

1. In predicate calculus sentences contain quantified variables only Notes: 1. In predicate calculus sentences contain quantified variables only 2. The sub-expressions following the quantified variables form the scope of quantification; it is usually closed in round parentheses Example: The table for unit leaders has foreign keys to both the lecturers and units tables Relation names are predicates with place for each attribute Unit(Uno:INTEGER, Uname:CHAR) - Uno and Uname are attributes of relation Unit Lecturer(Lno:INTEGER, Lname:CHAR) - Lno and Lname are attributes of relation Lecturer Leader(LUno:INTEGER,Lno:INTEGER,Uno:INTEGER) - LUno, Lno and Uno are attributes of relation Leader All foreign key constraints can be stated logically using quantified sentences, in which variables range over the respective values ( LUno,Uno,Lno).(Leader(LUno,Uno,Lno)  ( Lname).(Lecturer(Lno,Lname))  ( Uname).(Unit(Uno,Uname)) ) CM036: Advanced Databases Relational Calculus

Relational Calculus as database query language Queries are logical expressions, which contain non-quantified (free) variables for tuples The free variables are placeholders for the information, we are looking for from the database relations The logical expressions, used in the query, are its conditions which need to be met during answering the query Example: Who are the employees with salary greater than 40 000? {e.FNAME,e.LNAME | Employee(e)  e.SALARY > 40 000} An answer is a replacement of the free variables in the query with tuple attributes from the relations used to formulate the query conditions; they should make the statement of the query true in database (pattern matching) Answer: James Borg and Jennifer Wallace Free variables Matching values e.FNAME James Jennifer e.LNAME Borg Wallace CM036: Advanced Databases Relational Calculus

1. The question variables are always listed in front of the Notes: 1. The question variables are always listed in front of the expression, separated by | from the question condition; 2. Question condition can contain free variables only from the list in the beginning; all other variables should be quantified Querying related tables requires check of the corresponding keys for equality Example: Retrieve the name and address of all employees who work for the ‘Research’ department {e.FNAME,e.LNAME,e.ADDRESS | Employee(e)  ( d).(Department(d)  d.DNAME = ‘Research’  d.DNUMBER = e.DNO ) } CM036: Advanced Databases Relational Calculus

Equvalence between relational algebra and relational calculus Relational algebra and relational calculus are equivalent with respect to their ability to formulate queries against relational databases (Codd 1972) Relational algebra concentrates on the procedural (“how-to”) aspects and because of this it is used as an intermediate language for optimization of database queries Relational calculus is more appropriate to specify declaratively the model properties (“what is true”), without worrying about the way it is achieved and as such it can be used as a specification or querying language Note: The relational language Query-By-Example (QBE), which is developed by IBM during 70ties and is implemented in Paradox and Access desktop database systems is based on the relational calculus CM036: Advanced Databases Relational Calculus