当前位置:网站首页>Database design: paradigms and anti paradigms

Database design: paradigms and anti paradigms

2020-11-08 21:14:00 Let me love you

  1. Three paradigms

First normal form (1NF): Every column in the data table ( Each field ) Must be the smallest unit that cannot be split , That is to ensure the atomicity of each column ; 

Second normal form (2NF): Satisfy 1NF after , Require all columns in the table , All must depend on the primary key , You can't have any columns that have nothing to do with the primary key , That is to say, a table only describes one thing ; 

Third normal form (3NF): The second paradigm must be satisfied first (2NF), requirement : Each column in the table is directly related to the primary key, not indirectly ,( Each column in the table can only depend on the primary key );

The first The first and second paradigms lie in Do you have two tables ,
The second paradigm is that a table contains many different entity attributes , Then it must be divided into several tables ,
The third paradigm is to require It's divided into multiple tables , Then one table can only have... In another table id( Primary key ), There can be no other information ( All other information is queried in another table with the primary key ).

summary :
     The first 1 normal form : In each table 1 Column , And this column is the smallest unit that cannot be split   No duplicate Columns
     The first 2 normal form :1 A watch only describes one thing   Properties are completely dependent on the primary key
     The first 3 normal form : Use foreign keys for table Association
  Direct dependence, not indirect ( Pass on ) rely on
It is required that a database table does not contain non primary key information that has been included in other tables .
In short , The third paradigm is that attributes do not depend on other non primary attributes . in other words , If there is a transfer function dependence of non primary attributes on the code , It doesn't conform to 3NF The requirements of

  1. Anti paradigm

The anti normal form allows the table to have There are transfer function dependencies

The comparison between paradigms and anti paradigms :

When querying records , The normal pattern often requires multiple table joins , The anti normal form only needs to query in the same table , When there's a lot of data , Obviously, the efficiency of the anti paradigm is better .
There's a lot of duplicate data in the anti paradigm , It takes up more memory , You may use more DROUP BY or DISTINCT Time consuming and performance consuming keywords .
When you want When modifying update data ( For example, modify Accounting The head of the Department is Russell), The paradigm is more flexible , And the anti paradigm is Modify all the data , And it's easy to make mistakes .

summary : There's a lot of comparison between paradigms and anti paradigms , Each has its own advantages , In the actual development, different patterns should be reasonably mixed according to the needs , To maximize the combination of their respective advantages .

版权声明
本文为[Let me love you]所创,转载请带上原文链接,感谢