Database normalization is the process of organizing the attributes and tables of a relational database to minimize data redundancy.
Normalization involves decomposing a table into less redundant (and smaller) tables but without losing information.
Normalization can also improve the scalability of a database, as it allows you to add new data more easily without affecting the structure of the existing data.
1st normalization form
- В таблице не должно быть дублирующих строк
- В каждой ячейке таблицы хранится атомарное значение (одно не составное значение)
- В столбце хранятся данные одного типа
- Отсутствуют массивы и списки в любом виде
2nd normalization form
- Таблица должна находиться в первой нормальной форме
- Таблица должна иметь ключ
- Все неключевые столбцы таблицы должны зависеть от полного ключа (в случае если он составной).
- Ключ – это столбец или набор столбцов, по которым гарантировано можно отличить строки друг от друга, т.е. ключ идентифицирует каждую строку таблицы. По ключу мы можем обратиться к конкретной строке данных в таблице
- Use decomposition to split 1 table into 2.
- Decomposition — it is the process of splitting one relation (table) into several.
3rd normalization form
- There is no transitive dependency for non-prime attributes
- If A->B and B->C are two FDs then A->C is called transitive dependency
- Solution: decomposition — create new tables.
Boyce Codd Normal Form
- Ключевые атрибуты составного ключа не должны зависеть от неключевых атрибутов.
Student ID, and Subject form the primary key, which means the Subject column is a prime attribute. But, there is one more dependency, Professor → Subject. And while Subject is a prime attribute, Professor is a non-prime attribute, which is not allowed by BCNF.