IMS 4212: Data Modeling—More Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Data Modeling—Topics.

Slides:



Advertisements
Similar presentations
Entity Relationship (ER) Modeling
Advertisements

Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
Entity Relationship (E-R) Modeling
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 8.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
Information Resources Management February 13, 2001.
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 4 ENTITY-RELATIONSHIP MODELLING.
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
BTM 382 Database Management Chapter 4: Entity Relationship (ER) Modeling Chitu Okoli Associate Professor in Business Technology Management John Molson.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Mapping ERM to relational database
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Entity-Relationship modeling Transparencies
3 Chapter 3 Entity Relationship (E-R) Modeling Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.
Chapter 7 Data Modeling with Entity Relationship Diagrams Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Chapter 4 The Relational Model.
Chapter 5 Entity–Relationship Modeling
BIS 360 – Lecture Six (Part 2) Conceptual Data Modeling (Chapter 10 and partial Chapter 12)
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
DATABASEMODELSDATABASEMODELS  A database model ◦ defines the logical design of data. ◦ Describes the relationships between different parts of data.
IMS 6217: Primary Key Reference 1 Dr. Lawrence West, MIS Dept., University of Central Florida Primary Keys Uniqueness of Table Rows Identifier.
IMS 6217: Relationships 1 Dr. Lawrence West, MIS Dept., University of Central Florida Database Design--Topics DB Design Steps Identify.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
IS 475/675 - Introduction to Database Design
IMS 4212: Data Modeling—Attributes 1 Dr. Lawrence West, Management Dept., University of Central Florida Attributes and Domains Nonkey.
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.
CS 370 Database Systems Lecture 9 The Relational model.
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.
Database Design – Lecture 5 Conceptual Data Modeling – adding attributes.
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)
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
IMS 4212: Introduction to Data Modeling—Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Relationships—Topics.
Chapter 3 Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
1 Entity-Relationship Model © Pearson Education Limited 1995, 2005.
1 CS 430 Database Theory Winter 2005 Lecture 15: How to Convert an ER Model to Relations.
Databases Illuminated Chapter 3 The Entity Relationship Model.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 4 ENTITY RELATIONSHIP (ER) MODELING Instructor Ms. Arwa Binsaleh 1.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
CS263 Lecture 5: Logical Database Design Can express the structure of a relation by a Tuple, a shorthand notation Name of the relation is followed (in.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Entity-Relationship Modeling. 2 Entity Type u Entity type –Group of objects with same properties, identified by enterprise as having an independent existence.
Logical Database Design and the Relational Model.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
IMS 6217: Database Design & Entities 1 Dr. Lawrence West, MIS Dept., University of Central Florida Database Design--Topics DB Design.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Chapter 5 Database Design
COP Introduction to Database Structures
Chapter 4: Part B Logical Database Design and the Relational Model
Entity Relationship (E-R) Modeling
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Review of Week 1 Database DBMS File systems vs. database systems
Relationships—Topics
Relationship Problems—Topics
Relationships—Topics
Presentation transcript:

IMS 4212: Data Modeling—More Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Data Modeling—Topics Foreign Keys Parent-Child Relationships Strong-Weak Entities Many to Many relationships Unary Relationships n-ary relationships Binary 1:1 relationships

IMS 4212: Data Modeling—More Relationships 2 Dr. Lawrence West, Management Dept., University of Central Florida Foreign Keys Relationships are established when the Primary Key attribute(s) of one entity is/are found in another entity These attributes are called Foreign Keys in the other entity Foreign Keys

IMS 4212: Data Modeling—More Relationships 3 Dr. Lawrence West, Management Dept., University of Central Florida Parent & Child Relationships (Terminology) The entity contributing the primary key is the parent The entity receiving the foreign key is the child Foreign Keys always, always, always go on the ‘many’ side of a 1:M relationship Identifier Attribute Shared Identifier Attribute (Foreign Key) ParentChild

IMS 4212: Data Modeling—More Relationships 4 Dr. Lawrence West, Management Dept., University of Central Florida Strong & Weak Entity Types Traditional definitions: –Strong entity type exists independently of any other entity –Weak entity type depends on some other entity type Strong Entity Type Weak Entity Type

IMS 4212: Data Modeling—More Relationships 5 Dr. Lawrence West, Management Dept., University of Central Florida Strong & Weak Entity Types (cont.) Identifying weak entities will often not happen until identifier attributes are specified When the Identifier Attribute of one entity appears as an attribute in another entity a relationship is established If the foreign key in the child table is not part of the child's PK the child is a strong entity Identifier Attribute Shared Identifier Attribute

IMS 4212: Data Modeling—More Relationships 6 Dr. Lawrence West, Management Dept., University of Central Florida Strong & Weak Entity Types (cont.) When the identifying attribute of one entity appears as part of a composite identifying attribute set in another entity the child entity is a weak entity Dept Code part of Course PK Indicates Weak Entity in some documentation styles (We will not use.) Parent (Strong) Child (Weak)

IMS 4212: Data Modeling—More Relationships 7 Dr. Lawrence West, Management Dept., University of Central Florida Strong vs. Weak Entity Types (Terminology) The identifying attribute that appears in the composite identifying attribute in a weak entity is sometimes called a cascading primary key. These primary key attributes can sometimes cascade through three or more entities Do not confuse mandatory relationships with weak entities

IMS 4212: Data Modeling—More Relationships 8 Dr. Lawrence West, Management Dept., University of Central Florida Many-to-Many Relationships What is the problem with implementing foreign keys for the following Many-to-Many relationships?

IMS 4212: Data Modeling—More Relationships 9 Dr. Lawrence West, Management Dept., University of Central Florida Many-to-Many Relationships (cont.) Many-to-Many (M:N) relationships must be decomposed into a new entity and two relationships Carefully examine the cardinality of the two new relationships If one is still M:N then decompose again

IMS 4212: Data Modeling—More Relationships 10 Dr. Lawrence West, Management Dept., University of Central Florida Many-to-Many Relationships (cont.) Always try the combination of the primary keys from the two original entities as the PK of the new entity –Sometimes not all attributes of a composite parent PK are needed –Sometimes an alternate PK suggests itself –Sometimes this proposed PK is not unique Add appropriate nonkey attributes to the new entity –Sometimes there won't be any—the new entity serves no role but to decompose the M:N relationship

IMS 4212: Data Modeling—More Relationships 11 Dr. Lawrence West, Management Dept., University of Central Florida Decomposing Many to Many Relationships Create a new entity Bring in PKs of original entities to the new entity Ask if the combination of these FKs can be the PK of the new entity –Defines the entity –Is enough to guarantee uniqueness –Is more than enough to guarantee uniqueness What is the new entity? Does a different PK suggest itself

IMS 4212: Data Modeling—More Relationships 12 Dr. Lawrence West, Management Dept., University of Central Florida Decomposing Many to Many Relationships (cont.) Determine the cardinality of the relationships from the original entities to the new entity If one (or both) are still many-to-many decompose again

IMS 4212: Data Modeling—More Relationships 13 Dr. Lawrence West, Management Dept., University of Central Florida Many-to-Many Relationships (cont.) Two kinds of entities created this way –A real ‘person, place, thing, event…’ that was overlooked in the original design –An ‘associative entity’ that has no purpose except to decompose the M:M relationship The distinction isn’t terribly important Both kinds can have non-key attributes

IMS 4212: Data Modeling—More Relationships 14 Dr. Lawrence West, Management Dept., University of Central Florida Many-to-Many Relationships (cont.) Decompose this relationship Sometimes the new entity has a natural meaning that should have been identified in the original data modeling step

IMS 4212: Data Modeling—More Relationships 15 Dr. Lawrence West, Management Dept., University of Central Florida Unary Relationships Unary relationships are relationships between an entity and itself –One employee supervises many other employees; each employee is supervised by, at most, one other employee –One part is a component of many other parts; One part (assembly) contains many other parts

IMS 4212: Data Modeling—More Relationships 16 Dr. Lawrence West, Management Dept., University of Central Florida EmployeeIDLastNameFirstName…ReportsTo 3JonesSally…9 5JeffersonMark…3 6WilsonJohn…3 8AdamskiJustin…9 9BossBig…9 13DowdRuss…6 19BrownLarry…9 Unary Relationships and Foreign Keys The foreign key in a unary relationship will be a different attribute in the entity

IMS 4212: Data Modeling—More Relationships 17 Dr. Lawrence West, Management Dept., University of Central Florida Decomposing Unary M:N relationships Unary Many-to-Many Relationships

IMS 4212: Data Modeling—More Relationships 18 Dr. Lawrence West, Management Dept., University of Central Florida Unary M:M Relationships (cont.) Fix this one

IMS 4212: Data Modeling—More Relationships 19 Dr. Lawrence West, Management Dept., University of Central Florida Ternary Relationships Ternary (or n-ary) relationships are relationships between three (or more) entities It will almost always be possible to identify a natural associative entity that reflects the relationship between the entities Create the weak associative entity and bring in foreign keys from the original entities

IMS 4212: Data Modeling—More Relationships 20 Dr. Lawrence West, Management Dept., University of Central Florida Ternary Relationships (cont.) In n-ary relationships there is a higher likelihood that the new entity will have its own 'natural' PK Examine the default PK carefully to see if it is appropriate Can you think of an alternate PK for the HouseSale entity? (What other entities are likely to be related to the HouseSale entity?)

IMS 4212: Data Modeling—More Relationships 21 Dr. Lawrence West, Management Dept., University of Central Florida Binary 1:1 Relationships In a 1:M relationship the parent entity will always be on the '1' side of the relaionship –Foreign key will be in the 'M' side Q: Where should the FK be in a 1:1 relationship?

IMS 4212: Data Modeling—More Relationships 22 Dr. Lawrence West, Management Dept., University of Central Florida Binary 1:1 Relationships (cont.) A: It doesn't matter (much) Some considerations –Use the simplest PK/FK available –If there is a 'natural' parent (e.g., employee 'owns' the office, not the other way around) make it the parent –If an occurrence of one member of the relationship may stand alone (not participate in a relationship) while the other will usually be in a relationship make it the parent