1 / 38

Chapter 3: Modeling Data in the Organization

Chapter 3: Modeling Data in the Organization. Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden. Objectives. ERD: Relationship Relationship Type vs. Relationship Instance Degree of Relationship: unary, binary, and ternary relationship

faunus
Download Presentation

Chapter 3: Modeling Data in the Organization

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. Chapter 3:Modeling Data in the Organization Modern Database Management 8th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden © 2007 by Prentice Hall

  2. Objectives • ERD: Relationship • Relationship Type vs. Relationship Instance • Degree of Relationship: unary, binary, and ternary relationship • Cardinality of relationship • Cardinality (Participation) Constraint • Convert many-to-many relationships to associative entities

  3. Relationship Types vs. Relationship Instances • Relationship type: • A meaningful association between (or among) entity types. • Represented by a single verb phrase. • E.g., WORKS_ON relationship type between EMPLOYEE and PROJECT. • Relationship instance: • each relationship instance includes exactly one entity instance from each participating entity type. • E.g., Employee A works on Project X.

  4. Figure 3-10 Relationship types and instances a) Relationship type b) Relationship instances

  5. More on Relationships • Relationship Types vs. Relationship Instances • The relationship type is modeled as lines between entity type • The instance is between specific entity instances • Relationships can have attributes • These describe features pertaining to the association between the entities in the relationship • Example:

  6. More on Relationships • More than one relationship type can exist between the same participating entity types • MANAGES and WORKS_FOR are distinct relationship types between EMPLOYEE and DEPARTMENT • Different meanings and different relationship instances.

  7. Entities of two different types related to each other Entities of three different types related to each other One entity related to another of the same entity type Degree of relationships – the number of entity types that participate in it

  8. Example: Unary Relationship

  9. Example: Binary Relationship

  10. Example: Ternary Relationship

  11. Cardinality of Relationships • One-to-One • Each entity instance in the relationship will have exactly one related entity instance • One-to-Many • An entity instance on one side of the relationship can have many related entity instances, but an entity instance on the other side will have a maximum of one related entity instance • Many-to-Many • Entities on both sides of the relationship can have many related entity instances on the other side

  12. Figure 3-12 Examples of relationships of different degrees a) Unary relationships

  13. Figure 3-12 Examples of relationships of different degrees (cont.) b) Binary relationships

  14. Note: a relationship can have attributes of its own Figure 3-12 Examples of relationships of different degrees (cont.) c) Ternary relationship

  15. Cardinality Constraints • Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity • Minimum Cardinality • If zero, then optional • If one or more, then mandatory • Maximum Cardinality • The maximum number

  16. Cardinality: Notations

  17. Optional One

  18. Mandatory One

  19. Optional Many

  20. Mandatory Many

  21. A patient history is recorded for one and only one patient A patient must have recorded at least one history, and can have many Figure 3-17 Examples of cardinality constraints a) Mandatory cardinalities

  22. A project must be assigned to at least one employee, and may be assigned to many An employee can be assigned to any number of projects, or may not be assigned to any at all Figure 3-17 Examples of cardinality constraints (cont.) b) One optional, one mandatory

  23. Associative Entity – Many-to-Many Relationship Revisited a) Relationship type b) Relationship instances

  24. Figure 3-11a A binary relationship with an attribute Here, the date completed attribute pertains specifically to the employee’s completion of a course…it is an attribute of the relationship

  25. Associative Entities • An entity–has attributes • A relationship–links entities together • When should a relationship with attributes instead be an associative entity? • All relationships for the associative entity should be many • The associative entity could have meaning independent of the other entities • The associative entity preferably has a unique identifier, and should also have other attributes • The associative entity may participate in other relationships other than the entities of the associated relationship • Ternary relationships should be converted to associative entities

  26. Figure 3-11b An associative entity (CERTIFICATE) Associative entity is like a relationship with an attribute, but it is also considered to be an entity in its own right. Note that the many-to-many cardinality between entities in Figure 3-11a has been replaced by two one-to-many relationships with the associative entity.

  27. Your Turn: P.138, problem 5f (in 8th edition 4g on page 131) • Scenario 1) Assume that a consultant can work for only one company at a time, and we need to track only current consulting engagements. Draw an ERD for this situation.

  28. Your Turn: P.138, problem 5f (in 8th edition 4g on page 131) • Scenario 2) Include a new attribute Hourly_rate, that a consultant charges a company for his or her service. Draw an ERD for this situation.

  29. Your Turn: P.138, problem 5f (in 8th edition 4g on page 131) • Scenario 3) Now consider each time a consultant works for a company, a contract is written describing the terms. Assuming that a consultant can still work for only one company at a time, and the company only need to track the current engagement, redraw the ERD. • Did you move any attribute to different entity type?

  30. Your Turn: P.138, problem 5f (in 8th edition 4g on page 131) • Scenario 4) Finally we need to keep the complete history of all consulting engagements for each consultant and company. Draw an ERD for this situation.

  31. Figure 3-21 Examples of multiple relationships a) Employees and departments Entities can be related to one another in more than one way

  32. Examples of multiple relationships

  33. Figure 3-21 Examples of multiple relationships (cont.) b) Professors and courses (fixed lower limit constraint) Here, min cardinality constraint is 2

  34. Strong vs. Weak Entities, andIdentifying Relationships • Strong entities • exist independently of other types of entities • has its own unique identifier • identifier underlined with single-line • Weak entity • dependent on a strong entity (identifying owner)…cannot exist on its own • does not have a unique identifier (only a partial identifier) • Partial identifier underlined with double-line • Entity box has double line • Identifying relationship • links strong entities to weak entities

  35. Identifying relationship Strong entity Weak entity

  36. Figure 3-13c An associative entity – bill of materials structure This could just be a relationship with attributes…it’s a judgment call

  37. Figure 3-18 Ternary relationship as an associative entity

  38. Microsoft Visio Notation for Pine Valley Furniture E-R diagram Different modeling software tools may have different notation for the same constructs

More Related