The normal forms (NF) of relational database theory provide criteria for determining a table’s degree of vulnerability to logical inconsistencies and anomalies.
2. Learning outcomes:
a) Explain the term normal form
b) Give examples of tables in normal forms
c) Identify determinants of normal forms
d) Explain the concept foreign keys
3. NORMAL FORMS
The normal forms (NF) of relational database theory
provide criteria for determining a table’s degree of
vulnerability to logical inconsistencies and anomalies.
4. Database normalization
Normalization is the process of organizing the
columns (attributes) and tables (relations) of a
relational database to reduce data redundancy and
improve data integrity.
5. Characteristics of
normalization includes:
1. The minimal number of attributes necessary to
support the data requirements of the enterprise.
2. Attributes with a close logical relationship are
found in the same relation.
3. Minimal redundancy with each attribute
represented only once with important exception
of attributes that form all or part of foreign keys.
6. FIRST NORMAL FORM
A relation is in first normal form if and only if the domain of each
attribute contains only atomic (indivisible) values, and the value of
each attribute contains only a single value from that domain.
First normal form enforces these criteria:
1. Eliminate repeating groups in individual tables.
2. Create a separate table for each set of related data/table.
3. Identify each set of related data/table with a primary key
7. The following scenario illustrates how a
database design might violate first normal
form.
Customer
Customer ID First Name Surname
Telephone
Number
123 Pooja Patel
555-861-2025,
192-122-1111
456 Zhang San
(555) 403-1659
Ext. 53; 182-929-
2929
789 John Doe 555-808-9633
8. A design that complies with
1NORMAL FORM
Customer
Customer ID First Name Surname
Telephone
Number
123 Pooja Patel 555-861-2025
123 Pooja Patel 192-122-1111
456 Zhang San 182-929-2929
456 Zhang San
(555) 403-1659
Ext. 53
789 John Doe 555-808-9633
9. A design that also complies
with higher normal forms
Customer Name
Customer ID First Name Surname
123 Pooja Patel
456 Zhang San
789 John Doe
Customer Telephone Number
Customer ID Telephone Number
123 555-861-2025
123 192-122-1111
456 (555) 403-1659 Ext. 53
456 123-567-1234
789 555-808-9633
10. Second normal form (2NF)
A table is in 2NF if it is in 1NF and every non-prime attribute
of the table is dependent on the whole of every candidate
key.
A non-prime attribute of a table is an attribute that is not a
part of any candidate key of the table.
2NF enforces these criteria:
1. Remove subsets of data that apply to multiple rows of a
table and place them in separate tables.
2. Create relationship between these new tables and their
predecessors through the use of foreign key.
11. A VIOLATION OF 2NF
Electric Toothbrush Models
Manufacturer Model Model Full Name
Manufacturer
Country
Forte X-Prime Forte X-Prime Italy
Forte Ultraclean Forte Ultraclean Italy
Dent-o-Fresh EZbrush
Dent-o-Fresh
EZbrush
USA
Kobayashi ST-60 Kobayashi ST-60 Japan
Hoch Toothmaster Hoch Toothmaster Germany
Hoch X-Prime Hoch X-Prime Germany
12. A VIOLATION OF 2NF
Even if the designer has specified the
primary key as {Model Full Name}, the
table is not in 2NF. {Manufacturer,
Model} is also a candidate key, and
Manufacturer Country is dependent on a
proper subset of it: Manufacturer. To
make the design conform to 2NF, it is
necessary to have two tables:
13. Electric Toothbrush Manufacturers
Manufacturer Manufacturer Country
Forte Italy
Dent-o-Fresh USA
Kobayashi Japan
Hoch Germany
Electric Toothbrush Models
Manufacturer Model Model Full Name
Forte X-Prime Forte X-Prime
Forte Ultraclean Forte Ultraclean
Dent-o-Fresh EZbrush
Dent-o-Fresh
EZbrush
Kobayashi ST-60 Kobayashi ST-60
Hoch Toothmaster
Hoch
Toothmaster
Hoch X-Prime Hoch X-Prime
14. Third normal form (3NF)
Third Normal form applies that every non-prime
attribute of a table must be dependent on primary
key.
3NF enforces the following criteria:
1. That the table must conform to both 1NF and
2NF
2. Remove columns that are not fully dependent
on the primary key
3. Create relationship between these new tables
and their predecessors through the use of
foreign key.
For example, consider a table with the following
fields:
15. Student_Detail Table
Student_id Student_name DOB Street city State Zip
In this table Student_id is Primary key, but street, city and
state depends upon Zip. The dependency between zip and
other fields is called transitive dependency. Hence to apply
3NF, we need to move the street, city and state to new table,
with Zip as primary key.
New Student_Detail Table
Student_id Student_name DOB Zip
Address Table
Zip Street city state
16. The advantage of removing transitive dependency is,
1. Amount of data duplication is reduced.
2. Data integrity is achieved.
17. ASSIGNMENT
1. Read up: “ Entity-Relationship model”.
2. Explain the differences between primary, candidate
and foreign keys.
18. Terminologies:
1. A superkey is defined in the relational model of database
organization as a set of attributes of a relation variable for
which it holds that in all relations assigned to that variable,
there are no two distinct tuples (rows) that have the same
values for the attributes in this set.
2. Candidate key – is a minimal superkey for a relation in a
table.
3. Foreign key – is a field in a relational table that matches a
candidate key of another table.
4. Normalization –
5. Anomalies – irregularities, variance, abnormalities etc.
6. Inconsistencies – discrepancies, contradictions etc.
7. Redundancies – severances, joblessness, dismissals etc.
Editor's Notes
A functional dependency on part of any candidate key is a violation of 2NF. In addition to the primary key, the table may contain other candidate keys; it is necessary to establish that no non-prime attributes have part-key dependencies on any of these candidate keys.
Multiple candidate keys occur in the following table: