E-R diagram to database table

Source: Internet
Author: User
Database E-R diagram correlation June 15, 2014: 39E-R data model adopted three main concepts: entity set, link set and attribute entity set: with the same type and the same nature (or attribute) object set attributes: simple attributes and compliant attributes; single-value Attributes and multi-value attributes; null attributes; derived attribute contact set: links are the associations between multiple entities.

Database E-R diagram correlation June 15, 2014 E-R data model adopted three main concepts: entity set, contact set and attribute entity set: with the same type and the same nature (or attribute) object set attributes: simple attributes and compliant attributes; single-value Attributes and multi-value attributes; null attributes; derived attribute contact set: links are the associations between multiple entities.

Database E-R graph correlation

June 15, 2014

17: 39

Three main concepts used in E-R data model are: entity set, link set and attribute.

Entity set: entity set with the same type and the same nature (or attribute)

Attributes: simple attributes and compliant attributes; single-value and multi-value attributes; null attributes; derived attributes

Contact set: A contact is an association between multiple entities. A contact set is a set of similar contacts.

Eg: If E1, E2 ,..., If En is n entity sets, then the contact set R is {(e1, e2 ,..., En) | e1 belongs to E1, e2 belongs to E2 ,... En belongs to a subset of En}, while (e1, e2 ,..., Is a contact.

Capture Time of on-screen editing:

Code: How do entities in a given object set or links in a given contact set differ from each other?

Entity set:

Supercode: a set of one or more attributes. The combination of these attributes allows us to uniquely identify an object in an object set. (There may be redundant attributes)

Candidate code: the minimum supercode (any real subset of the supercode cannot be a supercode) is the candidate code. There can be multiple candidate codes.

Master code: the candidate code selected by the Data designer to distinguish different entities in the same entity set.

Any two entities in the entity set cannot have the same value on the Code attribute at the same time.

Contact set: (supercode, the master code has nothing to do with the attributes of the contact set)

Supercode: the Union of the master codes of each object is the supercode of the contact set.

Master code: the base code that depends on the ing of the contact set (one-to-many ). For many-to-many cases, the primary code of the two tables is the same; for one-to-many cases, the primary code of the multiple tables is the same; for one-to-one cases, the master code of any table can be used as the master code of the contact set.

Ing base: one-to-one, one-to-multiple, multiple-to-one, and multiple-to-many

A and B are entity sets.

One-to-one: one entity in A is at most associated with one entity in B, and one entity in B is at most the same entity in.

One-to-multiple: one entity in A can be associated with any number of entities in B, and one entity in B can be associated with at most one entity in.

Many-to-many: An entity in A can be associated with any number of entities in B, and an entity in B can also be associated with any number of entities in.

The contact may also have descriptive attributes, which are different from the attributes of the object contained in the contact.

Use entity set or use attribute: mainly distinguishes between the structure of the constructed real-world facts and the semantics of the discussed attributes.

Object set or contact set: Use the contact set to describe actions between objects. This method is also useful when determining whether certain attributes are more precise when expressed as links.

The base ratio of a contact may affect the location of the contact attribute. Attributes of one-to-one or one-to-many contact sets can be placed in the involved entity set, rather than in the contact set. The attributes of one-to-multiple connections can be placed in the entity set of the "multiple" party in the contact. For the one-to-one contact set, the attributes of the contact can be placed in any entity set of the involved contact.

The decision of using descriptive attributes as the link property or object property during the design should reflect the characteristics of the simulated facts. The designer can choose to retain access-date as the attribute of depositor to indicate that access occurs on the interaction point of the object set customer and account.

In the case of many-to-many relationship, when an attribute is determined by the joint operation of the involved entity set rather than by a single entity set, the attribute must be placed in the many-to-many relationship set.

Dependency, full participation, partial participation

There is dependency: Loan and repayment. A loan data may correspond to multiple repayment data items, and the repayment depends on the loan.

All participants: All entities participate in a contact set. All repayment data entities are involved in the "loan repayment" relationship, and all repayment data is related to a loan.

Partial participation: the entity part participates in a contact set. The customer data entity is involved in the "customer loan" relationship, and not all customers have loans.

E-R diagram: can represent the global logical structure of the database, simple, clear

Rectangle: entity set.

Elliptic: attribute.

Diamond: Contact set.

Line Segment: connects an attribute to an object set or connects an object to a contact set.

Double oval: multi-value attribute.

Virtual elliptic: represents a derived property.

Double Line: indicates that all objects are involved in the contact set.

Straight lines without arrows: many to many

Straight line with arrows: the arrow points to one side.

Derived attributes: in a database, an object contains multiple attributes. The attributes that can be obtained from other attributes are called derived attributes. For example, the "student" entity has attributes such as "Birthday" and "Age". The value of the "Age" attribute can be calculated from "Birthday". The "Age" attribute is a derived attribute.

Multi-value attributes: for example, there can be multiple relatives of employees. When designing a database table, you must create a separate table.

Capture Time of on-screen editing:

The main Code contains the following attributes.

Weak entity set: the attributes of an entity set are insufficient to form the primary Code. Such an entity set is called a weak entity set.

The weak entity set is represented by a rectangle with a double border, and the corresponding symbolic link is represented by a diamond of the double border.

Weak entities do not have a primary code, but have delimiters. mark them with virtual underscores (_).

Master code of the weak entity set: the master code of the strong entity set on which the weak entity set depends and the identifier of the weak entity set.

If the weak entity set only participates in the symbolic link, but does not have many attributes, it is more appropriate to express it as an attribute During modeling. On the contrary, if a weak entity set is involved in a link that identifies a link, or has many attributes, it is more appropriate to express it as a weak entity set during modeling.

We can use the triangle above to represent the specificity and generalization. property inheritance is also specific to the specificity and generalization.

Aggregation: contacts are treated as entities.

Capture Time of on-screen editing:

Design the E-R mode of the database

Capture Time of on-screen editing:

Convert E-R mode to table

Use tables to represent strong entity sets:

Use tables to represent weak entity sets:

Weak entity set attributes plus the master code of the dependent strong entity set

Table:

Tables with weak object sets and associated strong object sets are redundant.

Merge multiple-to-one: Entity A and entity B, and multiple-to-one contact set AB. If entity A is dependent on entity B, only two tables are created, and one or more primary key attributes of Entity A and entity B are created. (Multiple-to-one, two tables, one of which contains foreign keys; multiple-to-many, three tables, Relational Tables + two entity tables)

Use tables to represent multi-value attributes:

For a multi-value attribute M, a new table T must be created. One column C corresponds to M, and the other columns in T correspond to the master code of the entity set or contact set whose M is a multi-value attribute. For example, the relatives of employees are multiple rows.

Table representation:

1. Create a table for the high-level object set and a table for each underlying object set. The underlying entity set includes columns corresponding to the attributes of the underlying entity set. In addition, it also includes all attribute columns of the master code of the high-level entity set. (6 tables can be created in-15)

2. if the generalization is non-intersecting and all-that is, if two lower-level entity sets are directly affiliated with the same upper-level entity set, no entity belongs to both lower-level entity sets. At the same time, any entity in a high-level entity set must also be a member of a low-level entity set. In this case, you can use another representation method: instead of creating any table for the high-level object set, you can only create one table for each low-level object set, the table contains the columns corresponding to the attributes of the lower-level object set and those corresponding to the attributes of the higher-level object set. (-15 can create 4 tables)

Used to indicate clustering:

Capture Time of on-screen editing:

Related Article

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.