Database--The method of transforming from ER diagram to relational mapping

Source: Internet
Author: User
database--the method of transforming from ER diagram to relational mapping

Specific steps:

1.For each strong entity type E. Create a new table. Include as its columns, all the simple attributes and easy components of the composite attributes of E. Identify the PRI Mary Key and the alternate keys. Do not include any multi-valued attribute as a key. If The unique field of an entity is a multi-valued attribute, introduce an artificial primary key field.

Mapping of strong entity types: Entity E is converted into a relational r,r that contains all of the simple attributes in. For composite properties, it is composited into simple properties.

2.For each weak entity W, associated with only one 1:1 identifying owner relationship. Identify the table T of the owner entity type. Include as columns of T, all the simple attributes and simple components of the composite attributes of W.

3.For each weak the entity W that's associated with a 1:n or m:n identifying relationship, or participates in + than on E relationship. Create a new table T. Include as its columns, all the simple attributes and the composite attributes of W. Form the primary key of T as follow:in the case of a 1:n owner relationship, by including as a foreign key in T, th E primary key of the owner entity. The primary key of T is the combination of W ' s partial key and the foreign key. In the case of a m:n owner relationship, by creating a new column that'll hold unique values. The association between the weak entity and its owner entity would be specified in Step 6.)

4.For each binary 1:1 relationship type R Identify the tables S and T of the participating entity types. Choose S (preferably the one with total participation). Include as foreign key in S, the primary key of T. Include as Columns of S, all the simple attributes and simple component s of the composite attributes of R.

Mapping of binary relations 1:1: Entities A and B are 1:1, two entities correspond to R and S, the primary key of S is used in the relationship R as foreign key, and the primary key of R in S is the foreign key.

5.For each binary 1:n relationship type R. Identify the table S (at the n-side) and T of the participating entities. Include as a foreign key in S, the primary key of T. Include as columns of S, all the simple attributes and simple Compone NTS of composite attributes of R.

The mapping of binary relationship 1:n. The entities A and B are 1:n, the two entities correspond to R and S, the one end of N is marked S, the R in S is the foreign key, and the primary key is the primary key of S.

6.For each n-ary relationship (including binary n:m relationship) type R. Create a new table T. Include as columns of T, a ll the attributes and simple components of composite attributes of R. Include as foreign keys, the primary keys of The participating (strong or weak) entity types. Specify as the primary key of T, the list of foreign keys.

The mapping of binary relationship m:n. Entities A and B are m:n, and two entities correspond to R and S respectively, then a new relationship T is created for M:N, and the combination of the primary key of R and S in T is the primary key of T

7.For each multi-valued attribute A. Create a new table T. Include as columns of T, the simple attribute or simple Compone NTS of the attribute A. In table T, include as foreign key, the primary key of the entity or relationship type that have A. Specify as the primary Key of T, the foreign key and the columns corresponding to A.

The mapping of multi-valued attribute a. Create a new relationship R for each multi-valued property. R contains an attribute corresponding to a, plus the primary key K for the entity where the A is located. A combination of R's primary key by A,k

8.For each specialization with disjoint subclasses. Create A new table Ti for each subclass Si. Include as columns of Ti, the simple attributes and simple component attributes of the superclass. Include as columns of Ti, the simple attributes and simple component attributes specific to Si. Identify the primary key.

9.For each specialization with overlapping subclasses. Create A new table O for the superclass. Include as columns of O, the simple attributes and the simple component attributes of the superclass. Identify its primary key and alternate keys. Create A new table Ti for each subclass Si. Include as columns of Ti, the simple attributes and simple component attributes specific to Si. Include as a foreign key in Ti (to is part of the primary key of TI), the primary key of O.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.