CHAPTER 2: MODELING DATA IN THE ORGANIZATION (THE BASIC ER-MODEL) © 2013 Pearson Education 1 Modern Database Management 11 th Edition, International Edition.

Slides:



Advertisements
Similar presentations
Entity-Relationship (ER) Modeling
Advertisements

Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Systems Development Life Cycle
Data Modeling is an Analysis Activity
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
Entity Relationship Model
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 3 The Entity- Relationship Model.
Database Design & Mapping
System Analysis - Data Modeling
Chapter 3: Modeling Data in the Organization
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
DATABASE APPLICATION DEVELOPMENT SAK 3408
Chapter 3: Modeling Data in the Organization
Chapter 2: Modeling Data in the Organization
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.
Chapter 4 Entity Relationship (ER) Modeling
Chapter 8 Structuring System Data Requirements
Chapter 3 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Importance of data modeling Importance of data modeling Write good.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 10 Structuring.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Entity Relationship Diagrams (ERDs)
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 7th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
1 © Prentice Hall, 2002 CMIS564: E/R Modeling Dr. Bordoloi Based on Chapter 3; Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 2: Modeling Data in the Organization Modern Database Management 10 th Edition Jeffrey.
Chapter 3: Modeling Data in the Organization
Chapter 3: Modeling Data in the Organization
Data Modeling ERM ERD.
Chapter 2: Modeling Data in the Organization
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
Conceptual Data Modeling, Entity Relationship Diagrams
DATABASEMODELSDATABASEMODELS  A database model ◦ defines the logical design of data. ◦ Describes the relationships between different parts of data.
Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CHAPTER 2: MODELING DATA IN THE ORGANIZATION Modern Database Management 11 th Edition.
5 Copyright © 2006, Oracle. All rights reserved. Understanding Entity Relationship Diagrams ( 實體關係圖 ) Part I.
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 2: Modeling Data in the Organization.
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Modeling Data in the Organization Chapters 3 + 4: Modern Database Management 9 th Edition.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Chapter 2 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 2: Modeling Data in the Organization Modern Database Management 11 th Edition.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Chapter 3: The Enhanced E-R Model
Carnegie Mellon University © Robert T. Monroe Management Information Systems Data Modeling Management Information Systems Robert.
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education 1 Modern Database Management 11 th Edition, International Edition Jeffrey A. Hoffer,
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 2: MODELING DATA.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 10 Structuring.
Pree Thiengburanathum, CAMT, Chiang Mai University 1 Database System Modeling Data in the Organization October 31, 2009 Software Park, Bangkok Thailand.
Chapter 2: Modeling Data in the Organization
Chapter 3 1 Chapter 3: Modeling Data in the Organization.
IS 4420 Database Fundamentals Chapter 3: Modeling Data in the Organization Leon Chen.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Lecture 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
Chapter 3: Modeling Data in the Organization
Modeling data in the Organization
Modelling Data in Organisation Entity-Relationship Model
TMC2034 Database Concept and Design
Chapter 2: Modeling Data in the Organization (THE BASIC ER-MODEL)
Overview of Entity‐Relationship Model
Database Concepts Database Analysis
Review of Week 1 Database DBMS File systems vs. database systems
Chapter 3: Modeling Data in the Organization
Presentation transcript:

CHAPTER 2: MODELING DATA IN THE ORGANIZATION (THE BASIC ER-MODEL) © 2013 Pearson Education 1 Modern Database Management 11 th Edition, International Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi

Chapter 2 © 2013 Pearson Education Chapter Outline  The E-R Model (E-R Diagram): An introduction  Modeling Business ( 事務、業務 ) Rules of Organizations  Modeling Entities and Attributes  Modeling Relationships  E-R Modeling Example 2

Chapter 2 © 2013 Pearson Education Objectives  Understand the definitions of terms  Understand the importance of data modeling  Select 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 3

Chapter 2 © 2013 Pearson Education How to Select Good Data Name  Related to business, not technical, characteristics  Meaningful and self-documenting  Unique  Readable  Composed of words from an approved list  Following a standard syntax 4

Chapter 2 © 2013 Pearson Education DATA NAMES and DEFINITIONS  Data objects must be named and defined  Fundamental to understanding and modeling data  A definition is an explanation of a term or fact  Term : a word or phrase with specific meaning  Fact : an association between two or more terms (A fact is used to relate terms)  Guidelines for good data definition  A concise description of the essential data meaning  Gathered in conjunction with systems requirements  Accompanied by diagrams  Achieved with a team agreement, and iteratively refined 5

Chapter 2 © 2013 Pearson Education CONSTRUCTS ( 組成 ) of E-R MODEL  Entities ( 實體 ):  Entity instance ( 個例 ) : a person, place, object, event, or concept (often corresponds to a data row or a record in a table)  Entity type ( 種類、型別 ) : a collection of entities (often corresponds to a table) (often corresponds to a table)  Relationships ( 關係 ):  Relationship instance : a link between entities (corresponds to a certain primary key-foreign key pair in related tables)  Relationship type : a category of relationship (a link between entity types)  Attributes:  Properties or characteristics of an entity or relationship type (often corresponds to a field or a column in a table) 6 StdSSNStdLastNameStdMajorStdClass WELLSISFR NORBERTFINJR KENDALLACCTJR Student Table E-R diagram example

7 Sample E-R Diagram (Figure 2-1) 7 Chapter 2 © 2013 Pearson Education Each ITEM must be supplied by at least one SUPPLIERs. A SUPPLIER may supply many ITEMs.

8 Relationship degrees ( 度數 ) specify the number of entity types involved Entity symbols A special entity that is also a relationship Relationship symbols Relationship cardinalities ( 基數 ) specify how many entity instances of each entity type is involved Attribute symbols Basic E-R notation (Figure 2-2) 8 Chapter 2 © 2013 Pearson Education

Chapter 2 © 2013 Pearson Education Business Rules ( 業務規則、事務規則 )  Core concepts of an organization  Statements that define or constrain some aspect of the business ( 企業、業務、事務 )  Derived from organizational policies, procedures, events, functions  Assert business structure  Control/influence business behavior  Expressed in terms familiar to end users  Can be automated through DBMS software  Example : Each ITEM must be supplied by at least one SUPPLIERs. Each ITEM must be supplied by at least one SUPPLIERs. 9 examples

Chapter 2 © 2013 Pearson Education A Good Business Rule Is:  Declarative ( 敘述性的 ) : what, not how  Precise : clear, agreed-upon meaning  Atomic : One statement, not several, for each rule. One statement, not several, for each rule.  Consistent : internally and externally  Expressible : structured, natural language  Distinct ( 有區別的 ) : non-redundant  Business-oriented : Understood by business people Understood by business people 10

Chapter 2 © 2013 Pearson Education Entities  Entity type A collection of entities that share common properties or characteristics  Entity instance  A single occurrence of an entity type  A person, a place, an object, an event, or a concept in the user environment about which the organization wishes to maintain data 11

Chapter 2 © 2013 Pearson Education Entity Type and Entity Instances 12 Instance 1 Instance 2

Chapter 2 © 2013 Pearson Education An Entity (Instances) …  SHOULD BE:  An object that we are trying to model  An object that will have many similar instances in the database  An object that will be composed of multiple attributes  SHOULD NOT BE:  A single user of the database system  An output of the database system (e.g., a report) 13

Chapter 2 © 2013 Pearson Education 14 Inappropriate entities The company has only one treasurer Output of the system Figure 2-4 Example of inappropriate entities Appropriate entities

Chapter 2 © 2013 Pearson Education Strong vs. Weak Entities, and Identifying Relationships  Strong entity  exists independently of other types of entities  has its own unique identifier ( 獨特的識別屬性 )  identifier is underlined with a single line  Weak entity  cannot exist on its own  dependent on a strong entity (identifying owner)…  does not have a unique identifier (only a partial identifier)  entity box and partial identifier have double lines  Identifying relationship  Links a strong entity to a weak entity 15 example

Chapter 2 © 2013 Pearson Education 16 Strong entity Weak entity Figure 2-5 Example of a weak identity and its identifying relationship

Chapter 2 © 2013 Pearson Education Attributes Attributes ( 屬性 )  Attribute–a property or characteristic of an entity type or a relationship type  Classifications of attributes:  Required versus Optional Attributes  Simple versus Composite Attribute  Single-valued versus Multi-valued Attribute  Stored versus Derived ( 推算的 ) Attributes  Identifier Attributes 17

Chapter 2 © 2013 Pearson Education Required vs. Optional Attributes 18 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

Chapter 2 © 2013 Pearson Education Simple vs. Composite Attributes  Composite attribute An attribute that has several meaningful component parts (attributes) 19 The address is broken into component parts Figure 2-7 A composite attribute

Chapter 2 © 2013 Pearson Education Figure 2-8 Entity with multi-valued attribute (Skill) and derived attribute (Years Employed) Multi-valued an employee can have more than one skill Derived Calculated from Date Employed and current date Multi-valued and Derived Attributes Multivalued attribute may have more than one value for a given entity (or relationship) instance Derived attribute values can be calculated from related attribute values (not physically stored in the database) 20 Chapter 2 © 2013 Pearson Education

Chapter 2 © 2013 Pearson Education Identifier Attribute (Key, 識別屬性 )  Identifier (Key 鍵、索引 )  an attribute (or a combination of attributes) that uniquely identifies all the individual instances of an entity type  No two instances of the entity type may have the same value for the identifier  Simple versus Composite Identifier  Candidate Identifier  an attribute that could be a key  satisfies the requirements for being an identifier 21

Chapter 2 © 2013 Pearson Education Criteria for Identifiers  Choose Identifiers that  Will not change in value  Will not be null  Less likely to lose uniqueness in the future  Avoid intelligent identifiers, whose structure indicates classifications, locations, and so on. (e.g., the first two digits of an identifier value may indicate the warehouse. Such codes are often changes.)  Substitute simple, single-attribute key for long, composite key 22 conflicts

23 Figure 2-9 Simple and composite identifier attributes The identifier is boldfaced and underlined 23 Chapter 2 © 2013 Pearson Education

Chapter 2 © 2013 Pearson Education Naming Attributes in ER-Diagram  Attribute name should be a singular noun ( 單數名詞 ) or noun phrase ( 名詞片語 ) (e.g., Customer ID)  Attribute name should be unique  No two attributes of the same entity type have a same name.  It is desirable that no two attributes across all entity types have a same name.  Name may follow a standard format to make an attribute name unique  e.g. [Entity type name { [ Qualifier] } ] attribute class  e.g. [Entity type name { [ Qualifier ( 修飾語 ) ] } ] attribute class Employee Birth Date  Similar attributes of different entity types should use the same qualifiers and attribute classes 24

Chapter 2 © 2013 Pearson Education Guidelines () for Defining Attributes Guidelines ( 指引 ) for 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 (i.e., domain)  Include aliases in documentation  State source of values ( 例 )  State source of values ( 例ICD-9-CM國際疾病分類編碼 )  Specify required vs. optional  State min and max number of occurrences allowed for a multi-valued attribute  Indicate relationships with other attributes 25

Chapter 2 © 2013 Pearson Education DOMAIN AND MEANING OF ATTRIBUTES (An Example : Staff and Branch Entity Types)

Chapter 2 © 2013 Pearson Education Modeling Relationships in ERD  Relationship Types vs. Relationship Instances  A relationship type is modeled as a line(s) between entity types  A relationship instance is a link between specific entity instances  Relationships can have attributes These attributes describe features pertaining to the relationship (an association between the related entities)  Two entities can have more than one type of relationship (multiple relationships) between them  Associative Entity  Associative Entity ( 關聯組合的實體 ) The presence of one or more attributes on a relationship suggests that the relationship should perhaps be represented as an entity type 27 example

28 Figure 2-10 Relationship types and instances a) Relationship type : Completes b) Relationship instances 28 Chapter 2 © 2013 Pearson Education

Chapter 2 © 2013 Pearson Education Degree () of Relationships Degree ( 度數 ) of Relationships  Degree of a relationship The number of entity types that participate in the relationship  Unary Relationship  Binary Relationship  Ternary Relationship 29

30 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 entity of the same entity type 30 Chapter 2 © 2013 Pearson Education example

31 Figure 2-12 Examples of relationships of different degrees a) Unary relationships 31 Chapter 2 © 2013 Pearson Education

32 Figure 2-12 Examples of relationships of different degrees (cont.) b) Binary relationships 32 Chapter 2 © 2013 Pearson Education

33 Figure 2-12 Examples of relationships of different degrees (cont.) c) Ternary relationship Note: a relationship can have attributes of its own 33 Chapter 2 © 2013 Pearson Education

Chapter 2 © 2013 Pearson Education Cardinality ( 基數 ) of Relationships  One-to-One  Each entity in the relationship will have exactly one related entity  One-to-Many  An entity on one side of the relationship can have many related entities, but an entity on the other side will have a maximum of one related entity  Many-to-Many  Entities on both sides of the relationship can have many related entities on the other side 34 example

Chapter 2 © 2013 Pearson Education Cardinality Constraints  Cardinality Constraints The number of instances of one entity that can or must be associated with each instance of another related entity  Minimum Cardinality  If zero, then optional  If one or more, then mandatory  Maximum Cardinality  The maximum number 35

36 Figure 2-17 Examples of cardinality constraints a) Mandatory cardinalities A patient must have recorded at least one visit history, and can have many A patient visit history is recorded for one and only one patient 36 Chapter 2 © 2013 Pearson Education 4X4 combinations of binary relationship types minimum cardinality maximum cardinality relationship instances

37 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 A project must be assigned to at least one employee, and may be assigned to many 37 Chapter 2 © 2013 Pearson Education relationship instances

38 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 38 Chapter 2 © 2013 Pearson Education relationship instances

39 Figure 2-21 Modeling multiple relationships between entity types a)The example between Employees and Departments  Entities can be related to one another in more than one way  Entity EMPLOYEE has 1 unary and 2 binary relationships 39 Chapter 2 © 2013 Pearson Education

40 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. 40 Chapter 2 © 2013 Pearson Education

41 Figure 2-15a and 2-15b Multivalued attributes can be represented as relationships 41 Chapter 2 © 2013 Pearson Education Simple, multivalued attributes Composite, multivalued attributes is represented as relationships

Chapter 2 © 2013 Pearson Education Associative Entities () Associative Entities ( 關聯組合的實體 )  In ER Diagram,  An entity has attributes  A relationship links entities together  The presence of one or more attributes on a relationship suggests that the relationship should perhaps be represented as an associative entity.  When should a relationship with attributes be represented as an associative entity?  The relationship is a many-to-many relationship.  The associative entity may participate in other relationships other than the relationship that it represents  Ternary relationships should be converted to associative entities 42 Example 1 example Example 2

43 Figure 2-11a A M:M 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. 43 Chapter 2 © 2013 Pearson Education Corresponding associative entity

44 Figure 2-11b An associative entity (CERTIFICATE) Associative entity is like a relationship with attributes, 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 2 one-to-many relationships with the associative entity. 44 Chapter 2 © 2013 Pearson Education

45 Figure 2-13b Two ITEM bill-of-materials structure instances 45 Chapter 2 © 2013 Pearson Education ( 轉鏈輪裝置 ) ( 車輪罩 ) Corresponding ERD

46 Figure 2-13c An associative entity – bill of materials structure This could also be represented as a relationship with attributes…(it’s a judgment call). 46 Chapter 2 © 2013 Pearson Education

47 Figure 2-18 Cardinality constraints in a ternary relationship 47 Chapter 2 © 2013 Pearson Education

48 Figure 2-19 Simple example of time-stamping The Price History attribute is both multi-valued 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 48 Chapter 2 © 2013 Pearson Education Composite, multivalued attributes

49 Figure 2-20c E-R diagram with associative entity for product assignment to product line over time 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 Act ( 公司和證券監管法規 ). 49 Chapter 2 © 2013 Pearson Education notation

50 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. 50 Chapter 2 © 2013 Pearson Education core entities

下一週第一堂上課時交 作業 #1 第二章 135~142 頁 Problems and Exercises 學號單號 : 1 : a, c, e, g, k 2 i & 2 ii : a, b, c 10 ( 徒手畫或用 Word 畫 ) 學號雙號 : 1 : b, d, f, h, k 2 i & 2 ii : e, f, g 10 ( 徒手畫或用 Word 畫 ) 作業

52 Copyright © 2013 Pearson Education Summary