ch4关系数据库设计原理解析.ppt
文本预览下载声明
第4章:关系数据库设计理论 Relational Database Design 不合理的关系模式带来的问题 函数依赖和范式的定义 多值依赖及第4范式 函数依赖理论 关系的规范化 Functional Dependencies (Cont.) Functional Dependencies (Cont.) 函数依赖是现实世界数据关联的形式之一。 Example3. FIRST(sno,city,zip,pno,qty) Functional Dependencies(Cont.) K is a candidate key(候选码)for R if and only if K ? R, and for no ? ? K, ? ? R Example4. R=(SN,CN,GRADE) (SN,CN)?GRADE SN?GRADE CN)?GRADE Multivalued Dependencies (Cont.) Multivalued Dependencies (MVDs) 设:R是属性集U上的一个关系模式,X,Y和Z都是U的子集,并且Z = U–X–Y.多值依赖X ?? Y成立,当且仅当对于关系模式R的任意一个关系r,r在X上的一个值对应唯一一组Y值,且这组Y值与Z的值无关。 MVD (Cont.) Tabular representation of ? ?? ? 设关系模式R ? 1NF。如果对于R的每个非平凡多值依赖 X ?? Y,X都是超码,则R ?4NF。 Closure of a Set of Functional Dependencies Example15. R = (A, B, C, G, H, I)F = { A ? B, A ? C,CG ? H, CG ? I, B ? H} some members of F+ A ? H by transitivity from A ? B and B ? H AG ? I by augmenting A ? C with G, to get AG ? CG and then transitivity with CG ? I CG ? HI from CG ? H and CG ? I AG ? H From A ? C and CG ? H ……………….. 4.3.属性的闭包Closure of Attribute Sets F为属性集U上给定的一组函数依赖,a,? ?U。 则 a+F称为属性集a关于函数依赖集F的闭包。 a+F = {?| a→?是所有由F给定和导出的函数依赖集合 }。 Example16. R(A,B,C),F={A→B,B→C} A+F ={ ABC } Algorithm to compute a+ F, the closure of a under F: result := a; while (changes to result) do for each ? ? ? in F do if ? ? result then result := result ? ? a+ F =result Example of Attribute Set Closure Example17. R = (A, B, C, G, H, I) F = {A ? B,A ? C, CG ? H,CG ? I, B ? H} (AG)+ PROCEDURE: 1. result = AG Result = ABCG (A ? C and A ? B) 3. result = ABCGH (CG ? H and CG ? AGBC) 4. result = ABCGHI (CG ? I and CG ? AGBCH) 4.4.属性闭包用途Uses of Attribute Closure 4.5 正则覆盖Canonical Cover R的依赖集F中有冗余的依赖存在 Eg: A?C is redundant in: {A?B, B?C,A?C} Parts of a functional dependency may be redundant E.g. on RHS: {A ? B, B ? C, A ? CD} can be simplified to {A ?B, B ? C,A ? D} E.g. on LHS: {A ? B, B ? C, ABC ? D} can be simplified to {A?B, B?C,AC?D} To compute a canonical cover for F: 应用分解规则,使F中每一个函数依
显示全部