[DAO] database three paradigm description, dao Database paradigm
**************************************** ********************************* *** Original article: blog.csdn.net/clark_xu Xu changliang's column**************************************** ********************************
First paradigm: the general situation is that the column value is unique and there cannot be repeated column values (must comply );
Negative example:
Name contact information (string type)
Xxx 12345; abc@163.com
Xxx bcd@163.com
Xxx 12345; 67890; def@163.com
Hazard: junk data cannot be deleted or modified;
Correct design method:
Name phone number 1 phone number 2 phone number 3 phone number 4 mailbox
In the second paradigm, attributes fully depend on primary keys (must comply)
N must satisfy the first paradigm
N must have a primary key
N other columns must depend entirely on the primary key.
Incorrect table creation method:
No. Name: Gender major lesson
100 xxx m java 600
200 xxx f java 700
What violates paradigm 2 is another meaning. Placing two entities in the same table is not convenient for individual Maintenance of one entity data.
No. Name: Gender major lesson
100 xxx m java 600
200 xxx f java 700
Table 2
Number of professional courses
00001 java 600
002, java 700
3) third paradigm: attributes do not depend on other non-primary attributes
N must follow the second paradigm
N remove transfer Dependencies
The correct design method is:
No. Name gender major no.
100 xxx m 001
200 xxx f 002
Table 2
Number of professional courses
00001 java 600
002, java 700
Overview:
Paradigm 2: A table cannot contain information of two entities. It must contain one entity.
Paradigm 3: one entity cannot reference attributes of other entities. It can only reference primary keys of other entities.
Note:
In some cases, due to query efficiency considerations, it may violate paradigm 3. Redundancy is added. Table join is not required during query, which increases the execution efficiency of tables, however, the maintainability is reduced. It is generally not recommended that tables that are frequently maintained violate the third paradigm.