Example:Superkey Drinkers(name,addr,beersLiked,manf, favBeer) {name,beersLiked}is a superkey because together these attributes determine all the other attributes. name->addr favBeer beersLiked -manf 11
11 Example: Superkey Drinkers(name, addr, beersLiked, manf, favBeer) z {name, beersLiked} is a superkey because together these attributes determine all the other attributes. – name -> addr favBeer – beersLiked -> manf
Example:Key {name,beersLiked}is a key because neither {name}nor {beersLiked}is a superkey. name doesn't->manf;beersLiked doesn't->addr. There are no other keys,but lots of superkeys. Any superset of {name,beersLiked). 12
12 Example: Key z {name, beersLiked} is a key because neither {name} nor {beersLiked} is a superkey. – name doesn’t -> manf; beersLiked doesn’t -> addr. z There are no other keys, but lots of superkeys. – Any superset of {name, beersLiked}
Where Do Keys Come From? 1.Just assert a key K. The only FD's are K->A for all attributes A. 2. Assert FD's and deduce the keys by systematic exploration. 3. More FD's From "Physics" Example:no two courses can meet in the same room at the same time"tells us: hour room -course. 13
13 Where Do Keys Come From? 1. Just assert a key K. – The only FD’s are K -> A for all attributes A. 2. Assert FD’s and deduce the keys by systematic exploration. 3. More FD’s From “Physics” - Example: “no two courses can meet in the same room at the same time” tells us: hour room -> course
Three ways: 1.A simple test for it 2. Use FD to deduce 3 Calculate closure of y Inferring FD's We are given FD's X1 -A1,X2->A2,.Xn-> A,and we want to know whether an FD Y-> B must hold in any relation (instance)that satisfies the given FD's. Example:If A->B and B->C hold,surely A->C holds,even if we don't say so. Important for design of good relation schemas. 14
14 Inferring FD’s z We are given FD’s X1 -> A1, X2 -> A2,…, Xn -> An , and we want to know whether an FD Y -> B must hold in any relation (instance) that satisfies the given FD’s. – Example: If A -> B and B -> C hold, surely A -> C holds, even if we don’t say so. z Important for design of good relation schemas. Three ways: 1. A simple test for it 2. Use FD to deduce 3. Calculate closure of y
1:Inference Test To test if Y->B,start by assuming two tuples agree in all attributes of Y. Y 0000000...0 00000??...? 15
15 1: Inference Test z To test if Y -> B, start by assuming two tuples agree in all attributes of Y. Y 0000000. . . 0 00000?? . . . ?