Employee1(SSN, FName, LName, PNumber, PName, Hours)Represents employees and the projects that he works on.
| 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 transformation process consists of replacing the None-2NF relation by a set of projections of the original relation.
The original relation can be obtained by taking the natural join of the projections
NOTE: the natural join operation on two relations joins the relations using the equality condition for every attribute that they have in common. If the relations do not have any attribute in common, the natural join is equal to a cartesian product
Employee1
| 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 |
Employee = Projection(SSN,FName,LName) Project = Projection(PNumber,PName,Hours)
|
|
|
* |
|
= |
| SSN | FName | LName | PNumber | PName | Hours |
|---|---|---|---|---|---|
| 111-11-1111 | John | Smith | pj1 | DBApplet | 20 |
| 111-11-1111 | John | Smith | pj2 | WebServer | 10 |
| 111-11-1111 | John | Smith | pj1 | DBApplet | 5 |
| 111-22-3333 | Jane | Doe | pj1 | DBApplet | 20 |
| 111-22-3333 | Jane | Doe | pj2 | WebServer | 10 |
| 111-22-3333 | Jane | Doe | pj1 | DBApplet | 5 |
| 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 |
Take the same relation again: Employee1
| 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 |
Employee = Projection(SSN,FN,LN) Project = Projection(SSN,PNum,PName,Hours)
|
|
|
* |
|
= |
| 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 |
R1 * R2 = R
So to prove that the decomposition technique is useful, let us try to decompose the following relation:
R = (A, B, C, D, E, F, G) A -> B, C D -> E, F A,D -> G
In other words:
We CANNOT answer this question without first finding the key(s) !!!
(A, D)
B, C, E, F, G
No: A -> B, C
Compute: A+ to fond all the attributes that "belongs" to A
A+ = A B CDecompose (A, B, C, D, E, F, G) into:
R1 = (A, B, C) (A+) R2 = (A, D, E, F, G) (We need to satisfy Lemma 2 !)
R1 = (A, B, C) Key = A is in 2NF R2 = (A, D, E, F, G) Key = (A,D) is NOT in 2NF !!
Key = (A,D) Non-key attributes: E, F, G Violation: D -> E, F D+ = D E FDecompose R2 = (A, D, E, F, G) into
R3 = (D, E, F) R4 = (A, D, G)
(A, B, C) (D, E, F) (A, D, G)
A = SSN D = PNumber G = Hours B = FName E = PName C = LName F = ControllingDept A -> B, C D -> E, F A,D -> G Result: (SSN, FName, LName) (PNumber, PName, ControllingDept) (SSN, PNumber, Hours)