Quote:
Originally posted by winyun
Hi, all
I would like to ask some fundamental concept about the db design.
1. what is functional dependence in normalization?
2. can anyone give some examples on A->B, CD->E,etc. to illustrate the concept?
Thank you for your attention.
|
While A->B, CD->E examples are used in theoretical discussions, I think the best way for a beginner to understand the concept of functional dependence is with realistic examples.
Take the following attributes from an unnormalised relation:
Employee No = 123
Employee Name = Fred
Employee DOB = 01-Jan-1970
Dept No = 40
Dept Name = Payroll
This says that there is an Employee No 123 named Fred born on 01-Jan-1970, who work in Department 40 which is the Payroll department.
Employee No uniquely identifies an employee
Dept No uniquely identifies a department
There is a functional dependency A->B if given a value for A there is only one corresponding value for B. It should be clear that the following functional dependencies apply:
1) Employee No -> Employee Name, Employee DOB, Dept No, Dept Name
2) Dept No -> Dept Name
(i.e. given Employee No 123, there is only one corresponding Employee Name (Fred), Employee DOB (01-Jan-1970), Dept No (40) and Dept Name (Payroll); and further, given Dept No 40 there is only one corresponding Dept Name (Payroll).
We can therefore normalise the data to:
R1={Employee No, Employee Name, Employee DOB, Dept No}
R2={Dept No, Dept Name}
Note that Dept Name has been removed from R1 because it is not directly dependent on the key (Employee No), it is indirectly dependant via the Dept No. You can remove Dept Name from R1 without losing any information (because you still have Dept No and Dept No -> Dept name).
Now if I replace the meaningful names with A,B etc. and say that for R={A,B,C,D,E}
1) A -> B,C,D,E
2) D -> E
Then by same logic we can normalise to:
R1={A,B,C,D}
R2={D,E}