Database Management System 16: Normalization
Database Management System 16: Normalization
Database Management System 16: Normalization
Chittaranjan Pradhan
Guidelines followed in
Chittaranjan Pradhan
School of Computer Engineering,
KIIT University
16.1
Normalization
Normalization
Chittaranjan Pradhan
Normalization
Normalization
Normalization is the process of decomposing or breaking a Lossless Decomposition
relation schema R into fragments (i.e. smaller schemas) R1 , Lossless - Join Algorithm
Dependency Preservation
R2 , ... Rn such that the following conditions hold: Guidelines followed in
Designing Good
• Lossless decomposition: The fragments should contain Database
A B
R1 R2 a 1
b 2
A B
a 1
R1 o
n R2 a 2
b 1
b 2
As R1 o
n R2 = R, the decomposition is lossless 16.3
Normalization
Lossless Decomposition...
Chittaranjan Pradhan
Normalization
A B Lossless Decomposition
a 1
R a 2
Lossless - Join Algorithm
Dependency Preservation
b 1 Guidelines followed in
Designing Good
Database
A
R1 a
b
B
R2 1
2
A B
a 1
R1 o
n R2 a 2
b 1
b 2
16.4
Normalization
Lossless Decomposition...
Chittaranjan Pradhan
Lossless Decomposition...
When the base relation schema is decomposed into the Normalization
Lossless Decomposition
fragmented relation schemas, the consecutive relations should Lossless - Join Algorithm
Dependency Preservation
be related by primary key - foreign key pair on the common
Guidelines followed in
column; so that natural join be possible on the common Designing Good
Database
column. Thus, we have to check whether the common column
is the key of any relation or not:
• If the common column is the key, the decomposition is
lossless
• If the common column is not the key, the decomposition is
lossy
Guidelines followed in
• Construct a table with n columns, where n is the number of Designing Good
Database
attributes in the original relation and k rows, where k is the
number of decomposed relations. Label the columns as
A1 , A2 , ... An
• Fill the entries in this table as follows: for each attribute Ai ,
check if this attribute is one of the attributes of the relation
schema Rj
• If attribute Ai is in the Relation Rj , then the entry (Ai , Rj ) of
the table will be ai
• If attribute Ai is not an attribute in the relation Rj , then the
entry (Ai , Rj ) of the table will be bij
• For each of FD X→Y of F, do the following until it is not
possible to make any more changes to the table. When the
table no longer changes, continue with step4
16.6
Normalization
Lossless - Join Algorithm...
Chittaranjan Pradhan
• If there are two or more rows with the same value under the Guidelines followed in
attribute or attributes of the determinant X, then make equal Designing Good
Database
their entries under attribute Y (i.e. RHS of FD)
• When making equal two or more entries under any column, if
one of them is ai , then make all of them ai
• If none of them is ai , then make all the entries uniform by
considering one b term. If they are bij and bkl , chose one of
these two values as the representative value and make the
other values equal to it. That means, make all the entries as
either bij or bkl . Continue with step3
• If there are no two rows with the same value under the
attribute or attributes of the determinant X, continue with
step3
• Check the rows of the table. If there is a row with its
entries equal to a1 , a2 ... an , then the decomposition is
lossless. Otherwise, the decomposition is lossy
16.7
Normalization
Lossless - Join Algorithm...
Chittaranjan Pradhan
Normalization
Lossless Decomposition
Lossless - Join Algorithm... Lossless - Join Algorithm
Dependency Preservation
R=(X, Y, Z), F={X→Y, Z→Y }, R1 =(X, Y), R2 =(Y, Z) Guidelines followed in
Designing Good
Database
A1 (X) A2 (Y) A3 (Z)
R1
R2
16.8
Normalization
Lossless - Join Algorithm...
Chittaranjan Pradhan
16.9
Normalization
Dependency Preservation
Chittaranjan Pradhan
(∪i Fi )+ = F +
A B C
1 2 3
R 2 2 3
3 2 3
4 3 4
Key=A
16.10
Normalization
Dependency Preservation...
Chittaranjan Pradhan
Normalization
Lossless Decomposition
A B Lossless - Join Algorithm
1 2 Dependency Preservation
A C
1 3
R2 = (A, C) and F={A→C} 2 3
3 3
4 4
16.11
Normalization
Dependency Preservation...
Chittaranjan Pradhan
Normalization
Lossless Decomposition
Lossless - Join Algorithm
A B Dependency Preservation
1 2
Guidelines followed in
R1 = (A, B) and F={A→B} 2 2 Designing Good
3 2 Database
4 3
B C
R2 = (B, C) and F={B→C} 2 3
3 4
Thus, (F1 ∪ F2 )+ = F +
16.12
Normalization
Guidelines followed in Designing Good Database
Chittaranjan Pradhan
Guideline 1
Normalization
Design a relation schema so that it is easy to explain its Lossless Decomposition
Lossless - Join Algorithm
meaning. Do not combine attributes from multiple entity sets Dependency Preservation
Guideline 2
Design the base relation schemas in such a way that the Normalization
Lossless Decomposition
anomalies such as insertion, deletion, or updation anomalies Lossless - Join Algorithm
Dependency Preservation
are removed from the relations
Guidelines followed in
Designing Good
Database
If any anomalies are present, note them clearly and make sure
that the programs that modify (update) the database will
operate correctly
Guideline 3
Avoid placing attributes in a base relation whose values may
frequently be NULL
Normalization
Lossless Decomposition
Lossless - Join Algorithm
Dependency Preservation
Guidelines followed in
Designing Good
Database
Guideline 4
Design the relation schemas so that they can be joined in a
such a way that no spurious tuples are generated
16.15