Presentation is loading. Please wait.

Presentation is loading. Please wait.

Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.

Similar presentations


Presentation on theme: "Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في."— Presentation transcript:

1 Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع الاساسي للمادة هي الكتاب المعتمد في وصف المقرر

2 Functional Dependencies FDs Chapter 10-2  FDs specify semantic constraints among the attributes of a relation schema 2  The most single important concept in relational schema design theory is a Functional Dependency FD 2

3 Functional Dependencies FDs Chapter 10-3 3  A set of attributes X functionally determines a set of attributes Y if the value of X determines a unique value for Y ABCD a1b1c1d1 a1b1c1d2 a1b2c2d1 a2b1c3d1 A and B determine C 3

4 Functional Dependencies Chapter 10-4 ABCD a1b1c1d1 a1b1c1d2 a1b2c2d1 a2b1c3d1 4  The first two tuples show that a FD is not the same as key constraint (AB is not a key)  The third and fourth tuples show that if two tuples differ in either A or B, they can differ in C without violating the FD  If we add tuple(a1, b1, c2, d1) the resulting instance would violate the FD 4

5 Functional Dependencies Chapter 10-5  FD written as X → Y and read as X functionally determines Y, or simply as X determine Y  X → Y holds if whenever two tuples have the same value for X, they must have the same value for Y  X → Y if and only if  For any two tuples t 1 and t 2 in any relation instances r(R) If t 1 [X]=t 2 [X] then t 1 [Y]=t 2 [Y]  If K is a key of R, then K functionally determines all attributes in R (since we never have two distinct tuples with t 1 [K]=t 2 [K]) 5 5

6 Functional Dependencies Chapter 10-6  FDs are derived from the real-world constraints on the attributes, for example  Social security number determines employee name SSN → ENAME  Project number determines project name and location PNUMBER → {PNAME, PLOCATION}  SSN and project number determines the hours per week that the employee works on the project {SSN, PNUMBER} → HOURS 6 6

7 Functional Dependencies 7  FD is a property of the semantics of attributes  The database designers will use their understanding of the semantics of the attributes and how they relate to one another, then specify the FDs that should hold on all relation states(Extensions) 7

8 Functional Dependencies 8  FDs cannot be inferred automatically from a given relation extension, but must be define explicitly by someone who knows the semantics of the attributes TEACHERCOURSEAuthor SmithData StructureBartram SmithData ManagementAl-Nour HallCompilerHoffman BrownData StructureSahny 8

9 Functional Dependencies 9  Although, at first glance we may think that Author → COURSE, we cannot confirm this unless we know that it is true for all possible legal state  However, it is sufficient to present a single counter example to disprove a FD, for example  Because Smith teach both Data Structure and Data Management we can conclude TEACHER does not functionally determine COURSE 9

10 Functional Dependencies 10  Relation Extensions r(R) that satisfy the FD are called Legal Extensions  The main use of FDs is to describe further a relation schema by specifying constraints on its attributes that must hold at all times  Certain FDs can be specified without referring to a specific relation, for example  {STATE, DRIVER_LICENCE_NUMBER } → SSN Should hold for any adult in the USA 10

11 Inference Rules for FDs Chapter 10-11  Practically, it is difficult to specify all possible FDs for a given relation  Typically, the designer specifies the FDs that are semantically obvious (denoted by F)  Usually, however, numerous other FDs hold in all legal relation instances  The other dependencies can be inferred or deduced from FDs in F 11

12 Inference Rules for FDs Chapter 10-12  For example, if each department has one manager then DEPT_NO → MGR_SSN  A manager has a unique phone number then MGR_SSN → MGR_PHONE  These two dependencies together imply that DEPT_NO → MGR_PHONE  This is an inferred FD and need not be explicitly stated  Formally, Given a set F of FDs, the closure F + of that set is the set of all FDs that can be inferred from F 12

13 Inference Rules for FDs Chapter 10-13  For example, Suppose that we specify the following set F = { SSN → {ENAME, BDATE, ADDRESS, DNUMBER}, DNUMBER → {DNAME, DMGRSSN} }  We can infer additional FDs SSN → {DNAME, DMGRSSN} SSN → SSN DNUMBER → DNAME 13

14 Inference Rules for FDs 14  An FD X → Y is inferred from a set of dependencies F specified on R if X → Y holds in every legal relation state r of R  To determine a systematic way to infer dependencies, we must discover a set of inference rules that can be used to infer new dependencies from a given set of dependencies  The notation  Is used to denote that the FD X → Y is inferred from the set of FDs F 14

15 Inference Rules for FDs Armstrong's inference rules Chapter 10-15  IR 1. (Reflexive)  If Y subset-of X, then X → Y  IR 2. (Augmentation)  If X → Y, then XZ → YZ (Notation: XZ stands for X U Z)  IR 3. (Transitive)  If X → Y and Y → Z, then X → Z 15

16 Inference Rules for FDs Chapter 10-16  IR 1, IR 2, IR 3 are Complete & Sound set of inference rules  Complete  All FDs implied by F can be derived by these rule  Repeated application of these rules will generate all FDs in F +  Sound  No additional FDs can be so derived  They generate only FDs in F +  In other word, these rules can be used to derive precisely the closure F + 16

17 Inference Rules for FDs Chapter 10-17  Several further rules can be derived from the three already given  Self determination X → X  Composition If X → Y and W → Z then XW → YZ  Decomposition If X → YZ, then X → Y and X → Z  Union If X → Y and X → Z, then X → YZ  (Psuedotransitivity) If X → Y and WY → Z, then WX → Z 17

18 Inference Rules for FDs Chapter 10-18 Proof Decomposition If X → YZ, then X → Y and X → Z 1. X → YZ (Given) 2. YZ → Y (IR 1 ) 3. X → Y ( IR 3 On 1, 2 ) Proof Union If X → Y and X → Z, then X → YZ 1. X → Y (Given) 2. X → Z (Given) 3. X → XY (IR 2 On 1 By augmenting with X Notice XX=X) 4. XY → YZ (IR 2 On 2 By augmenting with Y) 5. X → YZ (IR 3 On 3,4) 18

19 Inference Rules for FDs Chapter 10-19 Proof Psuedotransitivity If X → Y and WY → Z, then WX → Z 1. X → Y (Given) 2. WY → Z (Given) 3. WX → WY ( IR 2 On 1 By augmenting with W ) 4. WX → Z ( IR 3 On 3, 2) Proof Composition If X → Y and W → Z then XW → YZ 1. X → Y (Given) 2. W → Z (Given) 3. ZX → YZ (IR 2 On 1 By augmenting with Z) 4. XW → ZX (IR 2 On 2 By augmenting with X) 5. XW → YZ (IR 3 On 3,4) 19


Download ppt "Functional Dependencies and Normalization for Relational Databases 1 Chapter 15 تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في."

Similar presentations


Ads by Google