Entity Relationships. Relationships Relationships exist between entities The type of relationship is entirely dependent on the business rules The business.

Slides:



Advertisements
Similar presentations
More Diagramming & Practice with Relationship Modeling
Advertisements

Designing tables from a data model (Chapter 6) One base table for each entity.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Modeling the Data: Conceptual and Logical Data Modeling
DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design II (week 3)
Systems Development Life Cycle
Introduction to Relational Database ISYS 464. Introduction to Relational Model Data is logically structured within relations. Each relation is a table.
Entity-Relationship Model and Diagrams (continued)
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
Motivation for IDEF1X Simplicity Common Standard Useful when relational model is target Air Force 1985 or thereabouts.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Mapping ERM to relational database
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Relational DB Components
Database Design Sections 6 & 7 Second Normal Form (2NF), Unique Identifiers (UID), Third Normal Form (3NF), Arcs, Hierarchies and Recursive relationships.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Concepts and Terminology Introduction to Database.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
Avoiding Database Anomalies
Normalization (Codd, 1972) Practical Information For Real World Database Design.
WEEK 10 Database Design. Agenda – Week 10 Review Hybrid Review Table Instance Charts Primary Keys Normalization.
WEEK 10 Database Design. Agenda – Week 10 Review Hybrid Review Primary Keys Table Instance Charts.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
System Design System Design - Mr. Ahmad Al-Ghoul System Analysis and Design.
CS 370 Database Systems Lecture 9 The Relational model.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Physical.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Database Application Design and Data Integrity AIMS 3710 R. Nakatsu.
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.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
Chapter 17 Logical Database Design for the Relational Model Pearson Education © 2009.
Lesson 2: Designing a Database and Creating Tables.
Logical Database Design and the Relational Model.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
NORMALIZATION. What is Normalization  The process of effectively organizing data in a database  Two goals  To eliminate redundant data  Ensure data.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Tutorial 2 Data Modelling. 3 Terminology & Notation(1) An entity is an object about which the system needs to hold information –Customer, Student, Course.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
Database Design. Database Design Process Data Model Requirements Application 1 Database Requirements Application 2 Requirements Application 4 Requirements.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
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.
Lecture 4: Logical Database Design and the Relational Model 1.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Quiz Which of the following is not a mandatory characteristic of a relation? Rows are not ordered (Not required) Each row is a unique There is a.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
1 Database Design Sections 6 & 7 First Normal Form (1NF), Second Normal Form (2NF), Unique Identifiers (UID), Third Normal Form (3NF), Arcs, Hierarchies.
Database Design Chapters 17 and 18.
Chapter 4: Logical Database Design and the Relational Model
Chapter 5: Logical Database Design and the Relational Model
Tables and Their Characteristics
Database Design – Lecture 4
Entity-Relationship Model and Diagrams (continued)
Relational Database.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Systems Instructor Name: Lecture-11.
Data Modeling for Database Design 2
Database Processing: David M. Kroenke’s Chapter Six:
Presentation transcript:

Entity Relationships

Relationships Relationships exist between entities The type of relationship is entirely dependent on the business rules The business rules must be known first before determining the type of relationship. – E.g. Can a customer place more than one order? Can they have more than one phone number that the business needs to know about?

Relationships are Bidirectional Relationships have to be assessed in both directions between the entities Relationships are viewed from the standpoint of one record to its relationship to records in the other table A Customer can place many Orders, but any single order can only be placed by a single Customer

There are Four Relationship Types 1-1 One to One 1-M One to Many M-M Many to Many Recursive

One to one Relationships One to One (1:1) or (1-1) – Rare but a database can support it – E.g. “One employee is married to one Spouse” – It is a 1-1 relationship in both directions – One record in one table relates to only one record in the other table

1-1 Relationship When a record in one table matches up with only one record in the other table and vice versa

One to Many Relationships One to Many (1:n) or (1-M) – Most common and easily implemented in a database – E.g. “One customer places many orders” – It is a 1-M from Customer to Order – Is a 1-1 from Order to Customer – One record relates to many, but any single record in the second table relates back to only the parent in the first table

1-M Relationship When one record relates to one or many in the other table, but any one record in the second table will tie back to only one parent record

Many to Many Relationships Many to Many (M:n) or (M-M) Very common in the real world Can not be directly implemented in a database Will require a third “Junction Table” for implementation in the database A single record in one table may relate to many in the other table and vice versa E.g. – One student can take many classes, but any single class can be taken by many students

Many to Many Relationships One customer can hold many license types and any license type can be held my many customers – We can’t add Cust_Num to Licenses because it would be multi- valued – We can’t add License_Type to customer because it would be multi-valued – What can we do?

Many to Many Relationships M-M relationships are “bad” in a because they cause multi-valued fields if directly implemented To “solve” the issue, it does not work to: – Add additional columns – Add a record – Attempt a composite field The solution is adding a third “Junction Table” – Junction table primary key: Either a concatenation of the primary keys of the parent tables A combination of additional fields if the primary key combo is not unique Creating an artificial key

Junction Tables We can add a third table, a junction or bridge table This allows the M-M relationship to decompose into two 1-M relationships. 1 Customer can have many junction records 1 License can be related to many junction records A single junction record will relate back to one customer and one license

Recursive Relationships Recursive Relationship Rare but can be implemented in a database Occurs when a table has a 1-M relationship with itself Implemented by added the Primary Key of the table to the same table as a Foreign Key E.g. If an employee is also a team leader. The Employee_ID of the leader is added to the table as a foreign key to identify the team members of the leader

Recursive Relationships Recursive Relationship Employee ID has been added as the foreign key Manager ID. Who is Shemp’s manager? Employee #1, Moe

Relationship Optionality The relationship between entities may be optional or mandatory Since relationships are bidirectional, relationship optionality is also bidirectional

Relationship Optionality Relationships can be “optional” or “mandatory” Since relationships are bidirectional, they can be optional or mandatory in either direction – Optional – Optional – Mandatory – Mandatory – Optional – Mandatory Relationship optionality is dependent on the business rules of that particular database

Optional Relationship Optional Relationship: A parent record may exist with or without children A child record may exist without being tied to a parent Examples (optional in both directions) – A Model record may exist that does not have a Vehicle representing it – A Vehicle record could exist but be of an unknown Model

Relationship Optionality Mandatory Relationship: A parent record must have children A child record must be tied to a parent Examples (mandatory in both directions) – An Order record must have one or more Items – An Item record can not exist unless it is tied to a valid order

Relationship Optionality Optional and Mandatory relationships Optional in one direction, mandatory in the other Example: A Customer record may exist without a Rental But a rental record must be tied back to a valid Customer record.

Relationship Optionality and ERD’s Syntax in ERDs is used to convey relationship optionality (covered later in the class)