HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Decomposition of a relation to 2NF then to 3NF

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
2nf3nfthendecompositionrelation

Problem

I am having trouble decomposing a relation with given functional dependencies into 2NF then 3NF.

For example:

Relation R has attribute set
{A, B, C, D, E, F, G, H, I, J}


and functional dependency set
F
{
{A, B} -> {C},
{A} -> {D, E},
{B} -> {F},
{F} -> {G, H},
{D} -> {I,J}
}


I know to first work out the closure to find the key for R, and the key is
{A,B}`. Now I get stuck. My textbook doesn't give examples of how one can solve this, it just gives definitions of 2NF and 3NF.

How I can do this?

Solution

2NF: Remove Partial Dependencies

R with attribute set {A, B, C, D, E, F, G, H, I, J} includes partial dependencies.

D and E depend only on A, F depends only on B, G, H, I and J don't depend on the key (directly) at all.

R0 = {A, B, C}

R1 = {A, D, E, I, J}

R2 = {B, F, G, H}

R0, R1, and R2 contain no partial dependencies (or repeating groups) so they are 2NF. However R1 and R2 are still an issue, because they contain transitive dependencies.

3NF: Remove Transitive Dependencies

I and J depend on D, not on the key of R1. Therefore you need to further normalize R1 as follows:

R1 = {A, D, E, I, J}

R1a = {A, D, E}

R1b = {D, I, J}

Similarly, G and H depend only on F so R2 must be decomposed as follows:

R2 = {B, F, G, H}

R2a = {B, F}

R2b = {F, G, H}

All of your remaining relations (R0, R1a, R1b, R2a, R2b) are devoid of repeating groups, partial dependencies and transitive dependencies. That means our relations are in 3NF.

When you are looking at an relation that hasn't been normalized and a series of dependencies, you can often normalize by inspection just by recognizing what your primary keys are going to be. Any attribute or combination of attributes that functionally determine other attributes are going to end up as primary keys. Once you've got your primary keys defined, you just need to figure out which non-key attributes go with each key. This is obvious from the statement of what your functional dependencies are.

Context

StackExchange Database Administrators Q#31039, answer score: 8

Revisions (0)

No revisions yet.