|
Example:
SSN is key in the relation Employee: +-----------+--------+---------+----------+ | ssn | fname | lname | salary | +-----------+--------+---------+----------+ | 123456789 | John | Smith | 30000.00 | | 333445555 | Frankl | Wong | 40000.00 | | 999887777 | Alicia | Zelaya | 25000.00 | | 987654321 | Jennif | Wallace | 43000.00 | | 666884444 | Ramesh | Narayan | 38000.00 | | 453453453 | Joyce | English | 25000.00 | | 987987987 | Ahmad | Jabbar | 25000.00 | | 888665555 | James | Borg | 55000.00 | +-----------+--------+---------+----------+ |
|
a natural functional dependency or a trivial functional dependency
|
|
Employee1(SSN, FName, LName, PNumber, PName, Hours) Keys: (SSN, PNumber) |
Example: a "good" functional dependency
SSN, PNumber → Hours is a "good" functional dependency (because SSN,PNumber is a key of Employee1) |
Example: some "bad" functional dependencies
SSN → fname, lname is a "bad" functional dependency
(SSN, fname, lname) should be taken out and put together
in another relation by their own
|
| SSN | FName | LName | PNumber | PName | Hours |
|---|---|---|---|---|---|
| 111-11-1111 | John | Smith | pj1 | DBApplet | 20 |
| 111-11-1111 | John | Smith | pj2 | WebServer | 10 |
| 111-22-3333 | Jane | Doe | pj1 | DBApplet | 5 |
PNumber → PName
(PNumber is not a key)
|
Why a bad functional dependency will cause anomalies:
|
Therefore:
|
And this fact will in turn cause:
|
(Insert and delete anomalies will follow with similar logic).
| SSN | FName | LName | PNumber | PName | Hours |
|---|---|---|---|---|---|
| 111-11-1111 | John | Smith | pj1 | DBApplet | 20 |
| 111-11-1111 | John | Smith | pj2 | WebServer | 10 |
| 111-22-3333 | Jane | Doe | pj1 | DBApplet | 5 |
The key is: (SSN, PNumber)
|
Therefore:
|
|
|
|
Example of decomposition:
Original relation:
Employee1( SSN, FName, LName, PNumber, PName, Hours )
|
Employee1(SSN, FName, LName, PNumber, PName, Hours) Decomposed into: R1(SSN, PName, Hours) R2(PNumber, FName, LName) what does this relation mean ??? |
Employee1(SSN, FName, LName, PNumber, PName, Hours)
Decomposed into:
R3(SSN, FName, LName) -- Employee info
R4(PNumber, PName) -- Project info
R5(SSN, PNumber, Hours) -- Info on who works on which project
|
|
Answer:
|
|