# Database Management/Normalization

This lesson introduces database normalization concepts.

## Objectives and Skills

Objectives and skills for this lesson include:
* Understand the purpose of database normalization.
* Apply database normalization concepts to a given dataset.

## Readings

* Wikipedia: Database normalization
* Wikibooks: Database Design/Normalization

## Multimedia

* YouTube: Database Normalization
* YouTube: Normalization - 1NF, 2NF, 3NF and 4NF
* YouTube: Data Modeling and the ER Model

## Activities

Design a normalized (3NF) database representing one or more of the following datasets. Each table must have multiple fields and no repeating groups, with each field dependent upon the entire primary key. This is a logical design only (do not use a DBMS). The physical design will be added in a future lesson. Use the following syntax to document your completed design. Use PascalCase for table and field names. Table names should be plural. Table1(PrimaryKey, Field2, Field3, ...) Table2(PrimaryKey, Field2, Field3, ...) ...
* A car dealership wants a database to track sales by customer, vehicle, and sales person.
* A college wants a database to track enrollment by student, course, and instructor.
* A company wants a database to track their organizational structure by department, employee, and location.
* A computer repair company wants a database to track repairs by customer, computer, and technician.
* A doctor's office wants a database to track patient visits by doctor, patient, and visit.
* A library wants a database to track books by title, author, and genre.
* A YouTube subscriber wants a database to track videos by subject, YouTuber, and playlist.
* Choose your own dataset similar to the above with at least three related entities.

## Lesson Summary

* Database normalization is a logical database design technique to structure a relational database in accordance with a series of normal forms in order to reduce data redundancy and improve data integrity.
* Normalization is a process of using normal forms to avoid logical design error occurrences within a database. Unnormalized database design will display database inconsistencies which will cause errors when inserting, deleting or updating record information.
* De-normalization is a process that changes relations from higher to lower normal forms and is done to improve the performance of retrieving relations from the database. It also reduces the cost to maintain a database because it requires less joins.
* Database normalization is a progressive process using different normal forms. A higher level of database normalization cannot be achieved unless the previous levels have been satisfied. Any relation that is in BCNF satisfies 3NF. Any relation in 3NF satisfies 2NF. Any relation in 2NF satisfies 1NF.
* A fully normalized database allows its structure to be extended to accommodate new types of data with slight changes to the existing structure.
* The basic normal forms (from least normalized to most normalized) include: UNF (unnormalized form); 1NF (first normal form), 2NF (second normal form), 3NF (third normal form).

## Key Terms
### alternate key

    A candidate key not chosen as the primary key.

### anomaly

    A deviation from a rule or from what is regarded as normal.

### Boyce-Codd normal form (BCNF)

    A slightly stronger version of third normal form (3NF).

### candidate key

    A column(s) in a table that can uniquely identify any database record without referring to any other data.

### decomposition

    The process of breaking down a relation into smaller relations in an attempt to normalize the database.

### first normal form (1NF)

    Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).

### functional dependency

    A relationship between two attributes, typically between the PK and other non-key attributes within a table.

### normal form

    Used to eliminate or reduce redundancy in database tables.

### primary key

    A column that uniquely identifies a particular row in a table.

### second normal form (2NF)

    Meets all the requirements of first normal form and removes subsets of data that apply to multiple rows of a table and place them in separate tables.

### third normal form (3NF)

    Meets all the requirements of second normal form and removes columns that are not dependent upon the primary key.

### unnormalized relation

    Contains data redundancy, where multiple values and/or complex data structures may be stored within a single field or attribute, or where fields may be replicated within a single table.

## See Also

* McFadyen: Relational Databases and Microsoft Access - Chapter 10 (Normalization)
* Microsoft: Description of the database normalization basics
* Geeks for Geeks: Normal Forms in DBMS
* Guru99: What is Normalization in DBMS?
* TutorialsPoint: DBMS Normalization
* TutorialsPoint: Difference between Normalization and Denormalization
* W3Schools: Database Normalization
* Watt: Database Design - Chapter 12 (Normalization)