1 / 33

Data Modeling with the Entity-Relationship Model

Data Modeling with the Entity-Relationship Model. The Data Model. A data model is a plan, or blueprint, for a database design . A data model is more generalized and abstract than a database design.

yazid
Download Presentation

Data Modeling with the Entity-Relationship Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Modeling with the Entity-Relationship Model

  2. The Data Model • A data model is a plan, or blueprint, for a database design. • A data model is more generalized and abstract than a database design. • It is easier to change a data model than it is to change a database design, so it is the appropriate place to work through conceptual database problems.

  3. E-R Model • Entity-Relationship model is a set of concepts and graphical symbols that can be used to create conceptual schemas. • Versions • Original E-R model— Peter Chen (1976). • Extended E-R model— Extensions to the Chen model. • Information Engineering (IE) — James Martin (1990); it uses “crow’s foot” notation, is easier to understand. • IDEF1X — A national standard developed by the National Institute of Standards and Technology [see Appendix B] • Unified Modeling Language (UML) — The Object Management Group; it supports object-oriented methodology [see Appendix C]

  4. Entities • Something that can be identified and the users want to track • Entity class— a collection of entities of a given type • Entity instance — the occurrence of a particular entity • There are usually many instances of an entity in an entity class.

  5. CUSTOMER:The Entity Class and Two Entity Instances

  6. Attributes • Attributes describe an entity’s characteristics. • All entity instances of a given entity class have the same attributes, but vary in the values of those attributes. • Originally shown in data models as ellipses. • Data modeling products today commonly show attributes in rectangular form.

  7. EMPLOYEE:Attributes in Ellipses • Rather crowded when dealing with many entities

  8. EMPLOYEE:Attributes in Entity Rectangle • Most commonly used today

  9. Identifiers • Identifiers are attributes that name, or identify, entity instances.  Keys • The identifier of an entity instance consists of one or more of the entity’s attributes. • Composite identifiers: Identifiers that consist of two or more attributes • Identifiers in data models become keys in database designs: • Entities have identifiers. • Tables (or relations) have keys.

  10. Entity Attribute Displayin Data Models

  11. Relationships • Entities can be associated with one another in relationships: • Relationship classes: associations among entity classes • Relationship instances: associations among entity instances • In the original E-R model, relationships could have attributes but today this is no longer done. • A relationship class can involve two or more entity classes.

  12. Degree of the Relationship • The degreeof the relationshipis the number of entity classes in the relationship: • Two entities have a binary relationship of degree two. • Three entities have a ternary relationship of degree three.

  13. Binary Relationship

  14. Ternary Relationship

  15. Entities and Tables • The principal difference between an entity and a table (relation) is that you can express a relationship between entities without using foreign keys. • This makes it easier to work with entities in the early design process where the very existence of entities and the relationships between them is uncertain.

  16. Cardinality • Cardinality means “count,” and is expressed as a number. • Maximum cardinality is the maximum number of entity instances that can participate in a relationship. • Minimum cardinality is the minimum number of entity instances that must participate in a relationship.

  17. Maximum Cardinality • Maximum cardinality is the maximum number of entity instances that can participate in a relationship. • There are three types of maximum cardinality: • One-to-One [1:1] • One-to-Many [1:N] • Many-to-Many [N:M]

  18. The Three Types ofMaximum Cardinality

  19. Parent and Child Entities • In a one-to-many relationship: • The entity on the one side of the relationship is called the parent entity or just the parent. • The entity on the many side of the relationship is called the child entity or just the child. • In the figure below, EMPLOYEE is the parent and COMPUTER is the child:

  20. HAS-A Relationships • The relationships we have been discussing are known as HAS-A relationships: • Each entity instance has a relationship with another entity instance: • An EMPLOYEE has one or more COMPUTERs. • A COMPUTER has an assigned EMPLOYEE. • Contrast to IS-A relationships, which shows the inheritance relationship. • Person entity has name and address • Student entity is inherited from Person entity. Therefore, Student’s name is Person’s name.

  21. E-R Model • The E-R (entity-relationship) data model views the real world as a set of basic objects (entities) and relationships among these objects.

  22. Entities • Something that can be identified and the users want to track • Entity class— a collection of entities of a given type • Entity instance — the occurrence of a particular entity • There are usually many instances of an entity in an entity class.

  23. Entity • An entity is an object that exists and is distinguishable from other objects. For instance, John Doe/SID 15346 at AcmeU is an entity, as he can be uniquely identified as one particular person in the universe. • An entity may be concrete (a person or a book, for example) or abstract (like a holiday or a concept) • An entity set is a set of entities of the same type (e.g., all students at AcmeU). • Entity sets need not be disjoint. For example, the entity set student (all students of AcmeU) and the entity set customer (all customers of the bank) may have members in common

  24. Attributes • An entity is represented by a set of attributes. • E.g. name, SID, street, city for student entity. • The domain of the attribute is the set of permitted values (e.g. the telephone number must be seven positive integers). • Formally, an attribute is a function which maps an entity set into a domain. • Every entity is described by a set of (attribute, data value) pairs. • There is one pair for each attribute of the entity set. • E.g. a particular student entity is described by the set {(name, Jones), (SID, 15346), (city, Tacoma)}.

  25. Analogy to programming language • An analogy can be made with the programming language notion of type definition. • The concept of an entity set corresponds to the programming language type definition. • A variable of a given type has a particular value at a point in time. • Thus, a programming language variable corresponds to an entity in the E-R model.

  26. Maximum Cardinality • Maximum cardinality is the maximum number of entity instances that can participate in a relationship. • There are three types of maximum cardinality: • One-to-One [1:1] • One-to-Many [1:N] • Many-to-Many [N:M]

  27. Indicating Minimum Cardinality • As shown in the examples in a following slide: • Minimum cardinality of zero [0] indicating optional participation is indicated by placing an oval next to the optional entity. • Minimum cardinality of one [1] indicating mandatory (required) participation is indicated by placing a vertical hash mark next to the required entity.

  28. The Three Types ofMinimum Cardinality

  29. Reading Minimum Cardinality • Look toward the entity in question: • IF you see an oval THEN that entity is optional (minimum cardinality of zero [0]). • IF you see a vertical hash mark THEN that entity is mandatory (required) (minimum cardinality of 1).

  30. The Three Types ofMinimum Cardinality

  31. Data Modeling Notation

  32. Data Modeling Notation: ERwin

  33. Data Modeling Notation: N:M and O-M Note that: (1) ERwin cannot indicate true minimum cardinalities on N:M relationships (2) Visio introduces the intersection table instead of using a true N:M model

More Related