Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CHAPTER 2: MODELING DATA IN THE ORGANIZATION Modern Database Management 11 th Edition.

Similar presentations


Presentation on theme: "Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CHAPTER 2: MODELING DATA IN THE ORGANIZATION Modern Database Management 11 th Edition."— Presentation transcript:

1 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CHAPTER 2: MODELING DATA IN THE ORGANIZATION Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi 1

2 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall OBJECTIVES  Define terms  Understand importance of data modeling  Write good names and definitions for entities, relationships, and attributes  Distinguish unary, binary, and ternary relationships  Model different types of attributes, entities, relationships, and cardinalities  Draw E-R diagrams for common business situations  Convert many-to-many relationships to associative entities  Model time-dependent data using time stamps  【】 2

3 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall E-R MODEL CONSTRUCTS (1)  Entities:  Entity instance–object, person, place/org, event, concept (often corresponds to a row in a table)  Entity Type–collection of entities (often corresponds to a table)  【 Definition of entities P. 58 】 (format to follow for your HW/proj)  Entity type: UNIVERSITY; entity instances?  is there an attribute Student_Last_Name in the above?  is there an attribute Name_of_Department in the above?  Entity type: DEPARTMENT; entity instances? 3

4 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Type of entities–object, person, place, event, concept EntityAttributes object Ex: Bottled water place Ex: State place Ex: City people Ex: Student people Ex: Patient event Ex: Stud-org-sponsored campus activities Think: City names in State table? Similarly: UNIV, COLLEGE, FACULTY, STUDENT 4

5 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall E-R MODEL CONSTRUCTS (2)  Attributes:  Properties or characteristics of an entity or relationship type  (often corresponds to a field/column in a table) 5

6 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall E-R MODEL CONSTRUCTS (3)  Relationships:  Relationship instance–link between entities (entity instances)  【 Relationship type 】 – category of relationship…link between entity types  【 Descriptions 】 P. 59 (REQUIRED format for your HW/proj)  (often corresponds to ___/______ among related tables)  Q: Same column; how do we know which is which?  Try to state a relationship instance? Such as one that is between entity types STUDENT and COURSE? 6

7 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall In BusinessIn DB Concept In DB Implementation Remark Biz function Entity type Entity instance Attribute PK/FK – which is which? Relationship *(“num- ber”) 7

8 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 8 Sample E-R Diagram (Figure 2-1) Explanation of entities: P.58; business rules: P.59 – important, and useful!

9 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall E-R Diagram Notation – Chen (1976) 9

10 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 10 E-R Diagram: Chen Notation Boxes represent entities Ovals represent attributes Diamonds represent relationships

11 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 11 Relationship degrees specify number of entity types involved (unary, binary, ternary) Entity symbols A special entity that is also a relationship Relationship symbols Relationship cardinalities specify # entity instances in the other end of the relationship each entity instance in this end is allowed to associate Attribute symbols Basic E-R notation (Figure 2-2)

12 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall DEGREE & CARDINALITY OUTLINE  Degree:  Unary  Binary  Ternary  Cardinality:  “Number”:  One-to-one  One-to-many  Many-to-many  “Intensity”:  Mandatory  optional 12 Every scenario will be described or constructed from three dimensions – Example: -binary, mandatory one-to-many -Unary, optional one-to-one -etc

13 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall MODELING THE RULES OF AN ORG  P. 60: “what data modeling is all about?” –  To document rules and policies of an organization!  Business rules and policies govern –  Creating, {ex: enrollment record}  Updating, {ex: units attempted; units earned}  Removing {ex: customer credit card number} data in an info storage and processing system  Business rules and policies  must be described along with  the data to which they are related 12

14 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall BUSINESS RULES  Are statements that define or constrain some aspect of the business  Are derived from policies, procedures, events, functions  Assert business structure  Control/influence business behavior  Are expressed in terms familiar to end users  Are automated through DBMS software  Relationships in an ERD are defined/derived from business rules 14

15 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall OVERVIEW OF BUSINESS RULES (1)  Are statements that define or constrain some aspect of the business  Are derived from policies, procedures, events, functions  Assert business structure  Control/influence business behavior  Are expressed in terms familiar to end users  Are automated through DBMS software  Data definition language DDL 14

16 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall OVERVIEW OF BUSINESS RULES (2)  Are statements that define or constrain some aspect of the business  Syntax of business rules: ENTITY_1 Relationiship_Verb_Phrase number ENTITY_2 ENTITY_1 Relationiship_Verb_Phrase number ENTITY_2 where Relationiship_Verb_Phrase = Cardinality_adverb + Relationship_Verb Examples: ENTITY_1 May/Must Do/Have number ENTITY_2 STUDENT may have many ENROLLMENT CAR must be registered to at least one OWNER CUSTOMER must be served by only one EMPLOYEE  Two examples P. 61 – think about more examples of yours? 15

17 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall A GOOD BUSINESS RULE IS: (TABLE 2-1, P.62)  Declarative–what, not how  Precise–clear, agreed-upon meaning  Atomic–one statement  Consistent–internally and externally  Expressible–structured, natural language  Distinct–non-redundant  Business-oriented–understood by business people  Excellent examples: P. 59 17

18 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall  Production operation:  Product  Raw material  Work center  Equipment  Employee 18

19 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall A GOOD DATA NAME IS:  Related to business, not technical, characteristics  Meaningful and self-documenting  Unique  Readable  Composed of words from an approved list  Repeatable - different people would develop same name  Written in standard syntax  Excellent examples: P. 58 19

20 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SALIN’S (1990) SUGGESTION ON DATA NAME  Preparing a definition of the data  Removing insignificant words  Arranging the words in a meaningful, repeatable way  Assigning a standard abbr for each word  Use qualifiers if needed 18

21 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall DATA DEFINITIONS  Explanation of a term or fact  Term–word or phrase with specific meaning  Fact–association between two or more terms  Examples: P.64  Guidelines for good data definition  A concise description of essential data meaning  Gathered in conjunction with systems requirements  Accompanied by diagrams  Achieved by consensus, and iteratively refined 21

22 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall The E-R model is most used as a tool for communications between database designers & end users during the analysis phase of database development 20

23 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall ENTITIES  Entity – an object, a person, a place/?, an event, or a concept in the user environment  about which the organization wishes to maintain data  Entity type – a collection of entities that share common properties or characteristics  TRUCK // STUDENT  Entity instance – A single occurrence of an entity type  2014 Chevy Tahoe // John Smith, ACCT 23 Kinds of entities: P.66

24 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall AN ENTITY…  SHOULD BE:  An object that will have many instances in the database  An object that will be composed of multiple attributes  An object that has relationship w other object(s)  An object that we are trying to model  SHOULD NOT BE:  A user of the database system  An output of the database system (e.g., a report)  We use capital for names of entity types An entity has many instances. Ex: FACULTY has Jeff Zhang, David Liu… Implementation ? 22 Do not confused with one-to-many

25 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall ENTITY TYPE AND ENTITY INSTANCES 25 Instances Value of an attribute

26 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 26 Inappropriate entities Systemuser System output Figure 2-4 Example of inappropriate entities Appropriate entities

27 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall STRONG VS. WEAK ENTITIES, AND IDENTIFYING RELATIONSHIPS  Strong entity  exists 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)  entity box and partial identifier have double lines  Identifying relationship  links strong entities to weak entities – double line 27 - Uses the identifier of the strong entity as its identifier

28 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 28 Strong entity Weak entity Figure 2-5 Example of a weak identity and its identifying relationship

29 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall NAMING AND DEFINING ENTITY TYPES  Naming: 1) Singular noun 2) Specific to the organization 3) Abbr can be used; follow same rules 4) Named for result of event, not the process 5) Consistent  Defining ( more see P71 ):  What entity instances are included and not included  Often includes when an instance is created/  For some entity types: what history to be kept 27

30 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall ATTRIBUTES  Attribute–property or characteristic of an entity or relationship type  Every entity instance has its own set of values for the attributes of the entity (when each attribute has a specific value, …)  Classifications of attributes:  Required versus Optional Attributes  Simple versus (Composite Attribute)  Single-Valued versus {Multivalued Attribute}  Stored versus Derived Attributes  Identifier Attributes 30 Note the notations

31 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall REQUIRED VS. OPTIONAL ATTRIBUTES 31 Required – must have a value for every entity (or relationship) instance with which it is associated Optional – may not have a value for every entity (or relationship) instance with which it is associated

32 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SIMPLE VS. (COMPOSITE) ATTRIBUTES  Composite attribute – An attribute that has meaningful component parts (attributes) 32 The address is broken into component parts Figure 2-7 A composite attribute Example?

33 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 33 Figure 2-8 Entity with multivalued attribute (Skill) and derived attribute (Years Employed) Multivalued an employee can have more than one skill Derived Calculated from date employed and current date {Multi-valued} and Derived Attributes Multivalued – may take on more than one value for a given entity (or relationship) instance Derived – values can be calculated from related attribute values (not physically stored in the database) Example:

34 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall IDENTIFIERS (KEYS)  Identifier (Key)–an attribute (or combination of attributes) that uniquely identifies individual instances of an entity type  Simple versus Composite Identifier  An order line item is identified with…  Candidate Identifier–an attribute that could be a key…satisfies the requirements for being an identifier 34

35 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CRITERIA FOR IDENTIFIERS  Choose Identifiers that  Will not be null  Unique for each instance in the entity  Will not change in value  Avoid intelligent identifiers (e.g., containing locations or people that might change)  Substitute new, simple keys for long, composite keys – example: 35

36 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 36 Figure 2-9 Simple and composite identifier attributes The identifier is boldfaced and underlined

37 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall NAMING ATTRIBUTES  Name should be a singular noun or noun phrase  Name should be unique  Name should follow a standard format  e.g. [Entity type name { [ Qualifier ] } ] Class  Similar attributes of different entity types should use the same qualifiers and classes 37

38 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall DEFINING ATTRIBUTES  State what the attribute is and possibly why it is important  Make it clear what is and is not included in the attribute’s value  Include aliases in documentation  State source of values  Specify required vs. optional  State min and max number of occurrences allowed  Indicate relationships with other attributes 38

39 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall INTRO TO RELATIONSHIP  An association representing an interaction among the instances of one or more entity types – P.75  A relationship has a verb name  A name that describes the nature of the relationship  - examples:  STDENT takes COURSE,  MANAGER supervises EMPLOYEE,  ENGINEER is assigned to PROJECT,  PART is used in PRODUCT…  Think about one that involves an organization? 37

40 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall MODELING RELATIONSHIPS  Relationship Types vs. Relationship Instances  The relationship type is modeled as lines between entity types  the relationship instance is between specific entity instances  Relationships can have attributes  These describe features pertaining to the association between the entities in the relationship  Two entities can have more than one type of relationship between them (multiple relationships)  Associative Entity–combination of relationship and entity (“relationship-turned-entity”) 40

41 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 41 Figure 2-10 Relationship types and instances a) Relationship type (Completes) b) Relationship instances Next slide

42 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 42

43 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Figure 2-11a A 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 Please note: the above relationship is a many-to-many. What if it is one-to-many? Can we do the same re “Date- completed”? “Grade”? How? - in each scenario, the two attributes would be that of different entities 41

44 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall ASSOCIATIVE ENTITIES They are:  An entity–has attributes  A relationship–links entities together  Associative Entity–combination of relationship and entity  Whether or not to convert a relationship to an associative entity type? – four conditions (P 78) 1) Many-to-many 2) Resulting entity type has independent meaning, and can be identified 3) Has one or more attributes in addition to … 4) The associative entity participates in relationship(s) independent of the entities related in the associated relationship (P.80)  **   Ternary relationships should ALWAYS be converted to associative entities   ** 42

45 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 45 Figure 2-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 2-11a has been replaced by two one-to-many relationships with the associative entity (Note that min cardinalities are missing above for the associative entity) P. 79, second paragraph

46 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall ONLINE REFERENCES OF E-R DIAGRAM  A concise but fairly complete E-R model quick reference:  http://creately.com/blog/diagrams/er-diagrams- tutorial/ http://creately.com/blog/diagrams/er-diagrams- tutorial/  E-R diagram elements (Chen and crow’s foot), with examples  http://www.conceptdraw.com/solution- park/diagramming-ERD http://www.conceptdraw.com/solution- park/diagramming-ERD 46

47 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall DEGREE OF RELATIONSHIPS  Degree of a relationship is the number of entity types that participate in it 1. Unary Relationship  Between instances of a single entity 2. Binary Relationship  Between instances of two entities 3. Ternary Relationship  Between instances of three entities 47 Compared w cardinality - # of entity instances associated w EACH one instance

48 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 48 Degree of relationships – from Figure 2-2 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

49 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 49 Figure 2-12 Examples of relationships of different degrees a) Unary relationships

50 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 50 Figure 2-12 Examples of relationships of different degrees (cont.) b) Binary relationships

51 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 51 Figure 2-12 Examples of relationships of different degrees (cont.) c) Ternary relationship Note: a relationship can have attributes of its own

52 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 52 Figure 2-13c An associative entity – bill of materials structure This could just be a relationship with attributes…it’s a judgment call

53 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 53 Figure 2-14 Ternary relationship as an associate entity Guidelines: PP.82~83

54 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 54 More cases of ternary relationships? PATIENT – TREATMENT – DOCTOR? STUDENT – COURSE – FACULTY? Guidelines: PP.82~83

55 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 55 Attributes or entity? Fig 2-15a

56 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 56 Attributes or entity? Fig 2-15b

57 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 57 Attributes or entity? Fig 2-15c Participating in other relationships

58 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 58 Figure 2-13c An associative entity – bill of materials structure This could just be a relationship with attributes…it’s a judgment call.

59 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 59 CARDINALITY OF RELATIONSHIPS Watch out the difference between Degree of relationship And Cardinality!! # entities involved – one, two, or three # entity INSTANCEs related – one, or many (mand. or opt.)

60 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CARDINALITY OF RELATIONSHIPS  One-to-One  Each entity instance in the relationship (“A”) will have exactly one related entity (“B”)  One-to-Many  An entity instance (in “A”) on one side of the relationship can have many related entity instances (in “B”), but an entity instance on the other side will have a maximum of one related entity instance  Many-to-Many  Entity instances on both sides of the relationship can have many related ent. Inst. on the other side 60 Must examine from BOTH sides to determine

61 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CARDINALITY CONSTRAINTS  Cardinality Constraints—the number of instances of one entity (“B”) that can or must be associated with each instance of another entity (“A”)  When you view a relationship from one entity to another: the number of instances of “ending” entity that can or must be associated with each instance of “starting” entity  Minimum Cardinality  If zero, then optional  If one or more, then mandatory  Maximum Cardinality - The max number 61

62 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 62 FIG 2-16 INTRODUCING CARDINALITY CONSTRAINTS Use the “starting” & “ending” to think about cardinalities The cardinality of each relationship is read from the opposite end of the starting entity

63 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Ent2 Ent1Ent4Ent3 63 Identify the shapes that represent MIN/MAX cardinalities

64 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Relationship cardinalities specify - for EACH instance on the “starting entity type,” the # of instances on the “ending entity type” is allowed {“starting” and “ending” here refer to direction of rela.} Basic E-R notation (Figure 2-2; portion) Minimum one Minimum zero Maximum one Maximum many 60 Side note: Avoid “MAX < MIN”

65 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall  One-to-one (1:1) – A relationship between two entities in which an instance of entity A can be related to only one instance of entity B; and an entity B instance can be related to only one instance of entity A Has (1) Located-in (1) TOWNAIRPORT Chen Info Engi Has 61

66 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall  Optional 66 Mandatory Mandatory (Left to right) Try making ER diagrams?

67 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall  One-to-many (1:M) – A relationship between two entities, in which an instance of entity A (any instance of A) can be related to zero, one, or more instances of entity B; and an instance of entity B can be related to only one instance of entity A Has (many) Is-place-by (1) This is Chen model; Information engineering method for the same scenario see left portion of next slide 63

68 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Info Engring (Crow’s foot) ORDER CUSTOMER ITEM 1 M 1 M COURSE DEPT ENROLLMENT 1 M 1 M Each CUSTOMER can place many ORDERs; Each ORDER is placed by Only one CUSTOMER How many customers are there? Try stating this relationship? 64

69 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall  Optional 69 Mandatory Mandatory (Left to right) Try making ER diagrams?

70 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall  Many-to-many (M:N) – A relationship between two entities in which an instance (any instance) of entity A can be related to zero, one, or more instances of entity B; AND an instance of entity B can be related to zero, one, or more instances of entity A Orders (many) Is-ordered-by (many) Chen 66

71 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall  Optional 71 Mandatory Mandatory (Left to right) Try making ER diagrams?

72 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 72 Figure 2-17 Examples of cardinality constraints a) Mandatory cardinalities A patient must have recorded at least one history, and can have many (viewed L to R) A patient history is recorded for one and only one patient (viewed R to L) Related slide added

73 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 73 Each Patient [1) LEFT entity] has recorded [2) relationship verb] at least one, up to many [3) cardinality], patient history (records) [4, RIGHT entity] Each Patient History (record) [a) RIGHT entity] has been recorded [b) relationship verb (I wrote it; not displayed)] For at least one, up to 1 (ONE) [c) cardinality], patient (records) [d) LEFT entity] Fig 2-17 a) Cardinality, annotated 1 2 3 4 a b c d

74 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 74 Figure 2-17 Examples of cardinality constraints (cont.) b) One optional, one mandatory An employee can be assigned to any number of projects, or may not be assigned to any at all (viewed L to R) A project must be assigned to at least one employee, and may be assigned to many (viewed R to L) Use the “starting” & “ending” to think about cardinalities

75 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 75 In the eyes of EMPOLYEE, PROJECT is optional many; In the eyes of PROJECT, EMPLOYEE is mandatory many. After the associative entity is introduced: 1.The “far ends” are ALWAYS _____________(can be explained) 2.In the eyes of EMPLOYEE, ASSIGNMENT is _________ 3.In the eyes of PROJECT, ASSIGNMENT is ____________ M-M to Associative Entity (2-17b, explained) EMPLOYEEPROJECTASSIGNMENT

76 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 76 Figure 2-17 Examples of cardinality constraints (cont.) c) Optional cardinalities A person is married to at most one other person, or may not be married at all Use the “starting” & “ending” to think about cardinalities

77 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 77 Figure 2-18 Cardinality constraints in a ternary relationship

78 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 78 Cardinality Summary (Logic) [Observe!] Each A each B Can/may related to ___ B, ___ A: Option./mand. ____ to ____ Each A each B Must related to Can/may related to ___ B, one A: Option./mand. ____ to ____ Each A each B Can/may related to ___ B, one A: Option./mand. ____ to ____ Each A each B Must related to Can/may related to ___ B, one A: Option./mand. ____ to ____ Each A each B Can/may related to ___ B, many A: Option./mand. ____ to ____ Each A each B must related to Can/may related to ___ B, many A: Option./mand. ____ to ____

79 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 79 The “far ends” are Max? Min? The “near-center ends” are Min? Max? So one must always ensure that the “far ends” are never _________ Recap of MIN/MAX

80 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 80 Figure 2-19 Simple example of time-stamping The Price History attribute is both multivalued and composite. Time stamp – a time value that is associated with a data value, often indicating when some event occurred that affected the data value

81 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 81 Example of time, Fig 2-20a

82 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 82 Example of time, Fig 2-20b

83 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 83 Figure 2-20c E-R diagram with associative entity for product assignment to product line over time The Assignment associative entity shows the date range of a product’s assignment to a particular product line. Modeling time-dependent data has become more important due to regulations such as HIPAA and Sarbanes-Oxley.

84 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 84 Entities can be related to one another in more than one way Figure 2-21 Examples of multiple relationships a) Employees and departments Related slide added

85 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 85 Figure 2-21 Examples of multiple relationships (cont.) b) Professors and courses (fixed lower limit constraint) Here, min cardinality constraint is 2. At least two professors must be qualified to teach each course. Each professor must be qualified to teach at least one course.

86 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 86 Figure 2-21 Examples of multiple relationships c) CUSTOMER and COMPANY, in the Web 2.0 age Relationship 1: CUSTOMER does_business_with COMPANY Relationship 2: CUSTOMER ________________ COMPANY Extension of CUSTOMERCOMPANY does_business_with ________?________

87 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 87 Figure 2-22 Data model for Pine Valley Furniture Company in Microsoft Visio notation Different modeling software tools may have different notation for the same constructs.

88 Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 88 New slide about Cardinality: Should go after Slide #60 EACH A, one B; EACH B, one A – One-to-One EACH A, Many B; EACH B, ONE A – One-to-Many EACH A, Many B; EACH B, MANY A – Many-to-Many AB


Download ppt "Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CHAPTER 2: MODELING DATA IN THE ORGANIZATION Modern Database Management 11 th Edition."

Similar presentations


Ads by Google