Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.

Slides:



Advertisements
Similar presentations
Advanced Data Modeling
Advertisements

Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Entity Relationship (ER) Modeling
IT420: Database Management and Organization
Text-Book Chapters (7 and 8) Entity-Relationship Model
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 6 Advanced Data Modeling.
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 6 Advanced Data Modelling
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 6 Advanced Data Modeling.
Chapter 5 Understanding Entity Relationship Diagrams.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Lecture Eleven Entity-Relationship Modelling
Chapter Five Data Modeling with the Entity-Relationship Model.
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 2: Entity-Relationship Model (Continued)
Entity-Relationship (E-R) Model
Ch 6: ER to Relational Mapping
Entity-Relationship modeling Transparencies
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the Entity-Relationship.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Entity Relationship Diagrams (ERDs)
1 Web-Enabled Decision Support Systems Entity-Relationship Modeling Prof. Name Position (123) University Name.
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.
Chapter 3: Modeling Data in the Organization
Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.
Chapter 5 Entity Relationship (ER) Modelling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Entity Relationship Modeling
DATABASEMODELSDATABASEMODELS  A database model ◦ defines the logical design of data. ◦ Describes the relationships between different parts of data.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 8 Data Modeling Advanced Concepts Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 2: Modeling Data in the Organization.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Unit 3 Conceptual Data Modeling. Key Concepts Conceptual data modeling process Classes and objects Attributes Identifiers, candidate keys, and primary.
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 
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
Initial Design of Entity Types for the COMPANY Database Schema Based on the requirements, we can identify four initial entity types in the COMPANY database:
Chapter 11 & 12 Entity-Relationship (E-R) Model Characteristics of E-R Model Components of E-R Model Example of E-R Model Enhanced E-R Model.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
IMS 4212: Introduction to Data Modeling—Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Relationships—Topics.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
1 Entity-Relationship Model © Pearson Education Limited 1995, 2005.
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
advanced data modeling
Data Modeling Using the Entity- Relationship (ER) Model.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Slide 4-1 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Revised by IB & SAM, Fasilkom UI, 2005 Exercise 1. a property or description.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
Entity-Relationship Modeling. 2 Entity Type u Entity type –Group of objects with same properties, identified by enterprise as having an independent existence.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
Ch 05. Basic Symbols ( manino ). Cardinalities Cardinality Notation.
Chapter 5 Understanding Entity Relationship Diagrams.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Lecture # 17 July 28,2012 Data Modeling using the Entity Relationship.
ENTITY-RELATIONSHIP MODELLING. Objectives: How to use Entity–Relationship (ER) modelling in database design. Basic concepts associated with ER model.
Entity Relationship (E-R) Model
Data Modeling Using the Entity- Relationship (ER) Model
Databases (CS507) CHAPTER 7.
Conceptual Design & ERD Modelling
Tables and Their Characteristics
Presentation transcript:

Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa

Topics Min. and Max. Cardinality Understanding Relationships  M-way relationships  Equivalence between M-N and 1-M relationships  Identification dependency Generalization Hierarchies Modeling Guidelines

Crow’s Foot Cardinality Notation

Classification of Cardinalities Maximum cardinality based  1-1 A maximum cardinality of 1 is a functional relationship  1-M a functional relationship in one direction  M-N

One-to-One (Functional) Relationship Relationship explanation: A department may have only one manager. A manager (employee) may manage only one department.

One-to-Many (Functional) Relationship Relationship explanation: A project may be associated with at most one department. A department may have multiple projects.

Many-to-Many Relationship

Classification of Cardinalities Minimum cardinality based  Mandatory: existence dependent  Optional

Existence Dependency Participation determines whether all or only some entity instances participate in a relationship.  Participation can either be optional or mandatory. If an entity's participation in a relationship is mandatory (also called total participation), then the entity's existence depends on the relationship.  Called an existence dependency.

One-to-Many Mandatory Participation (Existence Dependent) Relationship Relationship explanation: A project must be associated with one department. A department may have zero or more projects.

Many-to-Many Mandatory Participation (Existence Dependent) Relationship

Summary of Cardinalities

Understanding Relationships M-way relationships Equivalence between M-N and 1-M relationships Identification dependency

Cardinality of Non-Binary Relationships The cardinality in a complex relationship of an entity type is the number of possible occurrences of that entity-type in the n-ary relationship when the other (n-1) values are fixed. Example: A supplier may provide zero or more parts to a project. A project may have zero or more suppliers, and each supplier may provide to the project zero or more parts.

Challenges with Cardinality of Non-Binary Relationships The minimum cardinality for N-ary relationships (i.e., participation) is ambiguous. Example:  Constraint: A project has at least 1 supplier per part.  Initial idea: Cardinality 1..* beside Supplier should force there to be a Supplier for each Part/Project combination.  Problem: Two different interpretations of Part/Project combination results in unforeseen consequences: Actual tuple: All entities must always participate (as have actual tuples) so minimum values for all entities would be 1. Potential tuple: 1 beside Supplier implies always a Supplier for every Part/Project combination. Not true in practice. Bottom line: We will avoid problem of specifying participation constraints for N-ary relationships. One way to avoid it is convert a relationship into an entity with N binary relationships.

Associative Entity Types for M-way Relationships

Practice Question Consider the university database developed before. Write cardinalities into the ER diagram given that:  A department must offer at least 2 courses and no more than 20 courses. Courses are offered by only one department.  A course may have multiple sections, but always has at least one section.  A student may enroll for courses (but does not have to).  A professor may be in multiple departments (at least 1), and a department must have at least 3 professors.  A section is taught by at least one professor, but may be taught by more than one. A professor does not have to teach.  A student may only enroll in a course (and in a single section) once. (Not keeping track of history of student enrollments.)

Strong and Weak Entity Types A strong entity type is an entity type whose existence is not dependent on another entity type.  A strong entity type always has a primary key of its own attributes that uniquely identifies its instances.  A weak entity type is an entity type whose existence is dependent on another entity type; i.e., it is Identification Dependent  A weak entity type does not have a set of its own attributes that uniquely identifies its instances. A common example of strong and weak entity types are employees and their dependents:  An employee is a strong entity because it has an employee number to identify its instances.  A dependent (child) is a weak entity because the database does not store a key for each child, but rather they are identified by the parent's employee number and their name.

Identification Dependency in Crow’s Foot Notation Partial Key

Superclasses and Subclasses Java code: public class SavingsAccount extends BankAccount UML class diagram :

When to use Generalization Hierarchies? It is important to emphasize that most database projects do not need the object-oriented modeling features of Generalization Hierarchies. Remember the goal of conceptual modeling is to produce a model that is simple and easy to understand.  Do not introduce complicated subclass/superclass relationships if they are not needed.  Only use Generalization Hierarchies constructs if they offer a significant advantage over regular ER modeling. Generalization Hierarchies are especially useful when the domain being modeled is object-oriented in nature and the use of inheritance reduces the complexity of the design.  Most business databases have minimal object-oriented data.

When to use Generalization Hierarchies? Using Attribute Inheritance Note that the title attribute indicates what job the employee does at the company. Consider if each job title had its own unique information that we would want to record such as:  EE, PR - programming language used (lang), DB used (db)  SA, ME - MBA? (MBA), bonus

Using Attribute Inheritance We could represent all these attributes in a single relation: Note the wasted space as attributes that do not apply to a particular subclass are NULL.

Using Attribute Inheritance A better solution would be to make two subclasses of Employee called Developer and Manager:

Specialization Example

Using Attribute Inheritance: The Result

Generalization and Specialization Subclasses and superclasses are created by using either generalization or specialization. Specialization is the process of creating more specialized subclasses of an existing superclass.  Top-down process: Start with a general class and then subdivide it into more specialized classes.  The specialized classes may contain their own attributes. Attributes common to all subclasses remain in the superclass. Generalization is the process of creating a more general superclass from existing subclasses.  Bottom-up process: Start with specialized classes and try to determine a general class that contains the attributes common to all of them.

Generalization Example

Constraints on Generalization and Specialization There are two types of constraints associated with generalization and specialization:  Completeness constraint - determines if every member in a superclass must participate as a member of one of its subclasses. It may be optional for a superclass member to be a member of one of its subclasses, or it may be mandatory that a superclass member be a member of one of its subclasses. Manditory membership in one of the subclasses is denoted by a C (for completeness)  Disjoint constraint - determines if a member of a superclass can be a member of one or more than one of its subclasses. If a superclass object may be a member of only one of its subclasses this is denoted by a D (subclasses are disjoint).

Constraints Example Completeness constraint (must be developer or manager) Disjoint constraint (cannot be both a developer and a manager) D,C

Constraints Question Note: What is the completeness and the disjoint constraints for superclass Employee (with subclasses Manager and Supervisor) given these instances?

Problems with ER Models When modeling a Universe of Discourse using ER models, there are several challenges that you have. The first, basic challenge is knowing when to model a concept as an entity, a relationship, or an attribute. In general:  Entities are nouns. You should be able to identify a set of key attributes for an entity.  Attributes are properties and may be nouns or adjectives. Use an attribute if it relates to one entity and does not have its own key. Use an entity if the concept may be shared by entities and has a key.  Relationships should generally be binary. Note that non-binary relationships can be modeled as an entity instead.

Modeling Traps There are several different "modeling traps" (called connection traps) that you can fall into when designing your ER model. Two connection traps that we will look at are:  Fan traps  Chasm traps

Fan Trap A fan trap is when a model represents a relationship between entity types, but the pathway between certain entity instances is ambiguous.  Often occurs when two or more one-to-many relationships fan out (come from) the same entity type. Example: A department has multiple employees, a department has multiple projects, and each project has multiple employees. Now answer the question, which projects does employee E3 work on?

Fan Trap Example Which projects does employee E3 work on?

Chasm Traps A chasm trap occurs when a model suggests that a relationship between entity types should be present, but the relationship does not actually exist. (missing relationship)  May occur when there is a path of optional relationships between entities. Example: A department has multiple employees, a department has multiple projects, and each project has multiple employees.

Chasm Trap Example Which department is employee E8 in? What are the employees of department D4?

Good Design Practices When designing ER models, there are several things that you should consider:  Avoid redundancy - do not store the same fact more than once in the model.  Do not use an entity when you can use an attribute instead.  Limit the use of weak entity sets.

Good Design Practices Avoiding Redundancy Example

Good Design Practices Entity versus Attribute Example An entity should only be used if one of these conditions is true:  The entity set should contain at least one non-key attribute.  It is the many side in a many-to-one relationship. Example: Projects have a department. A department only has a number.

Good Design Practices Weak Entity Sets Avoid the use of weak entity sets in modeling. Although at first glance there are very few natural keys based on the properties of objects (name, age, etc.), there are many good human-made keys that can be used (SSN, student#, etc.) Whenever possible use a global, human-made key instead of a weak entity. Note that sometimes a weak entity is required if no such global key exists.  For example, a database storing the students of multiple universities could not use a single student# as a key as it is unlikely that universities could agree on a global numberingsystem. Rather, student becomes a weak entity with partial key student# and identifying entity the university the student attends.

Simplifications Sometimes it is necessary to simplify some of the relationships:  Crow’s foot database design tool only supports binary relationships. Two common simplifications:  Many-to-many relationship Two one-to-many relationships  Higher order relationships binary relationships

Many-to-Many Relationship Simplification A many-to-many relationship can be converted into one entity with two 1:N relationships between the new entity and the original entities participating in the relationship. Original Simplified

Simplifying Higher Degree Relationships A non-binary relationship can be converted into a weak entity with identifying relationships to the original entity types.