Get the App
SLTechnology News&Howtos  ›  Database  › 

Oracle database design-database table design

Shulou Source: shulou.com Published: 2022-06-01 09:33:21 09月24日 Update

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.

Tags: Data database team association inter design player one-on-one address student model elective contact same two multiple fields actually that is the situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Shulou Technology NVidia MySQL