|
| 1 | +--- |
| 2 | +title: "Make DB tables great by normalization" |
| 3 | +tags: [development, database] |
| 4 | +category: "database" |
| 5 | +comment: true |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Introduction |
| 10 | + |
| 11 | +Nowadays, almost all scalable softwares are connected to database for data persistence need. |
| 12 | + |
| 13 | +Relational database is the most common and widely-used one, without that no any data can be stored and reused. |
| 14 | + |
| 15 | +The relationship and organization inside the database are always an important section to make data collected well. |
| 16 | + |
| 17 | +Thus, DB normalization was then proposed and become the guildline of making relational DB tables. |
| 18 | + |
| 19 | +It mainly eliminates irrelevant fields and duplication of data, to give normal data manipulation and data integrity. |
| 20 | + |
| 21 | + |
| 22 | +## Rules |
| 23 | + |
| 24 | +There are the progressive rules for database normalization, if obey then they call "1st/2nd/3rd normal form". |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +### Level 1: 1st normal form |
| 29 | +- Eliminate repeating groups in individual tables |
| 30 | +- Create a separate table for each set of related data |
| 31 | +- Identify each set of related data with a primary key |
| 32 | + |
| 33 | +### Level 2: 2nd normal form |
| 34 | +- Create separate tables for sets of values that apply to multiple records |
| 35 | +- Relate these tables with a foreign key |
| 36 | + |
| 37 | +### Level 3: 3rd normal form |
| 38 | +- Eliminate fields that do not relate to the key item to become atomic |
| 39 | + |
| 40 | +*For more detailed instruction, this [poster][db-normalization-poster] provides the full solution.* |
| 41 | + |
| 42 | +[db-normalization-poster]: http://marcrettig.me/wp-content/uploads/2017/04/rettigNormalizationPoster.pdf |
0 commit comments