Berkeley COMPSCI 186 - Lecture Notes (3 pages)

Previewing page 1 of 3 page document View the full content.
View Full Document

Lecture Notes



Previewing page 1 of actual document.

View the full content.
View Full Document
View Full Document

Lecture Notes

109 views

Lecture Notes


Pages:
3
School:
University of California, Berkeley
Course:
Compsci 186 - Introduction to Database Systems
Introduction to Database Systems Documents

Unformatted text preview:

Relational Calculus R G Chapter 4 We will occasionally use this arrow notation unless there is danger of no confusion Relational Calculus Query has the form T p T p T is a formula containing T Answer tuples T for which p T true Ronald Graham Elements of Ramsey Theory Formulae Atomic formulae R Relation R a op S b R a op constant op is one of Free and Bound Variables Quantifiers and Use of X or X binds X A variable that is not bound is free Recall our definition of a query T p T A formula can be an atomic formula p p q p q p q R p R R p R Simple Queries Find all sailors with rating above 7 S S Sailors S rating 7 Find names and ages of sailors with rating above 7 S S1 Sailors S1 rating 7 S sname S1 sname S age S1 age Important restriction T must be the only free variable in p T all other variables must be bound using a quantifier Joins Find sailors rated 7 who ve reserved boat 103 S S Sailors S rating 7 R R Reserves R sid S sid R bid 103 Note S is a variable of 2 fields i e S is a projection of Sailors 1 Universal Quantification Joins continued Find sailors rated 7 who ve reserved a red boat Find sailors who ve reserved all boats S S Sailors S rating 7 R R Reserves R sid S sid B B Boats B bid R bid B color red S S Sailors B Boats R Reserves S sid R sid B bid R bid This may look cumbersome but it s not so different from SQL A trickier example Find sailors who ve reserved all Red boats S S Sailors B Boats B color red R R Reserves S sid R sid B bid R bid Alternatively S S Sailors B Boats B color red R R Reserves S sid R sid B bid R bid A Remark Unsafe Queries syntactically correct calculus queries that have an infinite number of answers Unsafe queries e g S S Sailors Solution Don t do that a b is the same as a b b T a F T T F F T T Expressive Power Expressive Power Theorem due to Codd Every query that can be expressed in relational algebra can be expressed as a safe query in relational calculus the converse is also true Relational Completeness Query language e g SQL can



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?