In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the database three paradigms and anti-paradigm is, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
In the daily development process, we need to operate the Mysql database, which involves the construction of tables. How to create a well-structured database table, we need to follow the following three database paradigms.
1. The first paradigm
Ensure the atomicity of each column (field) in the data table.
If each field in the data table is the smallest data unit that can no longer be separated, the first normal form is satisfied.
For example: user user table, containing the field id,username,password
two。 The second paradigm
Building on the first paradigm, the goal is to ensure that each column in the table is related to the primary key.
If a relationship satisfies the first normal form and all columns except the primary key depend on the primary key, the second normal form is satisfied.
For example, a user has only one role, while one role corresponds to multiple users. The data table relationship can be established as follows to satisfy the second normal form.
User user table, field id,username,password,role_id
Role role table, field id,name
The user table associates the role table through role id (role_id)
3. The third paradigm
Building on the second paradigm, the goal is to ensure that the columns in the table are directly related to the primary key, not indirectly.
For example, a user can correspond to multiple roles, and a role can correspond to multiple users. The data table relationship can be established as follows to meet the third normal form.
User user table, field id,username,password
Role role table, field id,name
User_role user-role middle table, id,user_id,role_id
Like this, through the third table (intermediate table) to establish the relationship between the user table and the role table, while in line with the principle of paradigm, it can be called the third paradigm.
4. Anti-normalization
Anti-normalization refers to improving the read performance of the database by adding redundant or duplicated data.
For example, the user_role user-role middle table in the above example adds the field role_name.
De-normalization can reduce the number of join tables when associating queries.
Thank you for reading this article carefully. I hope the article "what are the three paradigms and anti-paradigms of database" shared by the editor will be helpful to everyone? at the same time, I also hope that you will support and pay attention to the industry information channel. more related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.