Udostępnij za pośrednictwem


Entities and Relationships (EDM)

The Entity Data Model (EDM) is an entity-relationship (ER) model. In the typical line of business (LOB) application, the structure of data is abstract during the early stages of application design. The design must specify how the application will contain various kinds of data in a logical structure. Orders, customers, order lines, addresses, suppliers, products, and employees, for example, will be represented by data structures, many of them very complex. After the elementary concepts are identified, entities are the formal specifications for all the details of data structure.

A Customer data type, for example, is designed to contain details like contact name, company name, address, and a unique identifier for each customer. An Order type might contain order date, order lines, due date, a unique identifier, and other data. Like most other data models, the EDM represents the logical connection between an order and the customer who makes the order as a relationship.

The following diagram illustrates some of the details of data structure and models them using the concepts of entities and relationships as specified by the EDM. In the diagram, entities are represented by rectangles and relationships are represented by the lines between rectangles. The text inside the rectangles represents the properties of entities.

Customer, Order, OrderLines diagram

Only top-level concepts are called entities in the EDM. In the diagram, a Customer is a top-level concept and is modeled as an entity. In the EDM, the Customer entity is derived from the basic EntityType.

Subordinate data elements are called properties of entities. The Customer entity has several properties: CustomerID, CompanyName, ContactName, Address, and Phone. Each of these properties has a data type. For example, the CustomerID is a string, as are CompanyName and ContactName.

In the diagram, the Address property differs from the other properties because it has an internal structure that contains several kinds of information. In the EDM, a nested data structure, such as this address, can be modeled as an entity and then use an association and a navigation property to connect it to the entity within which it functions as a property.

The Customer and Address data types are similar in that they both have internal structures composed of multiple properties; semantically and operationally, a Customer differs from an Address. Customer is likely to be the unit of query or data modification operations and of persistence. An Address, on the other hand, always exists in a Customer data type and is not generally used independently.

The relationships between entities are modeled using associations. An association is the relationship between entities, such as the relationship between a Customer and an Order. Every Order must have a corresponding Customer. Order and Customer are logically related but exist as independent entities. For more information about the association relationship, see Association (EDM).

The relationship in which one entity logically controls the other, such as an Order and its OrderLine items, is also represented by the association relationship. Each Order is composed of at least one OrderLine. If a Customer orders product #49, for example, the information about the item ordered consists of an OrderLine. The OrderLine cannot exist without the Order.

See Also

Concepts

Implementing Entities (EDM)
Implementing Associations (EDM)

Other Resources

Schemas and Mapping Specification (Entity Framework)