Chapter 4 Entity Relationship (E-R) Modeling

Slides:



Advertisements
Similar presentations
Entity Relationship (ER) Modeling
Advertisements

Chapter # 4 BIS Database Systems
Entity Relationship (E-R) Modeling
Entity Relationship (E-R) Modeling Hachim Haddouti
Entity Relationship (ER) Modeling
Chapter 4 Entity Relationship (E-R) Modeling
4 4 Chapter 4 Entity Relationship (E-R) Modeling Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Entity Relationship (ER) Modeling
Chapter 4 Entity Relationship (ER) Modeling
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Chapter 4 Entity Relationship (E-R) Modeling
Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Entity Relationship (E-R) Modeling
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 4 Entity Relationship (E-R) Modeling
Chapter Five Data Modeling with the Entity-Relationship Model.
BTM 382 Database Management Chapter 4: Entity Relationship (ER) Modeling Chitu Okoli Associate Professor in Business Technology Management John Molson.
Data Modeling 1 Yong Choi School of Business CSUB.
Yong Choi School of Business CSUB
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Chapter 4 Entity Relationship (E-R) Modeling
3 Chapter 3 Entity Relationship (E-R) Modeling Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R.
Chapter 7 Data Modeling with Entity Relationship Diagrams Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z.Yang Course Website: 3220m.htm
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 5 Entity Relationship (ER) Modelling
Chapter 5 Entity–Relationship Modeling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 4 Entity Relationship (ER) Modeling.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Chapter 4 Entity Relationship (ER) Modeling.  ER model forms the basis of an ER diagram  ERD represents conceptual database as viewed by end user 
4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Relationship Degree Indicates number of entities or participants.
Database Design – Lecture 5 Conceptual Data Modeling – adding attributes.
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Chapter 7 Data Modeling with Entity Relationship Diagrams
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 4 ENTITY RELATIONSHIP (ER) MODELING Instructor Ms. Arwa Binsaleh 1.
Entity Relationship Modeling
Database Design – Lecture 4 Conceptual Data Modeling.
Data Modeling Yong Choi School of Business CSUB. Part # 2 2 Study Objectives Understand concepts of data modeling and its purpose Learn how relationships.
Entity Relationship Model: E-R Modeling 1 Database Design.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
Department of Mathematics Computer and Information Science1 CS 351: Database Management Systems Christopher I. G. Lanclos Chapter 4.
Entity Relationship Modeling
Entity Relationship (E-R) Model
TMC2034 Database Concept and Design
Entity Relationship (E-R) Modeling
Entity Relationship (E-R) Modeling
Tables and Their Characteristics
Database Design – Lecture 4
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Review of Week 1 Database DBMS File systems vs. database systems
Chapter 4 Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Chapter # 4 Entity Relationship (ER) Modeling.
Presentation transcript:

Chapter 4 Entity Relationship (E-R) Modeling Database Systems: Design, Implementation, and Management Peter Rob & Carlos Coronel

In this chapter, you will learn: How relationships between entities are defined and refined, and how such relationships are incorporated into the database design process How ERD components affect database design and implementation How to interpret the modeling symbols for the four most popular ER modeling tools That real-world database design often requires that you reconcile conflicting goals

The Entity Relationship (E-R) Model ER model forms the basis of an ER diagram ERD represents the conceptual database as viewed by end user Main Components Entities In E-R models an entity refers to the entity set. An entity is represented by a rectangle containing the entity’s name. Attributes Attributes are represented by ovals and are connected to the entity with a line. Each oval contains the name of the attribute it represents. Attributes have a domain -- the attribute’s set of possible values. Attributes may share a domain. Relationships

Entities Refers to entity set and not to single entity occurrence Corresponds to table and not to row in relational environment In both Chen and Crow’s Foot models, entity is represented by rectangle containing entity’s name Entity name, a noun, is usually written in capital letters

Attributes Characteristics of entities In Chen model, attributes are represented by ovals and are connected to entity rectangle with a line Each oval contains the name of attribute it represents In Crow’s Foot model, attributes are written in attribute box below entity rectangle

The Attributes of the STUDENT Entity

Domains Attributes have domain Attributes may share a domain Domain is attribute’s set of possible values Attributes may share a domain

Primary Keys Underlined in the ER diagram Key attributes are also underlined in frequently used table structure shorthand Ideally composed of only a single attribute Possible to use a composite key : Primary key composed of more than one attribute

Composite Primary Keys (continued) Primary Keys (CLASS_CODE) Another possible Composite Primary Key (CRS_CODE + CLASS_SECTION)

Classes of Attributes A simple attribute cannot be subdivided. Examples: Age, Sex, and Marital status A composite attribute can be further subdivided to yield additional attributes. Examples: ADDRESS Street, City, State, Zip PHONE NUMBER  Area code, Exchange number

Classes of Attributes Multivalued attributes can have many values. A single-valued attribute can have only a single value. Examples: A person can have only one social security number. A manufactured part can have only one serial number. Multivalued attributes can have many values. A person may have several college degrees. A household may have several phones with different numbers Multivalued attributes are shown by a double line connecting to the entity.

Multivalued attributes in an Entity

Resolving Multivalued Attribute Problems Although conceptual model can handle M:N relationships and multivalued attributes, you should not implement them in relational DBMS. Possible courses of action for the designer Within the original entity, create several new attributes, one for each of the original multivalued attribute’s components ( Figure 4.4). Create a new entity composed of the original multivalued attribute’s components ( Figure 4.5).

Splitting the Multivalued Attribute into New Attributes

A New Entity Set Composed of Multivalued Attribute’s Components

A New Entity Set Composed of Multivalued Attribute’s Components

Derived Attributes A derived attribute may be calculated (derived) from other attributes Need not be physically stored within the database Can be derived by using an algorithm Example: AGE can be derived from the data of birth and the current date.

Depiction of a Derived Attribute

Derived Attributes (continued)

The Entity Relationship (E-R) Model Relationships A relationship is an association between entities. Relationships are represented by diamond-shaped symbols.

Relationships Association between entities Participants are entities that participate in a relationship Relationships between entities always operate in both directions Relationship can be classified as 1:M Relationship classification is difficult to establish if know only one side of the relationship

Connectivity The term connectivity is used to describe the relationship classification (e.g., one-to-one, one-to-many, and many-to-many).

Cardinality Cardinality expresses the specific number of entity occurrences associated with one occurrence of the related entity. The minimum and maximum number of entity occurrences (0,3) for PROFESSOR : a professor may teach 0-3 classes. (0,35) for CLASS : a class may enroll up to 35 students, but it is possible for a class to have no currently enrolled students initially.

Connectivity and Cardinality in an ERD

Connectivity and Cardinality

Existence Dependence Existence Dependent Existence independent Entity exist in database only when it is associated with another related entity occurrence If an entity’s existence depends on the existence of one or more other entities, it is said to be existence-dependent. CLASS is existence-dependent on COURSE (parent entity) EMPLOYEE claims DEPENDENT— DEPENDENT is existence-dependent on EMPLOYEE Existence independent Entity can exist apart from one or more related entities Example: some of parts are produced “in-house” and other parts are bought from vendors. At least some of the parts are not supplied by a vender. PART is existence-independent from VENDOR

Relationship Strength 針對Existence Dependence再進一步分析: Weak (non-identifying) relationship exist if the PK of the related entity doesn’t contain a PK component of the parent entity COURSE( CRS_CODE, …) CLASS( CLASS_CODE, …) Strong (identifying) relationship PK of the related entity contains a PK component of the parent entity CLASS( CRS_CODE, CLASS_SECTION, …) 一樣都是existence-dependent 但要分辨出 existence-dependent 的強弱程度

A Weak Relationship Between COURSE and CLASS PK : PK :

A Strong (Identifying) Relationship Between COURSE and CLASS PK : PK :

Relationship Strength and Weak Entities A weak entity is an entity that Is existence-dependent and Has a primary key that is partially or totally derived from the parent entity in the relationship. The existence of a weak entity is indicated by a double rectangle. The weak entity inherits all or part of its primary key from its strong counterpart.

A Weak Entity in an ERD EMPLOYEE( EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_DOB ) DEPENDENT( EMP_NUM, DEP_NUM, DEP_FNAME, DEP_DOB ) Primary Key DEP_NUM

Weak entity in a Strong Relationship Between DEPENDENT and EMPLOYEE ( EMP_NUM ) ( EMP_NUM + DEP_NUM )

Weak Entities (continued)

Weak entity in a Strong Relationship Weak relationship PK of related entity doesn’t contain PK component of parent entity COURSE( CRS_CODE, …) CLASS( CLASS_CODE, …) Strong relationship PK of related entity contains PK component of parent entity CLASS( CRS_CODE, CLASS_SECTION, …) In any case, CLASS is always existence-dependent on COURSE, whether or not it is defined to be weak. Not Weak entity

Weak Entities (continued)

Relationship Participation Optional participation One entity occurrence does not require a corresponding entity occurrence in a particular relationship. An optional entity is shown by a small circle on the side of the optional entity. Mandatory participation One entity occurrence requires corresponding occurrence in related entity If no optionality symbol is shown on ERD, it is mandatory

Relationship Participation (continued) CLASS is Optional to PROFESSOR PROFESSOR is Mandatory to CLASS

CLASS is Optional to COURSE COURSE is Mandatory to CLASS COURSE and CLASS in a Mandatory Relationship

Relationship Participation (continued) CLASS is Optional to COURSE COURSE is Mandatory to CLASS

Relationship Participation (continued) COURSE and CLASS in a Mandatory Relationship

Relationship Participation (continued)

Relationship Degree A relationship’s degree indicates the number of associated entities or participants. A unary relationship exists when an association is maintained within a single entity. A binary relationship exists when two entities are associated. A ternary relationship exists when three entities are associated. DOCTOR DRUG PATIENT PRESCRIPTION

Relationship Degree (continued)

Relationship Degree (continued) ( DRUG_CODE ) ( PAT_NUM ) ( DOC_ID )

Relationship Degree A ternary relationship exists when three entities are associated.

The Implementation of a Ternary Relationship 若 FUND(FUND_ID,FUND_NAME) ,透過 CFR 仍能將所有必要的關係聯繫起來, 但 FUND(FUND_ID,FUND_NAME,CONTRIB_ID,FUND_AMOUNT) 亦有意義, 例如:F2 接受 C3 $10,000 的捐款,還未撥給任何 RECIPIENT 若FUND(FUND_ID,FUND_NAME)亦可,透過CFR仍能將所有必要的關係聯繫起來, 但FUND(FUND_ID,FUND_NAME,CONTRIB_ID,FUND_AMOUNT)亦有意義, 如FIGURE 4.18中:F2接受C3 $10,000的捐款,還未撥給任何RECIPIENT Researchers

Recursive relationship A recursive relationship is one in which a relationship can exist between occurrences of the same entity set. A recursive entity is found within a unary relationship.

Recursive Relationships

1:1 Recursive relationship EMPLOYEE is married to EMPLOYEE

Recursive Relationships

1:M Recursive relationship PART contains PART each part is used to create only one rotor assembly C130 = 4× AA21-6 + 2× AB-121 + …

Recursive Relationships (continued)

M:N Recursive relationship PART Contains PART A part_ can be used to create several different kinds of other parts A part_ is itself composed of many parts. PART PART contains PART contains PART PART COMPONENT

Recursive Relationships

M:N Recursive relationship COURSE Requires COURSE

Recursive Relationships

Implementation of the 1:M “EMPLOYEE Manages EMPLOYEE” Recursive Relationship

Recursive Relationships (continued)

The Entity Relationship (E-R) Model Composite Entities A composite entity is composed of the primary keys of each of the entities to be connected. The composite entity serves as a bridge between the related entities. The composite entity may contain additional attributes.

The Entity Relationship (E-R) Model Composite Entities

Converting the M:N Relationship Into Two 1:M Relationships

Composite Entities

At the start of registration A class may exist even though it contains no students at all A student has not yet signed up for any classes.

Composite Entities

A Composite Entity in the ERD

Developing an E-R Diagram The process of database design is an iterative rather than a linear or sequential process. Iterative process - based on repetition of processes and procedures. The process is repeated until the end users and designers agree that the E-R diagram is a fair representation of the organization’s activities and functions. Narrative- 敘述,講述

Developing an ER Diagram Building an ERD usually involves the following activities: Create detailed narrative of organization’s description of operations Identify business rules based on description of operations Identify main entities and relationships from business rules Develop initial ERD Identify attributes and primary keys that adequately describe entities Revise and review ERD

Developing an E-R Diagram Tiny College Database Tiny College (TC) is divided into several schools. Each school is administered by a dean. A 1:1 relationship exists between DEAN and SCHOOL. Each dean is a member of a group of administrators (ADMINISTRATOR). Deans also hold professorial rank and may teach a class ( PROFESSOR). Administrators and professors are also Employees.

Developing an E-R Diagram Tiny College Database (1) Each school is composed of several departments. The smallest number of departments operated by a school is one, and the largest number of departments is indeterminate (N). Each department belongs to only a single school.

Developing an ER Diagram

Developing an E-R Diagram Tiny College Database (2) Each department offers several courses. courses is optional to department. (Some departments are research only.)

Developing an ER Diagram

Developing an E-R Diagram Tiny College Database (3) A department may offer several classes of the same course. A 1:M relationship exists between COURSE and CLASS. CLASS is optional to COURSE

Developing an ER Diagram

Developing an E-R Diagram Tiny College Database (4) Each department has many professors assigned to it. One of those professors chairs the department. Only one of the professors can chair the department. DEPARTMENT is optional to PROFESSOR in the “chairs” relationship.

Developing an ER Diagram

Developing an E-R Diagram Tiny College Database (5) Each professor may teach up to four classes, each one a section of a course. A professor may also be on a research contract and teach no classes.

Developing an ER Diagram

Developing an E-R Diagram Tiny College Database (6) A student may enroll in several classes, but (s)he takes each class only once during any given enrollment period. Each student may enroll in up to six classes and each class may have up to 35 students in it. STUDENT is optional to CLASS.

Developing an ER Diagram

Developing an E-R Diagram Tiny College Database (8) Each department has several students whose major is offered by that department. Each student has only a single major and associated with a single department. It is possible, at least for a while, for a student not to declare a major filed of study. DEPARTMENT is optional to STUDENT.

Developing an ER Diagram

Developing an E-R Diagram Tiny College Database (8) Each student has an advisor in his or her department; each advisor counsels several students. An advisor is also a professor, but not all professors advise students.

Developing an ER Diagram

Developing an ER Diagram

Developing an ER Diagram

Diagram from 5th edit. Not yet updated.

Developing an ER Diagram

The Challenge of Database Design: Conflicting Goals Database design must conform to design standards High processing speeds are often a top priority in database design Conflicting Goals Design standards (design elegance) Processing speed (high-transaction-speed) require design compromises Example: 1:1 recursive relationship Two tables (avoid nulls) a single table (high speed) Operational requirements 經營上的

MAR_DATE MAR_PLACE (1) MAR_DATE MAR_PLACE (2) (3)

The Challenge of Database Design: Conflicting Goals A recursive 1:1 relationship yields many different solutions. Your job as a database designer is to use your professional judgment to yield a solution that meets the requirements. Operational requirements 經營上的

Summary Entity relationship (ER) model Uses ER diagrams to represent conceptual database as viewed by the end user Three main components Entities Relationships Attributes Includes connectivity and cardinality notations Connectivities and cardinalities are based on business rules

Summary (continued) ER symbols are used to graphically depict the ER model’s components and relationships ERDs may be based on many different ER models Entities can also be classified as supertypes and subtypes within a generalization hierarchy Database designers are often forced to make design compromises

The Entity Relationship (E-R) Model Entity Supertypes and Subtypes Describing the different types of employees within a single entity would be awkward at best. Example : Aviation business ( Figure 4.27) the special pilot characteristics (EMP_LICENCE, EMP_RATING, EMP_MED_TYPE) would cause a large number of nulls for other employees who are not pilots.

Nulls Created by Unique Attributes

The Entity Relationship (E-R) Model Generalization hierarchy Depicts relationships between higher-level supertype and lower-level subtype entities. Supertype contains the shared attributes Subtype contains the unique attributes. A subtype entity inherits its attributes and its relationships from the supertype entity.

A Generalization Hierarchy Disjoint relationships are indicated by G

The Entity Relationship (E-R) Model Disjoint Supertypes Also known as non-overlapping subtypes Subtypes that contain a subset of the supertype entity set Each entity instance (row) of the supertype can appear in only one of the disjoint subtypes. The supertype and its subtype(s) maintain a 1:1 relationship.

The EMPLOYEE/PILOT Supertype/Subtype Relationship

A Generalization Hierarchy with Overlapping Subtypes Overlapping relationships are indicated by Gs

A Comparison of ER Modeling Symbols

SUMMARY

The Chen Representation of the Invoicing Problem

The Crow’s Foot Representation of the Invoicing Problem

The Rein85 Representation of the Invoicing Problem

The IDEF1X Representation of the Invoicing Problem

A Supertype/Subtype Relationship

Developing an E-R Diagram Tiny College Database (0) Most DBMS do not support supertype/subtype relationship directly. At the implementation level, designers convert it into a 1:1 relationship. A PROFESSOR is an EMPLOYEE. An EMPLOYEE is not required to be a PROFESSOR. PROFESSOR is optional to EMPLOYEE. PROFESSOR is existence-dependent on EMPLOYEE, and it inherits its PK from EMPLOYEE. Therefore the relationship between EMPLOYEE and PROFESSOR is strong, while is PROFESSOR a weak entity.

A Supertype/Subtype Relationship in an ERD