Database ER diagram converted to relational schema
The E-R diagram is composed of three elements: entities, attributes of entities, and connections between entities. Converting an E-R diagram into a relational model actually means converting entities, their attributes, and the connections between entities into a relational model.
The E-R diagram is composed of three elements: entities, attributes of entities, and connections between entities. Converting an E-R diagram into a relational model actually means converting entities, their attributes, and the connections between entities into a relational model. .
2. E-R diagram conversion relationship model
1. Conversion of entity set to relational model
Principles followed by general conversion
Conversion rules of entity set : Convert an entity type to a relational schema. The attributes of the entity are the attributes of the relationship, and the code of the entity is the code.
Example: The student entity can be converted into the following relationship model:
Student (student number, name, gender, date of birth, department, grade)
2. Two Conversion of the relationship set between entity types to relationship schema
1:1 contact conversion method: 1:1 contact can be converted into an independent relationship schema, or it can be merged with the corresponding relationship schema at either end.
If converted to an independent relationship schema, the primary key of each entity connected to the relationship and the properties of the relationship itself are converted to the properties of the relationship, and the primary key of each entity is a candidate for the relationship. code.
If you merge with the relationship schema corresponding to one end, you need to add the main code of the other relationship schema and the attributes of the contact itself to the attributes of the relationship schema.
Example
1:n contact conversion method: 1:n contact can be converted into an independent relationship schema, or it can be merged with the corresponding relationship schema at the n end.
If converted to an independent relationship model, the primary code of each entity connected to the relationship and the properties of the relationship itself are converted into the properties of the relationship, and the primary code of the relationship is the primary code of the n-terminal entity. .
If merged with the n-terminal relationship model, a new attribute will be added to the n-terminal entity set. The new attribute consists of the primary code that contacts the corresponding 1-terminal entity set and the attributes that relate to itself. The primary code of the relationship model constant.
Example
Option 1: 1: The relationship formed by n contact exists independently
Warehouse (warehouse number, location, area)
Product (product number , product name, price)
Warehouse(product number, warehouse number, quantity)
Option 2: Merge the relationship formed by the contact with the n-end object
Warehouse(warehouse number) , location, area)
product (product number, product name, price,
warehouse number, quantity)
m:n contact conversion method: connected to the contact The codes of each entity and the attributes of the relationship itself are converted into attributes of the relationship. The code of the relationship is a combination of the codes of each entity.
Example
3. Conversion of the relationship set between the same entity type to the relationship model
vThe relationship between entities of the same entity type is a self-relationship, and can also be pressed The above three situations of 1:1, 1:n and m:n are handled separately.
1:n
m:n
4. Conversion of the relationship between multi-entity types to relational patterns
Generally, more than two There are also three situations: 1:1, 1:n and m:n between entity types. The conversion method generally follows the following principles:
1: Multiple connections of n: modify the relationship corresponding to the 1-end entity set , that is, adding the codes of other entity sets related to the contact and the attributes of the contact itself as new attributes to the 1-end entity set.
M:n Multiple relationship: Create a new independent relationship. The codes of each entity connected by the multiple relationship and the attributes of the relationship itself are converted into the attributes of the relationship. The code of the relationship is a combination of the codes of each entity.
5. Conversion of weak entity set to relational model
The concepts of strong entity set and weak entity set are closely related to existential dependence. The members of strong entity set must be dominant entities, while weak entities must be dominant entities. The members of a set are subordinate entities.
Since a weak entity cannot exist independently, it must be attached to an owner entity. Therefore, when converting the weak entity set into a relationship mode, the relationship corresponding to the weak entity must contain the master key of the owner entity.
6. Application Example
**After converting the ****E-R diagram to the relational model according to the above rules, the relational models with the same primary code can be merged. The main purpose is to reduce the system The number of relationships in it facilitates maintenance and data consistency.
The merging method is to add all the attributes of a relationship model in the relationship model with the same primary key to another relationship model, and then remove the synonymous attributes (which may have the same name or different names), And adjust the order of attributes appropriately.
Example 3-12 The E-R diagram of a certain project is shown in Figure 3-19. The attributes of each entity are as follows:
The above is the detailed content of Database ER diagram converted to relational schema. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The domestic AI dark horse DeepSeek has risen strongly, shocking the global AI industry! This Chinese artificial intelligence company, which has only been established for a year and a half, has won wide praise from global users for its free and open source mockups, DeepSeek-V3 and DeepSeek-R1. DeepSeek-R1 is now fully launched, with performance comparable to the official version of OpenAIo1! You can experience its powerful functions on the web page, APP and API interface. Download method: Supports iOS and Android systems, users can download it through the app store; the web version has also been officially opened! DeepSeek web version official entrance: ht

At the beginning of 2025, domestic AI "deepseek" made a stunning debut! This free and open source AI model has a performance comparable to the official version of OpenAI's o1, and has been fully launched on the web side, APP and API, supporting multi-terminal use of iOS, Android and web versions. In-depth search of deepseek official website and usage guide: official website address: https://www.deepseek.com/Using steps for web version: Click the link above to enter deepseek official website. Click the "Start Conversation" button on the homepage. For the first use, you need to log in with your mobile phone verification code. After logging in, you can enter the dialogue interface. deepseek is powerful, can write code, read file, and create code

DeepSeek: How to deal with the popular AI that is congested with servers? As a hot AI in 2025, DeepSeek is free and open source and has a performance comparable to the official version of OpenAIo1, which shows its popularity. However, high concurrency also brings the problem of server busyness. This article will analyze the reasons and provide coping strategies. DeepSeek web version entrance: https://www.deepseek.com/DeepSeek server busy reason: High concurrent access: DeepSeek's free and powerful features attract a large number of users to use at the same time, resulting in excessive server load. Cyber Attack: It is reported that DeepSeek has an impact on the US financial industry.