Introduction
Normalization refers to organising data within a database by creating tables, establishing relationships between them in order to protect the data and make the database more efficient and flexible. The second step in database normalization (after First Normal Form or 1NF) is the Second Normal Form or 2NF. A table can be in the Second Normal Form if it satisfies the following two conditions:
- The table must be in 1NF or First Normal Form.
- There must be no partial dependency, meaning all non-key attributes must fully depend on the primary key. (We will discuss partial dependency in detail in this article.)
The First Normal Form only eliminates repeating groups and not redundancy, while the Second Normal Form is all about full functional dependency and eliminates any partial dependency on primary keys. But what is partial dependency?
Let us first learn about some important terms needed to understand the topic better.
Key terms to understand for 2NF
Attribute: In relational databases, an attribute is a describing characteristic defining items under a single category in the cells of a column.
Candidate key: The candidate key can either be an attribute (column) or a group of attributes that uniquely identify every data item, i.e., all individual records in a relation or a table. We could say that the candidate key is a super key to records in the table.
Prime-attributes: The column in any candidate key will make a prime attribute.
Non-prime attributes: All other columns in a relation that do not occur in any candidate key are non-prime attributes.
Dependency: In a relation, dependency is a constraint defining a relationship between two or more attributes. Dependency occurs when data stored in the same table can be used to uniquely determine some other information stored in the table. There are various types of dependencies in relational databases including Functional Dependency, Fully-functionally Dependency, Transitive Dependency and Partial Dependency.
For the Second Normal Form, we mainly need to learn about partial dependency, and when we study 3NF, we will learn about transitive dependency in detail.