{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# R 5 r s 5 r s r s 5 r s s r to see that this

This preview shows pages 4–6. Sign up to view the full content.

r ) 5 R S (( 5 R S ( r ) × s ) 5 R S , S ( r )) To see that this expression is true, we observe that 5 R S ( r ) gives us all tuples t that satisfy the Frst condition of the deFnition of division. The expression on the right side of the set difference operator 5 R S (( 5 R S ( r ) × s ) 5 R S , S ( r )) serves to eliminate those tuples that fail to satisfy the second condition of the deFnition of division. Let us see how it does so. Consider 5 R S ( r ) × s . This relation is on schema R , and pairs every tuple in 5 R S ( r ) with every tuple in s . The expression 5 R S , S ( r ) merely reorders the attributes of r . Thus, ( 5 R S ( r ) × s ) 5 R S , S ( r ) gives us those pairs of tuples from 5 R S ( r )and s that do not appear in r .Ifatuple t j is in 5 R S (( 5 R S ( r ) × s ) 5 R S , S ( r )) then there is some tuple t s in s that does not combine with tuple t j to form a tuple in r .Thus , t j holds a value for attributes R S that does not appear in r ÷ s . It is these values that we eliminate from 5 R S ( r ). 6.5 Let the following relation schemas be given: R = ( A , B , C ) S = ( D , E , F ) Let relations r ( R )and s ( S ) be given. Give an expression in the tuple rela- tional calculus that is equivalent to each of the following: a. 5 A ( r ) b. s B = 17 ( r ) c. r × s d. 5 A , F ( s C = D ( r × s )) Answer: a. { t |∃ q r ( q [ A ] = t [ A ]) } b. { t | t r t [ B ] = 17 } c. { t |∃ p r q s ( t [ A ] = p [ A ] t [ B ] = p [ B ] t [ C ] = p [ C ] t [ D ] = q [ D ] t [ E ] = q [ E ] t [ F ] = q [ F ])

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

View Full Document
Practice Exercises 5 d. { t |∃ p r q s ( t [ A ] = p [ A ] t [ F ] = q [ F ] p [ C ] = q [ D ] } 6.6 Let R = ( A , B , C ), and let r 1 and r 2 both be relations on schema R .Give an expression in the domain relational calculus that is equivalent to each of the following: a. 5 A ( r 1 ) b. s B = 17 ( r 1 ) c. r 1 r 2 d. r 1 r 2 e. r 1 r 2 f. 5 A , B ( r 1 ) 1 5 B , C ( r 2 ) Answer: a. { < t > |∃ p , q ( < t , p , q > r 1 ) } b. { < a , b , c > | < a , b , c > r 1 b = 17 } c. { < a , b , c > | < a , b , c > r 1 < a , b , c > r 2 } d. { < a , b , c > | < a , b , c > r 1 < a , b , c > r 2 } e. { < a , b , c > | < a , b , c > r 1 < a , b , c > 6∈ r 2 } f. { < a , b , c > |∃ p , q ( < a , b , p > r 1 < q , b , c > r 2 ) } 6.7 Let R = ( A , B )and S = ( A , C ), and let r ( R )and s ( S )bere la t ions .W r i te expressions in relational algebra for each of the following queries: a. { < a > |∃ b ( < a , b > r b = 7) } b. { < a , b , c > | < a , b > r < a , c > s } c. { < a > |∃ c ( < a , c > s ∧∃ b 1 , b 2 ( < a , b 1 > r < c , b 2 > r b 1 > b 2 )) } Answer: a. 5 A ( s B = 17 ( r )) b. r 1 s c. 5 A ( s 1 ( 5 r . A ( s r . b > d . b ( r
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page4 / 8

r 5 R S 5 R S r s 5 R S S r To see that this expression is...

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

View Full Document
Ask a homework question - tutors are online