E-R Diagram to database table

Source: Internet
Author: User

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: if the e1,e2,..., en is a set of n entities, then the contact set R is {(E1,e2,..., en) |e1 belongs to a subset of E1,e2 belonging to E2,... en, and (E1,e2,..., en) is a connection.

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


The number of entities in a given entity set or how contacts in a given contact set differ from each other

Entity set:

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

Candidate code: The minimum Super code (any true subset of the super-code can not become the super-code) is the candidate code. The candidate code can have more than one.

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

Any two entities in an entity set are not allowed 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 situation, the main code of a party is composed of many; for one-to-two situations, the main code of any table can be the main code of the contact set.

The cardinality of a map: one-to-many; many-to-many

A and B are entity sets

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

One-to-many: an entity in a can be associated with any 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 any number of entities in B, and an entity in B can also be associated with any number of entities in a.

A contact may also have a descriptive attribute that differs from the property of a contact contained entity

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 describing the behavior that occurs between entities. This method is also useful when deciding whether to express certain properties 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 a participating entity set rather than in a contact set. A one-to -many link attribute can be placed in the entity set of the "many" side of the contact, and the properties of the contact can be placed in any of the entity's entities involved in the contact set.

The decision to specify whether a descriptive attribute is a property of a contact or an attribute of an entity at design time should reflect the characteristics of the facts being simulated . The designer can choose to preserve access-date as an attribute of depositor, indicating that access occurs on the interaction point of the entity set customer and account.

In many-to-many cases, the attribute must be placed in a many-to-many contact set when a property is determined by the participating entity set union rather than by a separate entity set .

dependent, full participation, partial participation

Dependency: Loan and repayment, a loan data may correspond to multiple repayment data, repayment depends on the loan.

Full participation: Entities are all involved in a contact set. The repayment data entities are all involved in the "loan repayment" relationship, and all repayments are linked to a loan.

Partial participation: The entity part participates in a contact set. The customer data Entity part 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: Indicates that an entity is all involved 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 where an entity contains multiple properties, a property that can be derived from another property is called a derivation property. For example, there are attributes such as "Birthday" and "age" in the student entity, from birthdays you can calculate the value of the age attribute, and the age attribute is the derived property.

Multi-valued attributes: For example, an employee's relative 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 contains attributes that are underlined.

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

Weak entities do not have a master code, but have a distinguished character, 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.

If a weak entity set participates only in symbolic relationships and its properties are not many, it is more appropriate to describe it as a property at modeling time. Conversely, if a weak entity set participates in a contact that is considered an identity contact, or if its properties are many, it is more appropriate to model it as a weak entity set.

Specialization and generalization we can all use the above triangle construction to express, attribute inheritance is also for 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

Multiple-to-one merging: entity A and Entity B, and many-to-one contact set AB, if a has a pair of B dependencies, then only two tables are established, one and B primary key attributes in a. (Many-to-one, two-table, multi-party containing foreign keys; many-to-many, three-sheet, relational-table + two-entity-table)

To represent a multivalued property with a table:

For a multivalued attribute m, you must create a new table T, where 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. For example, relatives of employees, multiple lines.

Use a table to represent a generalization:

1. Create a table for the high-level entity set, and a table for each underlying entity set. The underlying entity set includes columns that correspond to the properties of the underlying entity set, plus all attribute columns for the high-level entity set Master code. (Figure 2-15 can be set up to correspond to 6 tables)

2. If the generalization is disjoint and all-that is, if two lower-level entity sets are directly subordinate to the same set of high-rise entities, then there will be no entities belonging to both lower-layer entity sets at the same time, and any entity of the high-level entity set will necessarily be a member of a lower entity set. At this point, you can take another representation: No tables are created for the high-level entity set, only one table is created for each lower set of entity sets, and the table includes columns that correspond to the properties of the lower-level entity set and columns that correspond to the properties of the upper-layer entity set. (Figure 2-15 can be set up to correspond to 4 tables)

Used to indicate aggregation:

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

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.