Documente Academic
Documente Profesional
Documente Cultură
Database normalization is the process of making the data in a database available in the most
organized way possible.
When youre normalizing a database, there are two things you need to consider: whether the
information in the database has internal redundancies, and whether the dependencies across
the different tables in the database are logically organized.
The term normalization comes from the concept of normal forms, which describe just how
organized the information is in the database.
As an example, lets imagine were creating a database of the children in a class, and the pets
they have. When starting to build this database, the first approach might be to create a simple
table with all of the information in one place, and one row for each student.
TABLE: STUDENTS
| Name
| Age | Pet | Pet Name |
---------------------------------------------| Heather
| 10 | Dog | Rex
|
---------------------------------------------| Rachel
| 10 | Cat | Fluff
|
---------------------------------------------| Jimmy
| 11 | Dog | Kimba
|
---------------------------------------------| Lola
| 1o | Cat | Thomas
|
----------------------------------------------
This works until you realize that Heather might have two pets, a dog and a cat. How would
you represent that in this table? In order to do that, we need to introduce first normal form.
| Rachel
| 10 | Cat | Fluff
|
---------------------------------------------| Jimmy
| 11 | Dog | Kimba
|
---------------------------------------------| Lola
| 10 | Cat | Thomas
|
----------------------------------------------
student table is also a good idea. Often these will be added automatically when database rows
are set to autoincrement.
TABLE: STUDENTS
| ID | Name
| Age |
---------------------------------| 00 | Heather
| 10 |
---------------------------------| 01 | Rachel
| 10 |
---------------------------------| 02 | Jimmy
| 11 |
---------------------------------| 03 | Lola
| 10 |
---------------------------------TABLE: PETS
| ID | Type
| Pet Name | Owner ID |
-------------------------------------------| 00 | Dog
| Rex
| 00
|
-------------------------------------------| 01 | Cat
| Thomas
| 00
|
-------------------------------------------| 02 | Cat
| Fluff
| 01
|
-------------------------------------------| 03 | Dog
| Kimba
| 02
|
-------------------------------------------| 04 | Cat
| Thomas
| 03
|
--------------------------------------------
| 01 | Cat
| Thomas
|
--------------------------------| 02 | Cat
| Fluff
|
--------------------------------| 03 | Dog
| Kimba
|
--------------------------------Table: PETS-STUDENTS
| Pet ID | Owner ID |
--------------------| 00
| 00
|
--------------------| 01
| 00
|
--------------------| 02
| 01
|
--------------------| 03
| 02
|
--------------------| 01
| 03
|
---------------------
Now we have a flexible and searchable structure in fourth normal form that can represent all
the available information about each of the students, each of the pets, and the relationships
among them.