search
HomeCommon ProblemDatabase ER diagram converted to relational schema

Database ER diagram converted to relational schema

Jun 16, 2023 pm 03:30 PM
Database er diagram

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.

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. .

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
ao3 quark entrance official website ao3 official website quark entranceao3 quark entrance official website ao3 official website quark entranceMay 15, 2025 pm 06:45 PM

1. Ao3 official website quark entrance☜☜☜☜☜☜Click to save. 2. Ao3 Quark entrance official website☜☜☜☜☜☜☜Click to save. 【ao3】1. AO3 (Archive of Our Own) is a huge online archive website created by fans. 2. It mainly contains fan works, covering a wide variety of media, from books and movies to TV series and games, almost everything is included. 3. AO3 has rich content and diverse types, which can meet the needs of different readers.

ao3 mirror URL quark ao3 mirror address quark entranceao3 mirror URL quark ao3 mirror address quark entranceMay 15, 2025 pm 06:42 PM

1. Ao3 mirror URL Quark☜☜☜☜☜☜☜☜ Click to enter. 2. Ao3 mirror address quark entrance ☜☜☜☜☜☜☜ Click to enter. 3. AO3 (Archives Our Own) is a non-profit fan and fan-fiction archive website launched on October 29, 2008. 4. AO3 is a website founded by fans and run by fans, dedicated to protecting the works created by fans and providing a censorship-free environment for fan novel writers.

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software