Sobes.tech
Senior

Normalization and denormalization of tables — tell about normal forms.

sobes.tech AI

Answer from AI

Normalization of tables is the process of organizing data in a database to reduce redundancy and ensure integrity. Denormalization is the reverse process, where data is intentionally duplicated to improve query performance.

Normal Forms (NF) are a set of rules for normalization:

  • 1NF (First Normal Form): All fields are atomic, meaning they do not contain repeating groups or multiple values.

  • 2NF (Second Normal Form): 1NF is satisfied, and all non-key attributes depend fully on the entire composite key (if the key is composite).

  • 3NF (Third Normal Form): 2NF is satisfied, and there are no transitive dependencies between non-key attributes (non-key fields do not depend on each other).

  • Boyce-Codd Normal Form (BCNF): A stricter version of 3NF, where for every functional dependency, the determinant is a key.

  • 4NF and higher: Deal with multi-valued dependencies and other complex cases.

Example: If we have a table with information about students, courses, and instructors, and the instructor depends on the course, not on the student, then for 3NF, the table should be split into two: one with information about students and courses, and another about courses and instructors.

Denormalization is used when normalized tables lead to complex and slow JOIN operations. In this case, data is duplicated to speed up reading, but updating and maintaining integrity becomes more complicated.

Normalization and denormalization of tables — tell… - sobes.tech