er模型转关系模式_ER模型到关系模型
er模型轉(zhuǎn)關(guān)系模式
As we all know that ER Model can be represented using ER Diagrams which is a great way of designing and representing the database design in more of a flow chart form.
眾所周知,ER模型可以使用ER Diagrams表示,這是一種設(shè)計和表示數(shù)據(jù)庫設(shè)計的好方法,更多地采用流程圖形式。
It is very convenient to design the database using the ER Model by creating an ER diagram and later on converting it into relational model to design your tables.
使用ER模型設(shè)計數(shù)據(jù)庫非常方便,方法是創(chuàng)建一個ER圖,然后將其轉(zhuǎn)換為關(guān)系模型以設(shè)計表。
Not all the ER Model constraints and components can be directly transformed into relational model, but an approximate schema can be derived.
并非所有的ER模型約束和組件都可以直接轉(zhuǎn)換為關(guān)系模型,但是可以導(dǎo)出近似模式。
So let's take a few examples of ER diagrams and convert it into relational model schema, hence creating tables in RDBMS.
因此,讓我們以ER圖的一些示例為例,并將其轉(zhuǎn)換為關(guān)系模型架構(gòu),從而在RDBMS中創(chuàng)建表。
實體成為表格 (Entity becomes Table)
Entity in ER Model is changed into tables, or we can say for every Entity in ER model, a table is created in Relational Model.
ER模型中的實體已更改為表,或者可以說,對于ER模型中的每個實體,都會在關(guān)系模型中創(chuàng)建一個表。
And the attributes of the Entity gets converted to columns of the table.
實體的屬性將轉(zhuǎn)換為表的列。
And the primary key specified for the entity in the ER model, will become the primary key for the table in relational model.
并且在ER模型中為實體指定的主鍵將成為關(guān)系模型中表的主鍵。
For example, for the below ER Diagram in ER Model,
例如,對于下面的ER模型中的ER圖,
A table with name Student will be created in relational model, which will have 4 columns, id, name, age, address and id will be the primary key for this table.
將在關(guān)系模型中創(chuàng)建一個名稱為Student的表,該表將有4列, id , name , age , address和id將是該表的主鍵。
關(guān)系成為關(guān)系表 (Relationship becomes a Relationship Table)
In ER diagram, we use diamond/rhombus to reprsent a relationship between two entities. In Relational model we create a relationship table for ER Model relationships too.
在ER圖中,我們使用菱形/菱形表示兩個實體之間的關(guān)系。 在關(guān)系模型中,我們也為ER模型關(guān)系創(chuàng)建關(guān)系表。
In the ER diagram below, we have two entities Teacher and Student with a relationship between them.
在下面的ER圖中,我們有兩個實體Teacher和Student ,它們之間具有關(guān)系。
As discussd above, entity gets mapped to table, hence we will create table for Teacher and a table for Student with all the attributes converted into columns.
如上所述,實體被映射到表,因此我們將為教師創(chuàng)建表,為學(xué)生創(chuàng)建表,并將所有屬性轉(zhuǎn)換為列。
Now, an additional table will be created for the relationship, for example StudentTeacher or give it any name you like. This table will hold the primary key for both Student and Teacher, in a tuple to describe the relationship, which teacher teaches which student.
現(xiàn)在,將為該關(guān)系創(chuàng)建一個附加表,例如StudentTeacher或為其指定任何您喜歡的名稱。 該表將在一個元組中包含“學(xué)生”和“老師”的主鍵,以描述這種關(guān)系,由哪個老師教給哪個學(xué)生。
If there are additional attributes related to this relationship, then they become the columns for this table, like subject name.
如果還有與此關(guān)系相關(guān)的其他屬性,則它們將成為此表的列,例如主題名稱。
Also proper foriegn key constraints must be set for all the tables.
還必須為所有表設(shè)置適當(dāng)?shù)那版I約束。
要記住的要點 (Points to Remember)
Similarly we can generate relational database schema using the ER diagram. Following are some key points to keep in mind while doing so:
同樣,我們可以使用ER圖生成關(guān)系數(shù)據(jù)庫架構(gòu)。 以下是在執(zhí)行此操作時要記住的一些關(guān)鍵點:
Entity gets converted into Table, with all the attributes becoming fields(columns) in the table.
實體被轉(zhuǎn)換成表格,所有屬性變成表格中的字段(列)。
Relationship between entities is also converted into table with primary keys of the related entities also stored in it as foreign keys.
實體之間的關(guān)系也轉(zhuǎn)換為表,同時相關(guān)實體的主鍵也作為外鍵存儲在表中。
Primary Keys should be properly set.
應(yīng)該正確設(shè)置主鍵。
For any relationship of Weak Entity, if primary key of any other entity is included in a table, foriegn key constraint must be defined.
對于弱實體的任何關(guān)系,如果表中包含任何其他實體的主鍵,則必須定義前鍵約束。
翻譯自: https://www.studytonight.com/dbms/er-to-relational-model.php
er模型轉(zhuǎn)關(guān)系模式
總結(jié)
以上是生活随笔為你收集整理的er模型转关系模式_ER模型到关系模型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手机的android版本怎么升级,华为H
- 下一篇: WordPress主题分享:Avada主