L05 - Relational Query Languages Relational Calculus...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Relational Query Languages Relational Calculus
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS174A: Calculus 2 Relational Calculus ± Two flavors: Tuple relational calculus ( TRC ) Domain relational calculus ( DRC ) ± Calculus has variables , constants , comparison ops , logical connectives and quantifiers Variables range over (or get bound to) TRC : tuples (i.e. rows) DRC : domain elements (i.e. field values) Both TRC and DRC are subsets of first-order logic ± Expressions in the calculus are called formulas . An answer tuple is essentially an assignment to variables that makes the formula evaluate to true
Background image of page 2
CS174A: Calculus 3 ± Get the name and rating of sailors with rating at least 6 and older than 20 { ( n , r ) | ∃ s a Sailors ( s , n , r , a ) r ≥6 ∧ a >20} ± Get the red boats that are reserved by a sailor with rating at least 7 ( b ) b n s t Boats ( b , b n , “red” ) Reserves ( s , b , t ) ∧∃ n r a Sailors ( s , n , r , a ) r ≥7 DRC Examples Sailors (sid, sname, rating, age) Boats (bid, bname, color) Reserves (sid, bid, day)
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS174A: Calculus 4 Domain Relational Calculus (DRC) ± Query has the form: {( x 1 , x 2 , . .., x n ) | ϕ ( x 1 , x 2 , . .., x n )} ± Answer includes all tuples ( a 1 , a 2 , . .., a n ) that make the formula ϕ( a 1 , a 2 , . .., a n ) true ± Formula is recursively defined, starting with simple atomic formulas (checking tuples in relations or making comparisons of values), and building bigger and better formulas using the logical connectives
Background image of page 4
CS174A: Calculus 5 DRC Formulas ± Atomic formula : R ( x 1 , x 2 , . .., x
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/02/2010 for the course CS 174a taught by Professor Zhin during the Fall '09 term at UCSB.

Page1 / 15

L05 - Relational Query Languages Relational Calculus...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online