Chapter 15 Relational Database Design Algorithms and Further
Chapter 15 Relational Database Design Algorithms and Further Dependencies 2018/05/22 otawa 1
Outline • 15. 1 Further Topics in Functional Dependencies: Inference Rules, Equivalence, and Minimal Cover • 15. 2 Properties of Relational Decompositions • 15. 3 Algorithms for Relational Database Schema Design • 15. 4 About Nulls, Dangling Tuples, and Alternative Relational Designs • 15. 5 Further Discussion of Multivalued Dependencies and 4 NF • 15. 6 Other Dependencies and Normal Forms • 15. 7 Summary 2
15. 1 Further Topics in Functional Dependencies: Inference Rules, Equivalence, and Minimal Cover 与えられた関数従属性(functional dependencies)から新 しい関数従属性を推論する • closure • equivalence • minimal cover 3
15. 1. 1 Inference Rules for Functional Dependencies 閉包(closure) 定義:与えられたFDの集合Fと、Fから推論される全てのFDを含んだ集合でありこれを F+と表す 例: F = {Ssn → {Ename, Bdate, Address, Dnumber}, Dnumber → {Dname, Dmgr_ssn} } Fから推論されるFDは Ssn → {Dname, Dmgr_ssn} Ssn → Ssn Dnumber → Dname これらの集合がF+ 6
15. 1. 1 Inference Rules for Functional Dependencies その他の推論規則 • IR 4 分解律(decomposition, or projective, rule): {X → YZ} |=X → Y • IR 5 合併律(union, or additive, rule): {X → Y, X → Z} |=X → YZ • IR 6 疑似推移律(pseudotransitive rule): {X → Y, WY → Z} |=WX → Z 10
15. 1. 1 Inference Rules for Functional Dependencies 例 R:CLASS ( Classid, Course#, Instr_name, Credit_hrs, Text, Publisher, Classroom, Capacity) FD 1: Sectionid → Course#, Instr_name, Credit_hrs, Text, Publisher, Classroom, Capacity; FD 2: Course# → Credit_hrs; FD 3: {Course#, Instr_name} → Text, Classroom; FD 4: Text → Publisher FD 5: Classroom → Capacity • { Classid } + = { Classid , Course#, Instr_name, Credit_hrs, Text, Publisher, Classroom, Capacity } = CLASS • { Course#} + = { Course#, Credit_hrs} 12
15. 2. 3 Nonadditive (Lossless) Join Property of a Decomposition 例1 どの列もaだけでは構成されていないのでこの分解は nonadditive join propertyを持っていない 25
15. 2. 3 Nonadditive (Lossless) Join Property of a Decomposition 例2 一番下の行がaのみで構成されているのでこの分解は nonadditive join propertyを持っている 26
15. 2. 4 Testing Binary Decompositions for the Nonadditive Join Property バイナリ分解(binary decomposition) • 関係Rを二つの関係に分解する • 分解の特殊なケース • nonadditive join propertyを持っているかのテストにア ルゴリズム 15. 3よりも簡単なNJBというものを使える (14章でやった) 27
15. 2. 5 Successive Nonadditive Join Decompositions Claim 2 Rの分解D = {R 1, R 2, . . . , Rm} がFに関してnonadditive join property を持っており、さらにRiの分解Di = {Q 1, Q 2, . . . , Qk} もRiにおけるF の射影に関してnonadditive join propertyを持っている場合 Rの分解D 2 = {R 1, R 2, . . . , Ri− 1, Q 2, . . . , Qk, Ri+1, . . . , Rm} もまた nonadditive join propertyを持っている 28
15. 3. 1 Dependency-Preserving and Nonadditive (Lossless) Join Decomposition into 3 NF Schemas 例1 universal relation U (Property_id, County, Lot#, Area) FD 1: Property_id → Lot#, County, Area FD 2: Lot#, County → Area, Property_id FD 3: Area → County 簡単のため省略表記にする • U (P, C, L, A ( • F: { P → LCA, LC → AP, A → C } 31
15. 3. 1 Dependency-Preserving and Nonadditive (Lossless) Join Decomposition into 3 NF Schemas • ステップ 3 Uのキーを含む関係が存在するのでOK • ステップ 4 冗長な関係は存在しないのでDependency Preservation と Nonadditive Join Property を持つ 3 NFスキーマは、 Y: S 1 (P, A, L), S 2 (L, C, P), S 3 (A, C) 34
15. 3. 1 Dependency-Preserving and Nonadditive (Lossless) Join Decomposition into 3 NF Schemas 例1、例2より次のことが言える • 同じuniversal relationとFDの集合から違う3 NF設計を することが可能 • このアルゴリズムはBCNFを満たす関係を生み出し、か つ dependency preservation propertyを 維持すること もある 35
15. 4 About Nulls, Dangling Tuples, and Alternative Relational Designs • 今まではNULL値がないことを前提にしていた • NULL値が存在すると問題が生じる可能性がある 38
15. 4. 1 Problems with NULL Values and Dangling Tuples NATURAL JOINする 39
15. 4. 1 Problems with NULL Values and Dangling Tuples • NATURAL JOINをすると結合される属性Dnumの値がNULLであ った二つのタプルは表示されなくなってしまう 40
15. 4. 1 Problems with NULL Values and Dangling Tuples • OUTER JOINをすれば結合される属性がNULLであるタプルも表 示される • LEFT OUTER JOINの例 41
15. 4. 1 Problems with NULL Values and Dangling Tuples • EMPLOYEEを図のように二つの関係に分解する • これらをNATURAL JOINすると元のEMPLOYEEが得られる 43
15. 4. 1 Problems with NULL Values and Dangling Tuples • ENPLOYEE_2の代わりにENPLOYEE_3の表記を用いる • ENPLOYEE_3はDnumがNULLであるタプルを含んでいない • これらをNATURAL JOINすると結果にBerger とBenitez のタプルが現れない →このようなタプルをダングリングタプル(dangling tuples)という 44
15. 5. 2 Fourth Normal Form Revisited • 48
15. 5. 3 Nonadditive Join Decomposition into 4 NF Relations • 51
15. 5. 3 Nonadditive Join Decomposition into 4 NF Relations • 52
55
56
15. 6. 3 Functional Dependencies Based on Arithmetic Functions and Procedures ORDER_LINE (Order#, Item#, Quantity, Unit_price, Extended_price, Discounted_price) • Extended_price = Unit_price * Quantityである、つまり(Quantity, Unit_price ) の組に対してExtended_priceの固有の値が決まるので (Quantity, Unit_price ) → Extended_price である • (Item#, Quantity, Unit_price ) → Discounted_price • (Item#, Quantity, Extended_price) → Discounted_price • これらのような算術的な関数従属性は多くの関係に現れるが、正規化の際に 特別注意されることはない 58
15. 7 Summary • 推論規則(inference rules) • 閉包(closure) • 極小被覆(minimal cover) • nonadditive join property • dependency-preserving property • MVD • 包含従属性(inclusion dependencies) • ドメインキー正規形(DKNF) 60
- Slides: 60