Скачать презентацию Chapter 3 Modeling Data in the Organization Chapter Скачать презентацию Chapter 3 Modeling Data in the Organization Chapter

d2d296b5d141a7ba4856eebcf4c1db48.ppt

  • Количество слайдов: 55

Chapter 3: Modeling Data in the Organization Chapter 3 Chapter 3: Modeling Data in the Organization Chapter 3

Business Rules a. Statements that define or constrain some aspect of the business b. Business Rules a. Statements that define or constrain some aspect of the business b. Assert business structure c. Control/influence business behavior d. Expressed in terms familiar to end users e. Automated through DBMS software Chapter 3

Scope of Business Rules a. We see business rules in Information system context. What Scope of Business Rules a. We see business rules in Information system context. What all fall inside and what all is outside the scope. Chapter 3

A Good Business Rule is: Chapter 3 A Good Business Rule is: Chapter 3

Gathering Business Rules a. Gathered from descriptions of business functions, events, policies, units, stakeholders. Gathering Business Rules a. Gathered from descriptions of business functions, events, policies, units, stakeholders. b. Can be elicited by interviews, group information system requirements collection sessions, organizational documents (personnel manuals, policies, contracts, marketting broucheres, technical istructions. ) c. Questions like who, what, where, why, and how are asked. d. To validate questions like, “is this always true? , “Are there special circumstances where alternatives exists? ” etc Chapter 3

Data Names Chapter 3 Data Names Chapter 3

A Good Data Name is: Chapter 3 A Good Data Name is: Chapter 3

Data Definitions a. Explanation of a term or fact a. Term–word or phrase with Data Definitions a. Explanation of a term or fact a. Term–word or phrase with specific meaning b. Fact–association between two or more terms b. Guidelines for good data definition a. Gathered in conjunction with systems b. Accompanied by diagrams c. Iteratively created and refined d. Achieved by consensus Chapter 3 requirements

E-R Model Constructs a. Entities: Entity instance–person, place, object, event, concept (often corresponds to E-R Model Constructs a. Entities: Entity instance–person, place, object, event, concept (often corresponds to a row in a table) b. Entity Type–collection of entities (often corresponds to a table) a. b. Relationships: Relationship instance–link between entities (corresponds to primary key-foreign key equivalencies in related tables) b. Relationship type–category of relationship…link between entity types a. • Attribute–property or characteristic of an entity or relationship type (often corresponds to a field in a table) Chapter 3

Sample E-R Diagram (Figure 31) Chapter 3 Sample E-R Diagram (Figure 31) Chapter 3

Basic E-R notation (Figure 3 -2) Entity symbols A special entity that is also Basic E-R notation (Figure 3 -2) Entity symbols A special entity that is also a relationship Relationship degrees specify number of entity types involved Chapter 3 Attribute symbols Relationship cardinalities specify how many of each entity type is allowed

What Should an Entity Be? a. SHOULD BE: a. An object that will have What Should an Entity Be? a. SHOULD BE: a. An object that will have many instances in the database b. An object that will be composed of multiple attributes c. An object that we are trying to model b. SHOULD NOT BE: a. A user of the database system b. An output of the database system report) Chapter 3 (e. g. , a

Figure 3 -4 Example of inappropriate entities System user Inappropriate entities System output Appropriate Figure 3 -4 Example of inappropriate entities System user Inappropriate entities System output Appropriate entities Chapter 3

Attributes a. Attribute–property or characteristic of an entity or relationahip type b. Classifications of Attributes a. Attribute–property or characteristic of an entity or relationahip type b. Classifications of attributes: a. Required versus Optional Attributes b. Simple versus Composite Attribute c. Single-Valued versus Multivalued Attribute d. Stored versus Derived Attributes e. Identifier Attributes Chapter 3

Identifiers (Keys) a. Identifier (Key)–An attribute (or combination of attributes) that uniquely identifies individual Identifiers (Keys) a. Identifier (Key)–An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type b. Simple versus Composite Identifier c. Candidate Identifier–an attribute that could be a key…satisfies the requirements for being an identifier Chapter 3

Characteristics of Identifiers a. Will not change in value b. Will not be null Characteristics of Identifiers a. Will not change in value b. Will not be null c. No intelligent identifiers (e. g. , containing locations or people that might change) d. Substitute new, simple keys for long, composite keys Chapter 3

Figure 3 -7 A composite attribute An attribute broken into component parts Figure 3 Figure 3 -7 A composite attribute An attribute broken into component parts Figure 3 -8 Entity with multivalued attribute (Skill) and derived attribute (Years_Employed) Multivalued an employee can have more than one skill Chapter 3 Derived from date employed and current date

Figure 3 -9 Simple and composite identifier attributes The identifier is boldfaced and underlined Figure 3 -9 Simple and composite identifier attributes The identifier is boldfaced and underlined Chapter 3

Figure 3 -19 Simple example of timestamping This attribute that is both multivalued and Figure 3 -19 Simple example of timestamping This attribute that is both multivalued and composite Chapter 3

More on Relationships a. Relationship Types vs. Relationship Instances a. The relationship type is More on Relationships a. Relationship Types vs. Relationship Instances a. The relationship type is modeled as lines between entity types…the instance is between specific entity instances b. Relationships can have attributes a. These describe features pertaining to the association between the entities in the relationship c. Two entities can have more than one type of relationship between them (multiple relationships) d. Associative Entity–combination of relationship and entity Chapter 3

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

Degree of Relationships a. Degree of a relationship is the number of entity types Degree of Relationships a. Degree of a relationship is the number of entity types that participate in it a. Unary Relationship b. Binary Relationship c. Ternary Relationship Chapter 3

Degree of relationships – from Figure 3 -2 One entity related to another of Degree of relationships – from Figure 3 -2 One entity related to another of the same entity type Chapter 3 Entities of two different types related to each other Entities of three different types related to each other

Cardinality of Relationships a. One-to-One a. Each entity in the relationship will have exactly Cardinality of Relationships a. One-to-One a. Each entity in the relationship will have exactly one related entity b. One-to-Many a. 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 c. Many-to-Many a. Entities on both sides of the relationship can have many related entities on the other side Chapter 3

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

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

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

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

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

Figure 3 -17 Examples of cardinality constraints (cont. ) b) One optional, one mandatory Figure 3 -17 Examples of cardinality constraints (cont. ) b) One optional, one mandatory A project must be assigned to at least one employee, and may be assigned to many Chapter 3 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. ) a) Optional cardinalities A person Figure 3 -17 Examples of cardinality constraints (cont. ) a) Optional cardinalities A person is is married to at most one other person, or may not be married at all Chapter 3

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

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

Figure 3 -15 a and 3 -15 b Multivalued attributes can be represented as Figure 3 -15 a and 3 -15 b Multivalued attributes can be represented as relationships simple composite Chapter 3

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

SUMMARY OF ER-DIAGRAM NOTATION FOR ER SCHEMAS Symbol Chapter 3 Meaning ENTITY TYPE WEAK SUMMARY OF ER-DIAGRAM NOTATION FOR ER SCHEMAS Symbol Chapter 3 Meaning ENTITY TYPE WEAK ENTITY TYPE RELATIONSHIP TYPE IDENTIFYING RELATIONSHIP TYPE ATTRIBUTE KEY ATTRIBUTE MULTIVALUED ATTRIBUTE COMPOSITE ATTRIBUTE DERIVED ATTRIBUTE

Identifying relationship Strong entity Chapter 3 Weak entity Identifying relationship Strong entity Chapter 3 Weak entity

Associative Entities a. An entity–has attributes relationship b. A –links entities together c. When Associative Entities a. An entity–has attributes relationship b. A –links entities together c. 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 c. The associative entity preferably has a unique identifier, and should also have other attributes d. The associative entity may participate in other relationships other than the entities of the associated relationship e. Ternary relationships should be converted to associative entities a. b. Chapter 3

Figure 3 -11 a A binary relationship with an attribute Here, the date completed Figure 3 -11 a 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 Chapter 3

Figure 3 -11 b An associative entity (CERTIFICATE) Associative entity is like a relationship Figure 3 -11 b 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 -11 a has been replaced by two one-to-many relationships with the associative entity. Chapter 3

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

Figure 3 -18 Ternary relationship as an associative entity Chapter 3 Figure 3 -18 Ternary relationship as an associative entity Chapter 3

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

Creating an ERD from the Investigated Facts a. Identify all the entities. b. Identify Creating an ERD from the Investigated Facts a. Identify all the entities. b. Identify all the relationships. c. Identify cardinality and multiplicities (min max). Chapter 3

Simple ERD 1 a. A painter can paint many paintings; each painting is painted Simple ERD 1 a. A painter can paint many paintings; each painting is painted by one painter. A gallery can have many paintings. A painting can be exhibited by a gallery. Painter Chapter 3 (1, 1) (0, N) Painting (0, N) Displayed (1, 1) Gallery

Simple ERD 2 a. An employee can learn many skills; each skill can be Simple ERD 2 a. An employee can learn many skills; each skill can be learnt by many employees. b. Expert Level? (L 1. . L 5) Employee Chapter 3 (0, N) Learn Level (0, M) Skills

Simple ERD 3 a. An employee manages one store; each store is managed by Simple ERD 3 a. An employee manages one store; each store is managed by one employee Employee Chapter 3 (1, 1) Manages (0, 1) Store

Simple ERD 4 a. A College example b. Students in a typical college or Simple ERD 4 a. A College example b. Students in a typical college or university will discover that each course can have many sections, each section refers to only one course. c. For example, an Accounting II course might have two sections: one offered on Monday, Wednesday, and Friday from 10: 00 a. m. to 10: 50 a. m. , and one offered on Thursday from 6: 00 p. m. to 8: 40 p. m. Chapter 3

(0, N) (1, 1) Course Chapter 3 Has Section (0, N) (1, 1) Course Chapter 3 Has Section

Simple ERD 5 a. Each student can take many classes (or none) and each Simple ERD 5 a. Each student can take many classes (or none) and each class can contain many students. Student Chapter 3 (1, M) Take (0, N) Classes

Combining ERDs a. A class can be identified with course and section. Course Student Combining ERDs a. A class can be identified with course and section. Course Student Chapter 3 (1, 1) (1, M) Has Take (0, N) Section

Course (1, 1) Has (0, N) Section (0, N) Student Chapter 3 (1, M) Course (1, 1) Has (0, N) Section (0, N) Student Chapter 3 (1, M) Take

Adding Additional Conditions a. Adding prerequisite, enroll grade (1, 1) Course (0, M) Has Adding Additional Conditions a. Adding prerequisite, enroll grade (1, 1) Course (0, M) Has Section (0, N) Prerequisite Student Chapter 3 (0, N) (1, M) Take Grade

Example a. a professor teaches zero, one or many classes and a class is Example a. a professor teaches zero, one or many classes and a class is taught by one professor • a course may generate zero, one or many classes and a class comes from one course • a class is held in one room but a room has many classes Chapter 3

Example a. an invoice is written by one salesrep but a salesrep writes many Example a. an invoice is written by one salesrep but a salesrep writes many invoices b. a vendor sells many products but a product is bought from one vendor c. an invoice has one or many products and a product is found on zero, one or many invoices Chapter 3