E-R Diagram to database table

Source: Internet
Author: User
Tags one table

Database E-r diagram Correlation

the years 6 Month the Day

17:39

The three main concepts used in the E-R data model are: entity sets, contact sets, and attributes

Entity set: A collection of entities with the same type and the same nature (or attributes)

Properties: Simple and conforming properties, single-valued and multivalued properties, null properties, derived properties

Contact Set: A contact is a correlation between multiple entities. A contact set is a collection of homogeneous contacts.

Eg: suppose E1,e2,...。 En is a set of n entities, then the contact set R is {(E1,e2,..., en) |e1 belongs to a subset of the e1,e2 belonging to the E2,... en, and (E1,e2,..., en) is a link.

capture time for screen clipping : 2014/6/15 18:14


Number of entities in a given entity set or how contacts in a given set of contacts differ from each other

Entity set:

Super code: A collection of one or more properties that enable us to uniquely identify an entity in an entity set. (may have redundant attributes)

Candidate code: The minimum Super code (the arbitrary true subset of the super-code can not become the super-code) is the candidate code.

The candidate code can have multiple.

Main code: Selected by the data designer to differentiate the candidate codes for different entities in the same entity set.

Arbitrary two entities in the entity set do not agree to have the same value on the code attribute at the same time.

Contact set: (Extra code, main code is not related to the attribute of the contact set)

Super code: The set of the main code of each entity is the super code of the contact set.

Main code: Cardinality (one-to-many, etc.) that relies on contact set mappings. For many-to-many cases, the main code of two tables is composed together. For a one-to-many case, the main code is composed of more than one party, and for one-to-one situations. No matter what the main code of a table can do the main code of the contact set.

Map cardinality: One-to-one; Many to one. Many-to-many

A and B are entity sets

One: A entity in a is associated with at most one entity in B. An entity in B also has at most one entity in a

One-to-many: an entity in a can be associated with a random number of entities in B, and an entity in B is associated with at most one entity in a

Many-to-many: an entity in a can be associated with a random number of entities in B. An entity in B can also be associated with a random number of entities in a.

Contact may also have descriptive narrative attributes, which differ from the attributes of the entities included in the contact

Using entity Sets or attributes: The main difference depends on the structure of the real-world facts being modeled. And the related semantics of the properties discussed

Use entity Sets or contact sets: Use a contact set when descriptive narratives occur between entities. This method is also useful when deciding whether to express certain attributes as a contact

The base scale of the contact may affect where the contact property is located.

The properties of one-to-one or one-to-many contact sets can be placed in the participating entity set rather than in the contact set. A one -to-many link attribute can be placed in the entity set of the "many" side of the contact . In the case of a one-to-one contact set, the attributes of the connection can be placed in any entity set that participates in the connection.

The decision to describe the narrative attribute as the property of the relationship or the attribute of the entity in the detailed design should reflect the characteristics of the facts being simulated . The designer is able to choose to preserve access-date as an attribute of depositor, indicating that access occurs at the interaction point of the entity set customer and account.

Many-to-many cases. When a property is determined by a union of participating entity sets rather than by a single entity set, the attribute must be placed in a many-to-many contact set .

dependencies, all participation, partial participation

There are dependencies: loans and repayments, a loan data may correspond to a number of repayment data. Repayment depends on the loan.

All participation: Entity all participates in a contact set.

Repayment data entity all participation in the "loan repayment" relationship, all repayments are linked to a loan.

Part of the participation: the entity part participates in a contact set. The Customer Data Entity section participates in the "customer loan" relationship, not all customers have a loan.

E-r diagram: Can represent the global logical structure of the database, simple, clear

Rectangle: The entity set.

Ellipse: property.

Diamond: Contact Set.

Segments: Connect properties to an entity set or connect an entity to a contact set.

Double ellipse: Represents a multi-valued property.

Virtual Ellipse: Represents a derived property.

Two lines: Represents an entity all participates in the contact set.

Straight line without arrows: Many-to-many

Line with arrows: arrow pointing to side of 1

Derived properties: In a database, an entity consists of multiple properties. The properties that can be derived from other properties are referred to as derivation properties. For example, there are attributes such as "Birthday" and "age" in the "student" entity. You can calculate the value of the age attribute from birthday, and the age attribute is the derived property.

Multi-valued attributes: For example, a relative of an employee can have more than one. When designing a database table, you need to start with a single table.


capture time for screen clipping : 2014/6/18 19:30

The main code includes the attributes underlined.

Weak entity set: The attributes of an entity set are not sufficient to form a master code. This 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 in a bilateral box.

Weak entities do not have a main code, but there is a resolution, marked with a dashed underline

The main code of the weak entity set: The main code of the strong entity set that the weak entity set depends on and the distinguished character of the weak entity set.

Assuming that the weak entity set only participates in the symbolic link, and its properties are not many, it is more appropriate to describe it as a property in modeling.

Conversely, it is more appropriate to model a weak entity set as a weak entity set when it is assumed to be in a relationship with an identity contact, or if its properties are many.

Specialization and generalization we can all be represented by the above triangle construction. Attribute inheritance is also specific to specialization and generalization.

To be treated as an entity;

capture time for screen clipping : 2014/6/18 17:42

Design the E-R mode of the database

capture time for screen clipping : 2014/6/18 20:15

Convert e-r mode to table

To represent a strong entity set with a table:

To represent a weak entity set with a table:

Weak entity set attribute plus the main code of the strongly-dependent entity set

To represent a contact set with a table:

The table of the associated set of weak entity sets and strong entity sets is redundant

Many-to-one merges: entity A and Entity B, and many-to-one contact set AB, assuming that a has a dependency on B, then only two tables are created, and A is one and B primary key attributes. (Many-to-one, two-table, many-side including foreign keys.) Many-to-many, three-sheet tables, relational tables + two entity tables)

To represent a multivalued property with a table:

For a multivalued attribute m, you must create a new table T, in which a column C corresponds to M, and the remaining columns in t correspond to the main code of the entity set or contact set with the multi-valued attribute M. such as relatives of employees. MultiRow

Use a table to represent a generalization:

1. Create a table for the high-level entity set, and at the same time create a table for each underlying entity set.

The underlying entity set contains columns corresponding to the properties of the underlying entity set, and also contains all the attribute columns of the high-level entity set Master code. (Figure 2-15 can build 6 tables)

2. Assuming that the generalization is disjoint and all-that is, assuming that two lower-level entity sets are directly subordinate to the same set of high-rise entities, there will be no entities at the same time belonging to both lower-layer entity sets. At the same time. Any entity of a high-level entity set must also be a member of a lower entity set.

At this time There is also a representation method: No tables are created for a high-level entity set. Only one table is created for each lower-level entity set, and the table contains the columns corresponding to the properties of the lower entity set and the columns corresponding to the properties of the upper entity set. (Figure 2-15 can build 4 tables)

Used to indicate aggregation:

capture time for screen clipping : 2014/6/18 20:03

E-R Diagram to database table

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.