1 / 52

Conceptual Data Models Chapter 7

Conceptual Data Models Chapter 7. Conceptual Data Model . Requirement collection/analysis results in well-formed requirements Can be used to create conceptual data model diagram Useful in understanding DB Used to map to DB model of DBMS Examples are: ER/EER model UML.

joshua
Download Presentation

Conceptual Data Models Chapter 7

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. Conceptual Data Models Chapter 7

  2. Conceptual Data Model • Requirement collection/analysis results in well-formed requirements • Can be used to create conceptual data model diagram • Useful in understanding DB • Used to map to DB model of DBMS • Examples are: • ER/EER model • UML

  3. ER model – Entity-Relationship • ER model – Chen • High-level conceptual model • Concepts • Entity – basic object from real-world • Entity type – defines collection/set of entities with same attributes • box in diagram • Entity set – collection of entities of entity type (instances)

  4. Attributes • Describes property of entity set • Oval in ER diagram • Atomic vs. composite (levels of ovals) • Single-valued vs. multivalued (double oval) multivalued composite • Stored vs. derived (dashed-line oval) • Key attribute (name underlined)

  5. Attributes cont’d • Every entity has a value for each attribute • Null valued • Not applicable • Missing • Not known/not applicable or missing • Attribute associated with domain of values

  6. Relationship • Relationship – one entity type refers to another entity type • Relationship type – set of associations between entities • Relationship set – collection of all relationships of relationship type • Diamond in ER diagram

  7. Relationship cont’d • Relationship types of different degrees: • Binary (typical) – two entity types participate • Ternary – three entity types participate • Higher degrees (rare) • Relationship instance – associates an entity from each set that participates • Can participate in > 1 relationship • Recursive relationship – same entity participates in relationship • Role names (on lines)

  8. Relationships cont’d • Structural constraints on relationship types • Cardinality ratio - # of instances 1:1 relationship 1:N relationship M:N relationship • Participation constraint Total participation Partial participation • Relationship attributes

  9. Structural Constraints • 2 options: 1. Combine notation • Min, Max 2. Separate notation • One for cardinality ratio • One for participation constraints

  10. Min,Max (min, max) where each entity participates in at least min and at most max relationships captures both cardinality ratio and participation constraints If min = 0, means partial, if min >= 1, total participation e.g. (1, 1) from employee to works_for (1, N) from department to works_for

  11. Separate notation • Cardinality ratio( # on line) • Participation constraint (double line for total) e.g. If N employees work for 1 department, put N on line from employee to works_for and 1 on line from department to works_for If must work for a department, double line, else single line If 1:N relationship, N is on opposite side as in previous notation

  12. Weak entity sets • Weak entity sets have no key attributes of their own (double box) • Always related to identifying owner via identifying relationship (double diamond) • Total participation (double line) • Partial key (dashed underline)

  13. ER diagram • Fig. 7.7 shows all ER components

  14. Additional notation • Alternative notations – structural constraints • One: 1 Many (N) : > (outer notation) • Mandatory: | Optional: 0 (inner notation) • ERD Tool • NOTE: place constraints on opposite side

  15. Mini-world is company DB (textbook) The database will keep track of employees and departments. • For each employee we will keep track of their name and their unique employee ID. • For each department we will keep track of the unique department ID and location. • Each employee reports to exactly one department. A department may have many employees reporting to it, but it does not have to have any.

  16. Mini-world is company DB (textbook) – initial requirements • Company has departments and department managers • Employees in company work for a department and work on project • Projects are associated with a department • Employee has name, SSN, address, salary, sex, birth date • For each project keep track of number of hours worked on project • Maintain information about dependents for insurance

  17. Company DB requirements - refined • Company is organized into departments • Each department has a unique name, unique number and an employee who manages the department • Keep track of the start date when employee began managing department • Department has several locations

  18. Company DB requirements • Department controls a number of projects • Each project has a unique name, unique number and a single location

  19. Company DB requirements • Each employee has a name, SSN, address, salary, sex, and birth date • Employee is assigned to one department but works on several projects which are not necessarily controlled by the same department • Keep track of the number of hours per week an employee works on each project • Keep track of supervisor of each employee

  20. Company DB requirements • Want to keep track of the dependents of each employee for insurance • Keep each dependent’s first name, sex, birth date, relationship to employee

  21. Missing information in requirements • Planned use? User groups? • Typical operations?

  22. ER diagram ER diagram (ERD) for the company database in the 3 different styles follows

  23. 7.2

  24. 7

  25. Additional notation • Alternative notations – structural constraints • One: 1 Many (N) : > (outer notation) • Mandatory: | Optional: 0 (inner notation) • ERD Tool • NOTE: place constraints on opposite side

  26. Company DB using ERD Tool

  27. Ternary Useful for many-to-many-to-many relationships When should one use a ternary?

  28. Company MG (Manufacturing Guru) • We have multiple products. • We have multiple suppliers. • We have multiple components. • We will keep track of which suppliers provide which components for which product.

  29. MG • Every product contains one or more components, each of which is provided by one supplier. • Every supplier can provide many componentsfor many products • Every component uses one product by one or more suppliers.

  30. Ternary If many-to-many-to-one, can just use binary relationships (depending on requirements)

  31. MG • Every product contains one or more components, each of which is provided by one or more supplier. • Every supplier can provide many components for many products • Every component is provided for one or more products by one or more supplier.

  32. Ternary • But this example is NOT many-to-many-to-one but many-to-many-to-many

  33. Ternary Relationships • 3 binary relationships is not sufficient to model this • would not keep track which suppliers provide which components for which product supplier • A1 supplies the component B for the product C • supplier A2 does not provide the component B for the product C • (i.e. supplier A2 provides the component B, but not for the product C)

  34. UML

  35. UML Notation – Universal Modeling Language • Objects (entities) are classes (box) • box contains the following separated by lines: • Object name • Attributes • method names

  36. Attributes in UML • Composite attribute modeled as structured domain • e.g. Name: NameDom Fname Minit Lname • Multivalued attribute modeled as a separate class • e.g. separate box, with aggregation notation using a diamond • Can specify domain of attribute by using : • e.g. Sex: {M, F}

  37. Relationships - associations • Relationship types are associations (lines) • Can be named (name on line) • Relationship instances are called links • (min, max) notation used - same as ERD tool • * indicates no limit • Relationship (link) attributes • Dashed line to box • Box with association name and attribute

  38. Weak entities • Weak entity – qualified association • placed in box directly attached to owner class • Partial key in box • Remaining attributes considered an aggregation • Multi-valued attributes represented by aggregation notation

  39. Issues • Primary keys • Typically added as a tag next to attribute name

  40. Stop here

  41. MG – altered specification • Every product contains one or more components, each of which is provided by one or more suppliers. • Every supplier can provide many components for many products, but they also do not have to provide any components for any products. • Every component is provided for one or many products by one or many suppliers.

  42. Associative Entity • No cardinality constraints on the figure • Where we would put a symbol indicating that we may record some suppliers who do not provide any components for any product? • Use a weak entity OR • Use an associative entity (diamond inside box) • Associative entities do not have unique or partially unique attributes, and often do not have any attributes at all

  43. Retail Company ZAG The database for the sales department of the retail company ZAG will capture data about the following: • For each product being sold: a product ID (unique), product name, and price. • For each category of the product: category ID (unique) and category name • For each vendor: vendor ID (unique) and vendor name

  44. For each customer: customer ID (unique), name and zip-code • For each store: store ID (unique) and zip code • For each region: region ID (unique) and region name • For each sale transaction: transaction ID (unique), date and time of transaction.

More Related