This is a brief quick description of database normalization.Database normalization is the process of organizing information in a relational database into tables to minimize redundancy.Normalizing a database allows scalability and it is easier to maintain, query and work with.
There are 5 steps to normalize a database, my personal experience is that unless it is absolutely necessary, you are in best shape when you get to step four. Going to step 5 may decrease performance in your database.
There are 5 database normalization steps:
First Normalization Step
- Eliminate duplicate columns on tables
- Create separate tables for each groups
- Identify primary keys for each row
Second Normalization Step
- Remove subsets of data that apply to multiple rows of a table
- Create relationships between these new tables using foreign keys
Third Normalization Step
Remove columns that are not dependent on the primary key
Fourth Normalization Step
Every row must have a combination of attributes that can be uniquely identified without any extraneous data – primary key
Fifth Normalization Step
A relation is on Fourth Normalization when there are no rows with any duplicated data
Primary key: is a unique identifier for each record in a table. A primary key can comprise multiple fields, one informational field like email address or social security number, or it can be generated by the database.
Foreign key: is a field or set of fields in one table that uniquely identifies a row of another number table: car color or car color and year.
Relationships: a relationship exits between two tables, one has a foreign key referenced to another table.There are 3 relationship types:
- One to one: one to one relationships can only have one record on each side of the relationship: a car can only have one outside color
- One to many: one table can have multiple relations to another table: a car can have 2 or more interior colors
- Many to Many: tables can have multiple records related to multiple records on another table: a person can work at multiple companies, you need a third table to relate these kind of relationships