Relationship Problems—Topics

Slides:



Advertisements
Similar presentations
Entity Relationship (ER) Modeling
Advertisements

Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Information Resources Management February 13, 2001.
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
BTM 382 Database Management Chapter 4: Entity Relationship (ER) Modeling Chitu Okoli Associate Professor in Business Technology Management John Molson.
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
Chapter 4 The Relational Model.
Chapter 5 Entity Relationship (ER) Modelling
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
IMS 6217: Relationships 1 Dr. Lawrence West, MIS Dept., University of Central Florida Database Design--Topics DB Design Steps Identify.
CS 370 Database Systems Lecture 9 The Relational model.
IMS 4212: Data Modeling—More Relationships 1 Dr. Lawrence West, Management Dept., University of Central Florida Data Modeling—Topics.
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 8 Entity-Relationship Modeling Pearson Education © 2009.
Entity Relationship (E-R) Model
COP Introduction to Database Structures
Databases (CS507) CHAPTER 7.
Logical Database Design and the Rational Model
Data Modeling and the Entity-Relationship Model
Chapter 5 Database Design
COP Introduction to Database Structures
TMC2034 Database Concept and Design
Chapter 4: Logical Database Design and the Relational Model
Chapter 4: Part B Logical Database Design and the Relational Model
Entity Relationship (E-R) Modeling
Requirements Become the E-R Data Model
Entity Relationship (E-R) Modeling
Chapter 5: Logical Database Design and the Relational Model
Tables and Their Characteristics
Chapter -3- Data Modeling Using the Entity-Relationship Model
Database Design – Lecture 4
CS 3630 Database Design and Implementation
Entity-Relationship Modelling
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
Entity-Relationship Model
Logical Data Modeling.
Entity Relationship Diagram
COS 346 Day 8.
Entity-Relationship Modeling
الفصل الخامس قواعد البيانات Databases
Database Systems: Design, Implementation, and Management Tenth Edition
Entity-Relationship Modelling
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Systems Instructor Name: Lecture-11.
From data needs to ER Model to relational DB Schema
Review of Week 1 Database DBMS File systems vs. database systems
Relational Database Design by ER- and EER-to-Relational Mapping
Conceptual Data Modeling Using Entities & Relationships
Chapter 3: Modeling Data in the Organization
Relationships—Topics
Relationships—Topics
Chapter 4 Entity Relationship (ER) Modeling
Mapping an ERD to a Relational Database
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
ER MODELING Instructor: SAMIA ARSHAD
Entity Relationship (ER) Modeling
Chapter # 4 Entity Relationship (ER) Modeling.
Mapping an ERD to a Relational Database
Relationships—Topics
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

Relationship Problems—Topics Foreign Keys (review) Many to Many relationships Ternary (n-ary) relationships Relationships with Attributes Parent-Child Relationships Strong-Weak Entities Unary Relationships Binary 1:1 relationships

Identify “Information Elements” Identify Entities Database Design Steps Identify “Information Elements” Identify Entities Identify Primary Keys Identify Relationships Fix Relationship Problems Identify Non-Key Attributes Fix Attribute Problems Address Performance Issues Build Application Objects (stored procedures, views) Design Reports List is not strictly sequential Some steps performed recursively Some steps require returning to previous steps

Problem Relationships Three kinds of relationship create serious implementation problems Many-to-Many relationships Ternary relationships Attributes on relationships What are they? What does the nature of the problem tell us about what we should do to fix it?

These attributes are called Foreign Keys in the other entity 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

Many-to-Many Relationships What is the problem with implementing foreign keys for the following Many-to-Many relationships?

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

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 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

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

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

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

Unary Relationships and Foreign Keys The foreign key in a unary relationship will be a different attribute in the entity EmployeeID LastName FirstName … ReportsTo 3 Jones Sally 9 5 Jefferson Mark 6 Wilson John 8 Adamski Justin Boss Big 13 Dowd Russ 19 Brown Larry

Unary Many-to-Many Relationships Decomposing Unary M:N relationships

Unary M:M Relationships (cont.) Fix this one

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

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?)

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?

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

Binary 1:1 Relationships (cont.) Watch for 1:1 relationships that are really relationships between two versions of the same entity Some 1:1 relationships may actually be supertype/subtype relationships Relationships modeled as Supertype/Subtype in the modeling process are implemented in the database as 1:1 relationships Supertype/Subtype covered later in course

Attributes on Relationships We cannot have attributes on relationships There is to container for the values Create a new entity for the attributes