1 / 39

Chapter 6

Chapter 6. Developing Data Models for Business Databases. Outline. Analysis of narrative problems Transformations for generating alternative designs Finalizing an ERD Schema Conversion Alternative notations. Analyzing Narrative Problems (I).

elda
Download Presentation

Chapter 6

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 6 Developing Data Models for Business Databases

  2. Outline • Analysis of narrative problems • Transformations for generating alternative designs • Finalizing an ERD • Schema Conversion • Alternative notations

  3. Analyzing Narrative Problems (I) • Identify potential entity types and attributes • For entity types, find nouns that represent groups of people, places, things, and events • For attributes, look for properties that provide details about the entity types • Determine primary keys • Stable and single purpose • Identify other candidate keys

  4. Problem Narrative Example (I)

  5. Analyzing Narrative Problems (II) • Identify relationships connecting previously identified entity types • Relationship references involve associations among nouns representing entity types • Sentences that involve an entity type having another entity type as a property • Sentences that involve an entity type having a collection of another entity type

  6. Problem Narrative Example (II)

  7. Diagram Refinements • Construct initial ERD • Revise many times • Generate feasible alternatives and evaluate according to requirements • Gather additional requirements if needed • Use transformations to suggest feasible alternatives

  8. Attribute to Entity Type Transformation

  9. Compound Attribute Transformation

  10. Entity Type Expansion Transformation

  11. Weak to Strong Entity Transformation

  12. History Transformation (I)

  13. History Transformation (II)

  14. Generalization Hierarchy Transformation

  15. Summary of Transformations

  16. Documenting an ERD • Important for resolving questions and in communicating a design • Identify inconsistency and incompleteness in a specification • Identify reasoning when more than one feasible alternative exists • Do not repeat the details of the ERD • Incorporate documentation into the ERD

  17. Documentation with the ER Assistant • Attribute comments • Entity type comments • Relationship comments • Design justifications • Diagram notes

  18. Common Design Errors • Misplaced relationships: wrong entity types connected • Incorrect cardinalities: typically using a 1-M relationship instead of a M-N relationship • Missing relationships: entity types should be connected directly • Overuse of specialized modeling tools: generalization hierarchies, identification dependency, self-referencing relationships, M-way relationships • Redundant relationships: derived from other relationships

  19. Resolving Design Errors • Misplaced relationships: use entity type clusters to reason about connections • Incorrect cardinalities: incomplete requirements: inferences beyond the requirements • Missing relationships: examine implications of requirements • Overuse of specialized modeling tools: only use when usage criteria are met • Redundant relationships: Examine relationship cycles for derived relationships

  20. Example Entity Type Cluster

  21. Summary of Data Modeling Strategies • Use notation precisely • Strive for simplicity • ERD connections • Avoid over connecting the ERD • Identify hub(s) of the ERD • Use specialized patterns carefully • Justify important design decisions

  22. Summary of Basic Conversion Rules • Each entity type becomes a table. • Each 1-M relationship becomes a foreign key in the table corresponding to the child entity type (the entity type near the crow’s foot symbol). • Each M-N relationship becomes an associative table with a combined primary key. • Each identifying relationship adds a column to a primary key.

  23. Application of Basic Rules (I) CREATE TABLE Course (… PRIMARY KEY (CourseNo) ) CREATE TABLE Offering (… PRIMARY KEY OfferNo, FOREIGN KEY (CourseNo) REFERENCES Course )

  24. Application of Basic Rules (II) CREATE TABLE Enrollment (… PRIMARY KEY (StdSSN, OfferNo), FOREIGN KEY (StdSSN) REFERENCES Student, FOREIGN KEY OfferNo REFERENCES Offering )

  25. Application of Basic Rules (III) • Same conversion result as the previous slide • Different application of rules

  26. Generalization Hierarchy Rule • Mimic generalization hierarchy as much as possible • Each subtype table contains specific attributes plus the primary key of its parent table. • Foreign key constraints for subtype tables • CASCADE DELETE option for referenced rows • Reduce need for null values • Need joins and outer joins to combine tables

  27. Generalization Hierarchy Example Employee table: EmpNo (PK) SalaryEmp table: EmpNo (PK), EmpNo (FK) HourlyEmp table: EmpNo (PK), EmpNo (FK)

  28. Optional 1-M Rule • Separate table for each optional 1-M relationship • Avoids null values • Requires an extra table and join operation • Controversial

  29. Optional 1-M Example CREATE TABLE Teaches (… PRIMARY KEY (OfferNo) , FOREIGN KEY(OfferNo) REFERENCES Offering, FOREIGN KEY(FacSSN) REFERENCES Faculty )

  30. 1-1 Relationships CREATE TABLE Office (… PRIMARY KEY (OfficeNo) , FOREIGN KEY(EmpNo) REFERENCES Employee, UNIQUE (EmpNo) )

  31. ERD Variations • No standard ERD notation • Symbol variations • Placement of cardinality symbols • Rule variations • Be prepared to adjust to the ERD notation in use by each employer

  32. ERD Rule Variations • M-way relationships • M-N relationships • Relationships with attributes • Self-referencing relationships • Relationships connected to other relationships

  33. Chen ERD Notation

  34. Unified Modeling Language • Standard notation for object-oriented modeling • Objects • Object features • Interactions among objects • UML supports class diagrams, interface diagrams, and interaction diagrams • More complex than ERD notation

  35. Simple Class Diagram

  36. Association Class

  37. Generalization Relationship

  38. Composition Relationship

  39. Summary • Data modeling is an important skill • Use notation precisely • Consider alternative designs • Apply specialized concepts carefully • Work many problems • No standard ERD notation

More Related