In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Normalization is a data design process whose high-level goal is to keep each fact in one place to avoid data redundancy and to insert, update, and delete exceptions. There are multiple levels of normalization, the first three of which are described in this section. Considering how basic the third normal form (3NF) item is, it only makes sense to see how to achieve 3NF.
Consider a situation that tracks sales. The core entity you track is the sales order, where each sales order contains detailed information about each item purchased (called line items): its name, price, quantity, and so on. The order also contains the name and address of the customer. Some orders have many different order items, and some orders have only one.
In the first normal form (1NF), there are no duplicate data sets and no duplicate rows. Each intersection of rows and columns (fields) contains only one value, and there are no column groups that contain the same facts. To avoid duplicating rows, there is a primary key. For sales orders, multiple line items for each sales order in a single field of the table are not displayed in the first paradigm. In addition, there are no more than one column to display order items.
Then there is the second normal form (2NF), where the design is the first normal form, and each non-key column depends on the complete primary key. Therefore, order items are divided into sales order line item tables, where each line represents an order item for an order. You can view the order item table and see that the name of the item sold does not depend on the primary key of the order item table: the item sold is its own entity. Therefore, you move the sales item to its own table to display the project name. The price of each item may vary from order to order (for example, due to discounts), so these prices remain in the order list. For sales orders, the name and address of the customer do not depend on the primary key of the sales order: the customer is its own entity. Thus
Next comes the third paradigm, whose goal is to ensure that it does not rely on non-critical attributes. Therefore, the goal is to get columns that are not directly related to the subject of the row (primary key) and place them in your own table. Therefore, details about the customer, such as customer name or customer city, should be placed in a separate table, and then the customer foreign key should be added to the order table.
Another example of the difference between the 2NF table and the 3NF table is the table of winners of tennis tournaments, which contains columns of the tournament, year, winner and winner's date of birth. In this case, the winner's date of birth can easily be inconsistent, because the same person may show the date of birth in different records. The way to avoid this potential problem is to divide the table into one for the winner and another for the date of birth of the player.
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.