Database Design Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.

Slides:



Advertisements
Similar presentations
Database Design Chapter Five DATABASE CONCEPTS, 6th Edition
Advertisements

© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.
(wrapping up from last week)
Database Design Chapter Five DATABASE CONCEPTS, 6th Edition
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 5/1 Copyright © 2004 Please……. No Food Or Drink in the class.
Entity-Relationship Model
Data Modeling and the Entity-Relationship Model
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition.
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 6.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 8.
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the ER Model.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 COS 346 Day 5.
© 2005 by Prentice Hall Chapter 3a Database Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke Database Processing Chapter 6 Transforming Data.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 COS 346 Day 10.
Methodology Logical Database Design for the Relational Model
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.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 6.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 6 Database Design Using Entity- Relationship Models.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization.
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Database Design Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition.
Database Design Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Entity-Relationship Model
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Chapter 3 The Relational Model and Normalization
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
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 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall 5-1 Chapter Objectives Learn how to transform E-R data models into relational.
Concepts and Terminology Introduction to Database.
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types Different Relationship Types in a Logical Relational Model.
Chapter 5 The Relational Model and Normalization David M. Kroenke Database Processing © 2000 Prentice Hall.
© 2002 by Prentice Hall 1 Database Design David M. Kroenke Database Concepts 1e Chapter 5 5.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall, Modified by Dr. Mathis 3-1 David M. Kroenke’s Chapter Three: The Relational.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
Database Design Using Entity-Relationship Models Transformation of Entity-Relationship Models into Relational Database Design Trees, Networks, and Bills.
Database Design IST210 Class Lecture
Chapters 15 &16 Conceptual and Logical Database Design Methodology.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall, modified by Dr. Lyn Mathis 5-1 David M. Kroenke’s, 10 th ed. Chapter.
Data Modeling IST210 Class Lecture.
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.
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.
Database Design Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 4/1 Copyright © 2004 Please……. No Food Or Drink in the class.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
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.
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.
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.
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.
Database vs File System Integrated Data Reduced Data Duplication Program/Data Independence Easier representation for user Separate/Isolated data Appl.
Chapter 4: Logical Database Design and the Relational Model
The Relational Model and Database Normalization
Database Design Chapter Five DATABASE CONCEPTS, 4th Edition
Chapter 5: Logical Database Design and the Relational Model
Database Processing: David M. Kroenke’s Chapter Five:
Data Modeling and the Entity-Relationship Model
Presentation transcript:

Database Design Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-2 Chapter Objectives Learn how to transform E-R data models into relational designs Practice the normalization process from Chapter 2 Understand the need for denormalization Learn how to represent weak entities with the relational model Know how to represent 1:1, 1:N, and N:M binary relationships

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-3 Chapter Objectives (continued) Know how to represent 1:1, 1:N, and N:M recursive relationships Learn SQL statements for creating joins over binary and recursive relationships Understand the nature and background of normalization

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-4 Representing Entities with the Relational Model Create a relation for each entity –A relation has a descriptive name and a set of attributes that describe the entity The relation is then analyzed using the normalization rules As normalization issues arise, the initial relation design may need to change

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-5 Anomalies Relations that are not normalized will experience issues known as anomalies –Insertion anomaly Difficulties inserting data into a relation –Modification anomaly Difficulties modifying data into a relation –Deletion anomaly Difficulties deleting data from a relation

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-6 Solving Anomalies Most anomalies are solved by breaking an existing relation into two or more relations through a process known as normalization

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-7 Definition Review Functional dependency –The relationship (within the relation) that describes how the value of a one attribute may be used to find the value of another attribute Determinant –The attribute that can be used to find the value of another attribute in the relation –The right-hand side of a functional dependency

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-8 Definition Review Candidate key –The value of a candidate key can be used to find the value of every other attribute in the relation –A simple candidate key consists of only one attribute –A composite candidate key consists of more than one attribute

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-9 Normal Forms There are many defined normal forms: –First Normal Form (1NF) –Second Normal Form (2NF) –Third Normal Form (3NF) –Boyce-Codd Normal Form (BCNF) –Fourth Normal Form (4NF) –Fifth Normal Form (5NF) –Domain/Key Normal Form (DK/NF)

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-10 Normalization For our purposes, a relation is considered normalized when: Every determinant is a candidate key [Technically, this is Boyce-Codd Normal Form (BCNF)]

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-11 Denormalization Normalizing relations (or breaking them apart into many component relations) may significantly increase the complexity of the data structure The question is one of balance –Trading complexity for anomalies There are situations where denormalized relations are preferred

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-12 Weak Entities For an ID-dependent weak entity, the key of the parent becomes part of the key of the weak entity

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-13 Representing Relationships The maximum cardinality determines how a relationship is represented 1:1 relationship –The key from one relation is placed in the other as a foreign key –It does not matter which table receives the foreign key

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-14 A One-to-One Relationship Example LOCKEREMPLOYEE 1:1

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-15 One Representation of a One-to-One Relationship LockerDesc Location LockerID Locker LockerID EmpName EmpID Employee Foreign Key Primary Key

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-16 Another Representation of a One-to-One Relationship EmpID LockerDesc Location LockerID Locker EmpName EmpID Employee Foreign Key Primary Key

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-17 SQL For a 1:1 Join SELECT* FROMLOCKER, EMPLOYEE WHERELOCKER.EmpID = EMPLOYEE.EmpID; SELECT* FROMLOCKER, EMPLOYEE WHERELOCKER.LockerID = EMPLOYEE.LockerID;

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-18 Mandatory One-to-One Relationships A mandatory 1:1 relationship can easily be collapsed back into one relation. While there are times when the added complexity is warranted… –Added security –Infrequently accessed data components …very often these relations are collapsed into one relation

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-19 One-to-Many Relationships Like a 1:1 relationship, a 1:N relationship is saved by placing the key from one table into another as a foreign key However, in a 1:N the foreign key always goes into the many-side of the relationship

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-20 A One-to-Many Relationship Example DEPARTMENTEMPLOYEE 1:N

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-21 Representing a One-to-Many Relationship DeptName Location DeptID Department DeptID EmpName EmpID Employee Foreign Key Primary Key

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-22 SQL For a 1:N Join SELECT* FROMDEPARTMENT, EMPLOYEE WHEREDEPARTMENT.DeptID = EMPLOYEE.DeptID;

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-23 Representing Many-to-Many Relationships To save a M:N relationship, a new relation is created. This relation is called an intersection relation An intersection relation has a composite key consisting of the keys from each of the tables that formed it

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-24 A Many-to-Many Relationship Example SKILLEMPLOYEE N:M

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-25 Representing a Many-to- Many Relationship SkillDesc SkillID Skill EmpName EmpID Employee Foreign Key EmpID SkillID Emp_Skill Foreign Key Primary Key

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-26 SQL For a N:M Join SELECT* FROMSKILL, EMP_SKILL, EMPLOYEE WHERESKILL.SkillID = EMP_SKILL.SkillID ANDEMP_SKILL.EmpID = EMPLOYEE.EmpID;

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-27 Representing Recursive Relationships A recursive relationship is a relationship that a relation has with itself. Recursive relationships adhere to the same rules as the binary relationships. –1:1 and 1:M relationships are saved using foreign keys –M:N relationships are saved by creating an intersecting relation

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-28 A Recursive Relationship Example EMPLOYEE 1:N Manages

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-29 Representing a Recursive Relationship ManagerID EmpName EmpID Employee ManagerID is a Foreign Key referencing the Primary Key EmpID

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-30 SQL For a 1:1 Recursive Join SELECT A.EmpID, A.EmpName as 'Manager', B.EmpID, B.EmpName as 'Worker' FROM EMPLOYEE A, EMPLOYEE B WHERE A.EmpID = B.ManagerID; Example results: EmpID ManagerEmpID Worker 4Bryant 1Jones 4Bryant 2Adams 4Bryant 3Smith 5Dean 4Bryant

DAVID M. KROENKE’S DATABASE CONCEPTS, 2nd Edition © 2005 Pearson Prentice Hall 1-31 Cascading Behavior Cascading behavior describes what happens to child relations when a parent relation changes in value Cascading behaviors are defined by the type of operation –Cascade update –Cascade delete

Database Design End of Presentation on Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition