The Relational Calculus (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)

Slides:



Advertisements
Similar presentations
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Part B.
Advertisements

The Relational Calculus
1 541: Relational Calculus. 2 Relational Calculus  Comes in two flavours: Tuple relational calculus (TRC) and Domain relational calculus (DRC).  Calculus.
1 Relational Algebra & Calculus. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 6- 1.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Introduction to Database Systems 1 Relational Calculus Relational Model : Topic 2.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Revision of Midterm 2 Prof. Sin-Min Lee Department of Computer Science.
Rutgers University Relational Calculus 198:541 Rutgers University.
Chapter 4 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Banking Example  branch (branch-name, branch-city, assets)  customer (customer-name, customer-street,
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
Lecture 3 [Self Study] Relational Calculus
The Relational Model: Relational Calculus
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Section 4.3.
1 CS 430 Database Theory Winter 2005 Lecture 6: Relational Calculus.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
CS 380 Introduction to Database Systems Chapter 7: The Relational Algebra and Relational Calculus.
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.
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.
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra)
1 Relational Algebra and Calculas Chapter 4, Part A.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Relational Algebra. 2 Outline  Relational Algebra Unary Relational Operations Relational Algebra Operations from Set Theory Binary Relational Operations.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1 CIS 611.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
The Relational Algebra and Calculus. Slide 6- 2 Chapter Outline Relational Algebra Unary Relational Operations Relational Algebra Operations From Set.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2004 Ramez Elmasri and Shamkant Navathe The Relational Calculus The main reference of this presentation is the textbook and PPT from : Elmasri.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
1 Copyright © Kyu-Young Whang Relational Calculus Chapter 4, Part B.
Slide 6- 1 Additional Relational Operations Aggregate Functions and Grouping A type of request that cannot be expressed in the basic relational algebra.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L5_Relational Calculus 1 Relational Calculus Chapter 4 – Part B.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 11 A First Course in Database Systems.
Copyright © 2004 Pearson Education, Inc.. Chapter 6 The Relational Algebra and Relational Calculus.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4, Part B.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 16 A First Course in Database Systems.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
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 Algebra. CENG 3512 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports.
Chapter 4 The Relational Algebra and Calculus
Relational Calculus Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Relational Calculus Chapter 4, Section 4.3.
Introduction to Relational Calculus Tuple Relational Calculus
CSE202 Database Management Systems
A First Course in Database Systems
Relational Calculus Chapter 4, Part B
The Relational Algebra and Relational Calculus
Elmasri/Navathe, Fundamentals of Database Systems, 4th Edition
11/22/2018.
Session - 6 Sequence - 2 SQL: The Structured Query Language:
12/5/2018.
12/31/2018.
Relational Calculus and QBE
Introduction to Database Systems
Relational Calculus and QBE
Relational Calculus Chapter 4, Part B 7/1/2019.
Presentation transcript:

The Relational Calculus (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)

The Relational Calculus2 Contents Introduction to Relational Calculus Tuple Relational Calculus Tuple Variables and Range Relations Formal Specification of Tuple Relational Calculus Queries Using the Existential Quantifier Transforming Universal and Existential Quantifiers Universal Quantifiers and Safe Expressions Domain Relational Calculus

The Relational Calculus3 Introduction to Relational Calculus A formal language based on first-order predicate calculus. Many commercial relational languages based on some aspects of relational calculus, including SQL. QUEL, QBE(Chapter 9) closer to relational calculus than SQL

The Relational Calculus4 Difference from relational algebra: One declarative calculus expression specifies a retrieval query. A sequence of operations is used in relational algebra. Relational algebra more procedural. Relational calculus more declarative (less procedural). Expressive power of the two languages is identical.

The Relational Calculus5 Relational Completeness: A relational query language L is relationally complete if we can express in L any query that can be expressed in the relational calculus (or algebra) Most relational query languages are relationally complete. More expressive power is provided by operations such as aggregate functions, grouping, and ordering.

The Relational Calculus6 Tuple Variable and Range Relations The tuple relational calculus is based on specifying a number of tuple variables. A tuple variable ranges over the tuples of a particular relation. Such relation is called a range relation.

The Relational Calculus7 A Form of Tuple Relational Calculus Query A simple tuple relational calculus query is of the from {t | COND(t)} t is a tuple variable COND(t) is a conditional expression involving t. The result of such a query is set of all tuples t that satisfies COND(t).

The Relational Calculus8 Example: Find all employees whose salary is above $50000: { t | EMPLOYEE(t) and t.SALARY > } EMPLOYEE(t) specifies the range relation EMPLOYEE for the tuple variable t Each tuple t satisfying t.SALARY > is retrieved Retrieves the whole tuple t

The Relational Calculus9 Example: To retrieve only some attributes of t: { t.FNAME, t.LNAME | EMPLOYEE(t) and t.SALARY>50000 } Similar to the SQL query: SELECT T.FNAME, T.LNAME FROM EMPLOYEE T WHERE T.SALARY > 50000

The Relational Calculus10 A Tuple Calculus Expression Need to specific the following information For each tuple variable t, the range relation R of t. This value is specified by a condition of the form R(t). A condition to select particular combinations of tuples. A set of attributes to be retrieved, the requested attribute.

The Relational Calculus11 A general expression of tuple relational calculus is of the form {(t 1.A 1, t 2.A 2,…t n.A n | COND(t 1,t 2,…,t n,t n+1,t n+2,…,t n+m )} Where t 1.A 1, t 2.A 2, … t n.A n are tuple variables, each A i is an attribute of the relation on which t i ranges, and COND is a condition or formula Expressions of Tuple Relational Calculus

The Relational Calculus12 Formulas of Tuple Relational Calculus A formula is made up of predicate calculus atoms, which can be one of the following: An atom of the form R(t i ), where R is a relation name and t i is a tuple variable. An atom of the form t i.A op t j.B, where op is one of the comparison operators in the set {=,>, ,<, ,  }, t i and t j are tuple variables, A is an attribute of the relation on which t i ranges, and B is an attribute of the relation on which t j ranges.

The Relational Calculus13 Formulas of Tuple Relational Calculus A formula is made up of predicate calculus atoms, which can be one of the following: An atom of the form t i.A op c or c op t j.B, where op is one of the comparison operators in the set {=,>, ,<, ,  }, t i and t j are tuple variables, A is an attribute of the relation on which t i ranges, and B is an attribute of the relation on which t j ranges, and c is a constant value.

The Relational Calculus14 Truth Value Each of the preceding atoms evaluates to ether TRUE or FALSE for a specific combination of tuples. This is called the truth value of an atom. In general, a tuple variable ranges over all possible tuples “ in the universe. ”

The Relational Calculus15 Formula Atoms connected via and, or and not. Every atom is a formula If F 1 and F 2 are formulas, so are : (F 1 and F 2 ) (F 1 or F 2 ) not(F 1 ) not(F 2 )

The Relational Calculus16 The Existential and Universal Quantifiers Universal quantifier(  ) Read for all Existential quantifiers(  ) Read their exists

The Relational Calculus17 Free and Bound Tuple Variables Informally, A tuple variable t is bound if it is quantified, mean that it appears in an (  t) or (  t) clause; otherwise, it is free.

The Relational Calculus18 Free and Bound Tuple Variables An occurrence of a tuple variable in a formula F that is an atom is free in F. An occurrence of a tuple variable t is free or bound in a formula made up of logical connectives – (F 1 and F 2 ), (F 1 or F 2 ), not(F 1 ), and not(F 2 ) – depending on whether it is free or bound in F 1 or F 2 (if it occur in either).

The Relational Calculus19 Free and Bound Tuple Variables All free occurrences of a tuple variable t in F are bound in a formula F ’ of the form F ’ = (  t)(F) or F ’ = (  t)(F). The tuple variable is bound to the quantifier specified in F ’.

The Relational Calculus20 For example F1 : d.DNAME= ‘ Research ’ F2 : (  t)(d.DNUMBER=t.DNO) F3 : (  t)(d.MGRSSN= ‘ ’ ) d is free in F1, F2 and F3 t is bound to the  quantifier in F2 t is bound to the  quantifier in F3

The Relational Calculus21 Formulas Every atom is a formula. If F1 and F2 are formulas, then so are (F 1 and F 2 ), (F 1 or F 2 ), not(F 1 ), and not(F 2 ). If F is a formula, then so is (  t)(F), where t is a tuple variable. If F is a formula, then so is (  t)(F), where t is a tuple variable.

The Relational Calculus22 Truth Value for Existential Quantifiers The formula (  t)(F) is TRUE if the formula F evaluates to TRUE for some (at least one) tuple assigned to free occurrences of t in F; otherwise (  t)(F) is FALSE.

The Relational Calculus23 Existential Quantifiers  called existential quantifier because (  t)(F) is TRUE if “ there exists ” some tuple t that make F TURE.

The Relational Calculus24 Truth Value for Universal Quantifiers The formula (  t)(F) is TRUE if the formula F evaluates to TRUE for every tuple (in the universe) assigned to free occurrences of t in F; otherwise (  t)(F) is FALSE.

The Relational Calculus25 Universal Quantifiers  called universal quantifier because every tuple in “ the universe of ” tuples must make F TRUE if (  t)(F) is to be TRUE.

The Relational Calculus26 Example Queries Using the Existential Quantifiers (1) Query 1 : Retrieve the name and address of all employees who work for the ‘ Research ’ department. Query 1 : Retrieve the name and address of all employees who work for the ‘ Research ’ department.

The Relational Calculus27 Example Queries Using the Existential Quantifiers (1) Q1: { t.FNAME, t.LNAME, t.ADDRESS | EMPLOYEE(t) and(  d)(DEPARTMENT(d) andd.NAME= ‘ Research ’ and d.DNUMBER=t.DNO) } Q1: { t.FNAME, t.LNAME, t.ADDRESS | EMPLOYEE(t) and(  d)(DEPARTMENT(d) andd.NAME= ‘ Research ’ and d.DNUMBER=t.DNO) }

The Relational Calculus28 Example Queries Using the Existential Quantifiers (1) The only free tuple variables in a relational calculus expression should be those that appear to the left of the bar (|). Each free variable is bound successively to each tuple that satisfies the condition to the right of the bar (|). The bar (|) read as “ such that ”

The Relational Calculus29 Example Queries Using the Existential Quantifiers (1) EMPLOYEE(t), DEPARTMENT(d) specify range relations for t. The condition d.NAME= “ Research ” is selection condition. (corresponds to SELECT in relational algebra) The condition d.DNUMBER=t.DNO is a join condition. (serves a similar purpose to EQUIJOIN in relational algebra)

The Relational Calculus30 Example Queries Using the Existential Quantifiers (2) Query 2 For every project located in ‘ Stafford ’, list the project number, the controlling department number, and the department manage ’ s last name, address, and birthdate. Query 2 For every project located in ‘ Stafford ’, list the project number, the controlling department number, and the department manage ’ s last name, address, and birthdate.

The Relational Calculus31 Example Queries Using the Existential Quantifiers (2) Q2: {p.PNUMBER, p. DNUM, m.LNAME, m.BDATE, m.ADDRESS | PROJECT(p) and EMPLOYEE(m) and PLOCATION='Stafford ‘ and (  d)(DEPARTMENT(d) and p.DNUM=d.DNUMBER and d.MGRSSN=m.SSN) } Q2: {p.PNUMBER, p. DNUM, m.LNAME, m.BDATE, m.ADDRESS | PROJECT(p) and EMPLOYEE(m) and PLOCATION='Stafford ‘ and (  d)(DEPARTMENT(d) and p.DNUM=d.DNUMBER and d.MGRSSN=m.SSN) }

The Relational Calculus32 Example Queries Using the Existential Quantifiers (8) Query 8: For each employee, retrieve the employee's name, and the name of his or her immediate supervisor. Query 8: For each employee, retrieve the employee's name, and the name of his or her immediate supervisor.

The Relational Calculus33 Example Queries Using the Existential Quantifiers (8) Q8: {e.FNAME, e.LNAME, s.FNAME,s.LNAME | EMPLOYEE(e) and EMPLOYEE(s) ande.SUPERSSN=s.SSN} Q8: {e.FNAME, e.LNAME, s.FNAME,s.LNAME | EMPLOYEE(e) and EMPLOYEE(s) ande.SUPERSSN=s.SSN}

The Relational Calculus34 Example Queries Using the Existential Quantifiers (3 ’ ) Query 3 ’ Find the names of employees who work on some projects controlled by department number 5. Query 3 ’ Find the names of employees who work on some projects controlled by department number 5.

The Relational Calculus35 Example Queries Using the Existential Quantifiers (3 ’ ) Q3 ’ : {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  x)(  w)(PROJECT(x) and WORKS_ON(w) and x.DNUM=5 and e.SSN=w.ESSN and p.PNO=x.PNUMBER)) } Q3 ’ : {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  x)(  w)(PROJECT(x) and WORKS_ON(w) and x.DNUM=5 and e.SSN=w.ESSN and p.PNO=x.PNUMBER)) }

The Relational Calculus36 Example Queries Using the Existential Quantifiers (4) Query 4 Make a list of project numbers for projects that involve an employee whose last name is ‘ Smith ’, either as a worker or a manager of the department that controls the project. Query 4 Make a list of project numbers for projects that involve an employee whose last name is ‘ Smith ’, either as a worker or a manager of the department that controls the project.

The Relational Calculus37 Example Queries Using the Existential Quantifiers (4) Q4: {p.PNUMBER | PROJECT(p) and (((  e)(  w)(EMPLOYEE(e) and WORKS_ON(w) and p.PNUMBER=w.PNO and e.LNAME='Smith ‘ and w.ESSN=e.SSN )) or ((  m)(  d)(EMPLOYEE(m) and DEPARTMENT(d) and p.DNUM=d.DNUMBER and d.MGRSSN=m.SSN and m.LNAME='Smith')))} Q4: {p.PNUMBER | PROJECT(p) and (((  e)(  w)(EMPLOYEE(e) and WORKS_ON(w) and p.PNUMBER=w.PNO and e.LNAME='Smith ‘ and w.ESSN=e.SSN )) or ((  m)(  d)(EMPLOYEE(m) and DEPARTMENT(d) and p.DNUM=d.DNUMBER and d.MGRSSN=m.SSN and m.LNAME='Smith')))}

The Relational Calculus38 Example Queries Using the Existential Quantifiers (4) In general, UNION in relational algebra corresponds to an or connective in relational calculus. INTERSECTION corresponds to an and connective.

The Relational Calculus39 Transforming Universal and Existential Quantifiers The not connective can be used to transform universal and existential quantifiers to equivalent formulas.

The Relational Calculus40 Well-known transformations from mathematical logic. (  x) (P(x))  (not  x) (not(P(x))) (  x) (P(x))  not (  x) (not(P(x))) (  x) (P(x))  (not  x) (not(P(x))) (  x) (P(x))  not (  x) (not(P(x)))

The Relational Calculus41 Well-known transformations from mathematical logic. The following is also true, where  stands for implies: (  x) (P(x))  (  x) (P(x)) (not  x) (P(x))  not (  x) (P(x)) The following is not true: not(  x) (P(x))  (not  x) (P(x))

The Relational Calculus42 Example Queries Using Universal Quantifiers (3) Query 3 Find the names of employees who work on all the projects controlled by department number 5. Query 3 Find the names of employees who work on all the projects controlled by department number 5.

The Relational Calculus43 Example Queries Using Universal Quantifiers (3) Q3: {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  x)(not(PROJECT(x)) or (not(x.DNUM=5) or ((  w)(WORKS_ON(w) and e.SSN=w.ESSN and p.PNO=x.PNUMBER) )) ) } Q3: {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  x)(not(PROJECT(x)) or (not(x.DNUM=5) or ((  w)(WORKS_ON(w) and e.SSN=w.ESSN and p.PNO=x.PNUMBER) )) ) }

The Relational Calculus44 Example Queries Using Universal Quantifiers (3) Q3 : For every tuple x in the project relation with x.DUM = 5, there must exist a tuple w in WORK_ON such that w.ESSN=e.SSN and w.PNO=x.PNUMBER. Q3 : For every tuple x in the project relation with x.DUM = 5, there must exist a tuple w in WORK_ON such that w.ESSN=e.SSN and w.PNO=x.PNUMBER.

The Relational Calculus45 Basic Components of Q3 Q3: {e.FNAME, e.LNAME | EMPLOYEE(e) and F ’ } F ’ = ((  x)(not(PROJECT(x)) or F 1 )) F 1 = not(x.DNUM=5) or F 2 F 2 = ((  w)(WORKS_ON(w) and e.SSN=w.ESSN and p.PNO=x.PNUMBER)) Q3: {e.FNAME, e.LNAME | EMPLOYEE(e) and F ’ } F ’ = ((  x)(not(PROJECT(x)) or F 1 )) F 1 = not(x.DNUM=5) or F 2 F 2 = ((  w)(WORKS_ON(w) and e.SSN=w.ESSN and p.PNO=x.PNUMBER))

The Relational Calculus46 Basic Components of Q3 Must exclude all tuples not of interest from the universal quantification by making the condition TRUE for all such tuples. Universally quantified variable x must evaluate to TRUE for every possible tuple in the universe.

The Relational Calculus47 Basic Components of Q3 In F ’, not(PROJECT(x)) makes x TRUE for all tuples not in the relation of interest “ PROJECT ”. F ’ = ((  x)(not(PROJECT(x)) or F 1 )) In F 1, not(x.DNUM=5) makes x TRUE for those PROJECT tuples we are not interested in “ whose DNUM is not 5 ” F 1 = not(x.DNUM=5) or F 2

The Relational Calculus48 Basic Components of Q3 F 2 specifies the condition that must hold on all remaining tuples “ all PROJECT tuples controlled by department 5 ” F 2 = ((  w)(WORKS_ON(w) and e.SSN=w.ESSN and p.PNO=x.PNUMBER))

The Relational Calculus49 Safe Expressions A safe expression in relational calculus is one that is guaranteed to yield a finite number of tuples as its result; otherwise, the expression is called unsafe. Unsafe expression may yield infinite number of tuples, and the tuples may be different types.

The Relational Calculus50 Safe Expressions For example: {t | not(EMPLOYEE(t))} is unsafe. Yields all non-EMPLOYEE tuples in the universe.

The Relational Calculus51 Universal Quantifiers and Safe Expressions One must be careful when specifying universal quantification. Judicious to follow rules to ensure expression make sense. Otherwise, unsafe expressions may result.

The Relational Calculus52 Safe Expressions We discuss rules for safe expressions using the universal quantifier by looking at query Q3. Following the rules for Q3 discussed above guarantees safe expressions when using universal quantifiers. Using transformations from universal to existential quantifiers, can rephrase Q3 as Q3A

The Relational Calculus53 Example of Transforming Universal and Existential Quantifiers Q3A: {e.FNAME, e.LNAME | EMPLOYEE(e) and (not (  x)(PROJECT(x) and (x.DNUM=5) and (not (  w)(WORKS_ON(w) and e.SSN=w.ESSN and p.PNO=x.PNUMBER)))) } Q3A: {e.FNAME, e.LNAME | EMPLOYEE(e) and (not (  x)(PROJECT(x) and (x.DNUM=5) and (not (  w)(WORKS_ON(w) and e.SSN=w.ESSN and p.PNO=x.PNUMBER)))) }

The Relational Calculus54 Additional Examples (6) Query 6: Retrieve the names of employees who have no dependents. Query 6: Retrieve the names of employees who have no dependents.

The Relational Calculus55 Example Queries Using the Existential Quantifiers (6) Q6: {e.FNAME, e.LNAME | EMPLOYEE(e) and (not(  d)(DEPENDENT(d) and e.SSN=d.ESSN)) }

The Relational Calculus56 Example Queries Using the Universal Quantifiers (6) Q6: {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  d)(not (DEPENDENT(d)) or not (e.SSN=d.ESSN))) } Q6: {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  d)(not (DEPENDENT(d)) or not (e.SSN=d.ESSN))) }

The Relational Calculus57 Additional Examples (7) Query 7: List the names of managers who have at least one dependent. Query 7: List the names of managers who have at least one dependent.

The Relational Calculus58 Example Queries Using the Existential Quantifiers (7) Q7: {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  d)(  p)(DEPARTMENT(d) and (DEPENDENT(p) and e.SSN=d.MGRSSN and p.ESSN=e.SSN)) } Q7: {e.FNAME, e.LNAME | EMPLOYEE(e) and ((  d)(  p)(DEPARTMENT(d) and (DEPENDENT(p) and e.SSN=d.MGRSSN and p.ESSN=e.SSN)) }

The Relational Calculus59 Quantifiers in SQL The EXISTS function in SQL is similar to the existential quantifier of the relational calculus.

The Relational Calculus60 Quantifiers in SQL SELECT … FROM … WHERE EXISTS (SELECT * FROM R AS X WHERE P(X)) SELECT … FROM … WHERE EXISTS (SELECT * FROM R AS X WHERE P(X))

The Relational Calculus61 Quantifiers in SQL SQL does not include a universal quantifier. Use of a negated existential quantifier not (  x) by writing NOT EXISTS is how SQL supports universal quantification.