9 Normalization
9 Normalization
Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 1 / 18
Keys
What is key
b A key is a column or set of columns that uniquely identifies each row in a table.
- Super key: a super key is a combination of one or more columns that uniquely identifies
each row in a table. It may contain additional columns that are not necessary to
uniquely identify each row. Example
b Terms used interchangibly
Table ⇔ Relation
Column ⇔ Attribute
Row ⇔ Tuple
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 2 / 18
Keys Type of Keys
Super Key
b A super key is a combination of one or more attribute that uniquely identifies each
tuple in a relation. It may contain additional columns that are not necessary to
uniquely identify each row.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 3 / 18
Keys Type of Keys
Super Key
b A super key is a combination of one or more attribute that uniquely identifies each
tuple in a relation. It may contain additional columns that are not necessary to
uniquely identify each row.
b student (rollNo, stdName, fathersName, mothersName, dob, gender,
address, emailID, enrollProgram, doa, aadharNo)
b List of super keys
- rollNo
- rollNo, emailID
- rollNo, stdName
- stdName, mothersName
- stdName, fathersName, mothersName
- stdName, mothersName, dob
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 3 / 18
Keys Type of Keys
Super Key
b A super key is a combination of one or more attribute that uniquely identifies each
tuple in a relation. It may contain additional columns that are not necessary to
uniquely identify each row.
b student (rollNo, stdName, fathersName, mothersName, dob, gender,
address, emailID, enrollProgram, doa, aadharNo)
b List of super keys
- rollNo
- rollNo, emailID
- rollNo, stdName
- stdName, mothersName
- stdName, fathersName, mothersName
- stdName, mothersName, dob
b Sufficient but not necessary: All the attributes in a super key may not be necessary
to uniquely identify a tuple in a relation. Example: (stdName, fathersName,
mothersName) .
.
.
.
.
. . . . .
. . . .
. . . .
. . . .
. . . .
. . . . .
.
.
.
.
.
.
.
.
.
Candidate Key
b A set of minimal attribute(s) that can identify each tuple uniquely in a given relation
is called as a candidate key.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 4 / 18
Keys Type of Keys
Candidate Key
b A set of minimal attribute(s) that can identify each tuple uniquely in a given relation
is called as a candidate key.
b student (rollNo, stdName, fathersName, mothersName, dob, gender,
address, emailID, enrollProgram, doa, aadharNo)
b List of Candidate keys
- rollNo
- emailID
- aadharNo
- stdName, mothersName
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 4 / 18
Keys Type of Keys
Candidate Key
b A set of minimal attribute(s) that can identify each tuple uniquely in a given relation
is called as a candidate key.
b student (rollNo, stdName, fathersName, mothersName, dob, gender,
address, emailID, enrollProgram, doa, aadharNo)
b List of Candidate keys
- rollNo
- emailID
- aadharNo
- stdName, mothersName
1 Determine the candidate keys: A candidate key is a minimal set of attributes that can
uniquely identify a record in the table. Identify all the candidate keys for the table.
2 Determine the non-candidate keys: A non-candidate key is any set of attributes that
is not a candidate key but can still uniquely identify a record in the table. Identify all
the non-candidate keys for the table.
3 Combine candidate and non-candidate keys: Combine each candidate key with each
non-candidate key to create a set of possible super keys.
4 Eliminate duplicates: Remove any duplicate sets of attributes from the list of possible
super keys.
5 Count the number of super keys: Count the number of remaining sets of attributes in
the list. This is the number of super keys for the table.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 5 / 18
Keys Type of Keys
1 Determine the candidate keys: The empID is a candidate key because it is a unique identifier
for each employee.
2 Determine the non-candidate keys: No non-candidate keys.
3 Combine candidate and non-candidate keys: Only one candidate key
4 Eliminate duplicates: There are no duplicates to eliminate.
5 Count the number of super keys: There is only one super key for this. table, which is the empID
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 6 / 18
Keys Type of Keys
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A)
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A) × (A → B)
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A) × (A → B) ✓
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A) × (A → B) ✓ × (CE → D)
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A) × (A → B) ✓ × (CE → D) ✓
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A) × (A → B) ✓ × (CE → D) ✓ × (C → F)
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A) × (A → B) ✓ × (CE → D) ✓ × (C → F)
Thus, prime attribute of R is C and E
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
1 Compute prime attributes. (Check for attributes, which are not in the dependent side)
A B C D E F
× (E → A) × (A → B) ✓ × (CE → D) ✓ × (C → F)
Thus, prime attribute of R is C and E
2 Find the closure of C and E, i.e. {CE}+
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 7 / 18
Keys Type of Keys
Compute closure
C → F
E → A
CE → D
A → B
Find the closure of C and E, i.e. {CE}+ from the above dependencies.
{CE}+ = { C , E }
= { C , E , F} Using C → F
= { A , C , E , F} Using E → A
= { A , C , D , E , F} Using CE → D
= { A , B , C , D , E , F } Using A → B
Thus, CE can determine all attributes of R. So, only possible candidate key is CE
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 8 / 18
Keys Type of Keys
Given, R = (A, B, C, D, E, F)
Super key may contain additional attribute(s) that are not necessary to uniquely identify each row,
whereas, candidate key is the minimal super key. Removing any attribute from the Candidate key
fails to identify the each tuple uniquely.
C and E are the prime attribute. To identify a tuple uniquely, the prime attributes must exists in
the super key. Out of 6 attributes in relation R, 4 attributes are none-prime. Thus, to identify a
tuple uniquely, 24 ways we can arrange the non-prime attributes along with prime attributes.
prime attribute)
Minimum super key count = 2(non
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 9 / 18
Keys Type of Keys
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 10 / 18
Keys Type of Keys
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 10 / 18
Keys Type of Keys
Normalization
Outcome of normalization
b The normal form of a relation refers to the highest normal form condition that it
meets, and hence indicates the degree to which it has been normalized
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 12 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 13 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 13 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 13 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 13 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 13 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 14 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 14 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 16 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 16 / 18
Normalization Normalization
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 18 / 18
Normalization Normalization
- Join dependency exists in a relation R if and only if R can be expressed as a natural join
of two or more other relations, such that the projection of R on any of its subsets is the
natural join of the projections of the other relations on that subset.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 18 / 18
Normalization Normalization
- Join dependency exists in a relation R if and only if R can be expressed as a natural join
of two or more other relations, such that the projection of R on any of its subsets is the
natural join of the projections of the other relations on that subset.
b A relation is said to be in 5NF, if the relation is in 4NF and there are no cyclic
dependencies.
b This is also called cyclic dependency. A cyclic dependency can occur only when
multi-field primary key consisting of three or more fields.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
N. Saharia Database Management Systems 18 / 18