Chapter08BRelationalCalculus.pptx

# The formula tf is true if the formula f evaluates to

• 31

This preview shows pages 7–13. Sign up to view the full content.

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. Relational Calculus 7

This preview has intentionally blurred sections. Sign up to view the full version.

The Existential and Universal Quantifiers is called the universal or “for all” quantifier because every tuple in “the universe of” tuples must make F true to make the quantified formula true. is called the existential or “there exists” quantifier because any tuple that exists in “the universe of” tuples may make F true to make the quantified formula true. Relational Calculus 8
Example Query Using Existential Quantifier Retrieve the name and address of all employees who work for the ‘Research’ department. The query can be expressed as : {t.FNAME, t.LNAME, t.ADDRESS | EMPLOYEE(t) and  d) (DEPARTMENT(d) and d.DNAME=‘Research’ and d.DNUMBER=t.DNO) } The only free tuple variables in a relational calculus expression should be those that appear to the left of the bar ( | ). In above query, t is the only free variable; it is then bound successively to each tuple. If a tuple satisfies the conditions specified in the query, the attributes FNAME, LNAME, and ADDRESS are retrieved for each such tuple. The conditions EMPLOYEE (t) and DEPARTMENT(d) specify the range relations for t and d. The condition d.DNAME = ‘Research’ is a selection condition and corresponds to a SELECT operation in the relational algebra, whereas the condition d.DNUMBER = t.DNO is a JOIN condition. Relational Calculus 9

This preview has intentionally blurred sections. Sign up to view the full version.

Example Query Using Existential Quantifier Find the names of employees who work on all the projects controlled by department number 5. The query can be: {e.LNAME, e.FNAME | EMPLOYEE(e) and  x)(not(PROJECT(x)) or not(x.DNUM=5) OR  w)(WORKS_ON(w) and w.ESSN=e.SSN and x.PNUMBER=w.PNO))))} Exclude from the universal quantification all tuples that we are not interested in by making the condition true for all such tuples . The first tuples to exclude (by making them evaluate automatically to true) are those that are not in the relation R of interest. In query above, using the expression not(PROJECT(x)) inside the universally quantified formula evaluates to true all tuples x that are not in the PROJECT relation. Then we exclude the tuples we are not interested in from R itself. The expression not(x.DNUM=5) evaluates to true all tuples x that are in the project relation but are not controlled by department 5. Finally, we specify a condition that must hold on all the remaining tuples in R.  w)(WORKS_ON(w) and w.ESSN=e.SSN and x.PNUMBER=w.PNO) Relational Calculus 10
Safe Expressions Expressions using negation, the universal quantifier, and the existential quantifier must make sense An safe expression is one guaranteed to yield a finite number of tuples For example {t|NOT(employee(t))} is not safe Relational Calculus 11

This preview has intentionally blurred sections. Sign up to view the full version.

Languages Based on Tuple Relational Calculus The language SQL is based on tuple calculus. It uses the basic block structure to express the queries in tuple calculus: SELECT <list of attributes> FROM <list of relations> WHERE <conditions>
This is the end of the preview. Sign up to access the rest of the document.
• Fall '09
• SUNANHAN
• Relational model, Quantification, Universal quantification, QBE, Domain relational calculus

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern