In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In database design, I often analyze how to design tables in business logic. It is necessary to understand the characteristics of relational database before designing the relationship of tables.
1 Relational database refers to the database that uses the relational model to organize the data.
2. The most important feature of relational database is the consistency of transactions.
3. To put it simply, the relational model refers to the two-dimensional table model, and a relational database is a data organization composed of two-dimensional tables and their relationships.
So in the real business analysis, we can understand that there is a relationship between each table and the table, which includes
1. One-to-one relationship
two。 One-to-many relationship
3. Many-to-many relationship
Association mapping: one-to-one
An one-to-one relationship is like the relationship between a team and its address. A team has only one address and an address area has only one team.
Theoretically, there are two kinds of performance of one-to-one relationship between data tables, one is foreign key association, the other is primary key association.
But in practical application, what I generally use is that the primary key associates two tables with the same fields, the same primary key, and of course, if there are not many fields, it can be designed as a table.
Association mapping: one-to-many
The actual list, such as the receipt, has the most common mapping relationship, which is simply like the relationship between the player and the team.
One-to-many: from a team's point of view, a team with multiple players is one-to-many.
Many to one: from a player's point of view, multiple players belong to a team.
The relationship of a pair is reflected in the master-slave table in the database with one piece of data in the master table and multiple pieces of data in the slave table.
Many to many
Multiple relationships are also common, such as the relationship between students and elective courses, in which a student can choose multiple elective courses, and each elective course can be selected by multiple students.
The many-to-many association relationship in the database generally needs to be processed by the way of intermediate table, which converts many-to-many into two one-to-many.
Many-to-many situations don't use much.
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.