MySQL database normalization (paradigm)

The original data table

title publisher year author1 author2 author3
"Elaborate PHP" Electronic Industry Press 2009 Galla peak    
"Elaborate JavaScript" Tsinghua University Press 2013 Galla peak Ying Xin  
"Highly concurrent web site" Electronic Industry Press 2014 Li Wenkai Zhang Tao Li strong
"LAMP" Band of Brothers Beijing Normal University Press 2015 Li Chao Li Ming  

The first paradigm:

(1) similar content data must be eliminated ( "elimination" approach is to create a data table to store them)

Create a data table (2) must be for each group of related data

(3) each data table a record must be progressively identified

Book Database: First Normal Form

id title publisher year author
1 "Elaborate PHP" Electronic Industry Press 2009 Galla peak
2 "Elaborate JavaScript" Tsinghua University Press 2013 Galla peak
3 "Elaborate JavaScript" Tsinghua University Press 2013 Ying Xin
4 "Highly concurrent web site" Electronic Industry Press 2014 Li Wenkai
5 "Highly concurrent web site" Electronic Industry Press 2014 Zhang Tao
6 "Highly concurrent web site" Electronic Industry Press 2014 Li strong
7 "LAMP" Band of Brothers Beijing Normal University Press 2015 Li Chao
8 "LAMP" Band of Brothers Beijing Normal University Press 2015 Li Ming

 

Second Normal Form:

(1) As long as the contents of the column data duplication, it means that the data should be split into multiple sub-table table

(2) must be resolved in the form of a data table associated with the foreign key

titles data sheets: a second Paradigm

titleid title publisher year
1 "Elaborate PHP" Electronic Industry Press 2009
2 "Elaborate JavaScript" Tsinghua University Press 2013
3 "Highly concurrent web site" Electronic Industry Press 2014
4 "LAMP" Band of Brothers Beijing Normal University Press 2015

Data Sheet authors: second Paradigm

authorid author
1 Galla peak
2 Ying Xin
3 Li Wenkai
4 Zhang Tao
5 Li strong
6 Li Chao
7 Li Ming

rel_title_author Table: second Paradigm

titleid authorid
1 1
2 1
2 2
3 3
3 4
3 5
4 6
4 7

Third Normal Form:

(1) data column not directly related to the primary key must be eliminated ( "elimination" approach is to re-create a table to store them)

titles Datasheet: third paradigm

titleid title publisherid year
1 "Elaborate PHP" 1 2009
2 "Elaborate JavaScript" 2 2013
3 "High concurrency Web site." 1 2014
4 "LAMP Band of Brothers" 3 2015

publishers Datasheet: third paradigm

publisherid publisher
1 Electronic Industry Press
2 Tsinghua University Press
3 Beijing Normal University Press

Guess you like

Origin www.cnblogs.com/niemx1030/p/11969391.html