Chapter 4: Logical Database Design and the Relational Model (Part II)

Slides:



Advertisements
Similar presentations
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
Advertisements

1 Logical Database Design and the Relational Model Modern Database Management.
CSc-340 6b1 Relational Database Design Chapter 8 [1 of 2] Features of Good Relational Designs Atomic Domains and First Normal Form Decomposition Using.
Systems Development Life Cycle
© 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.
© 2005 by Prentice Hall Chapter 3a Database Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Chapter 4: Logical Database Design and 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.
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
Terms - data,information, file record, table, row, column, transaction, concurrency Concepts - data integrity, data redundancy, Type of databases – single-user,
© 2007 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 5: Logical Database Design and the Relational Model
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
TM 6-1 Copyright © Addison Wesley Longman, Inc. & Dr. Chen, Business Database Systems Logical Database Design and the Relational Database Professor Chen.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 4: Logical Database Design and the Relational Model Modern Database Management 10.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Functional Dependence An attribute A is functionally dependent on attribute(s) B if: given a value b for B there is one and only one corresponding value.
Concepts and Terminology Introduction to Database.
Chapter 5: Logical Database Design and the Relational Model
Concepts of Database Management, Fifth Edition
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
Object-Relational Modeling. What Is a Relational Data Model? Based on the concept of relations (tables of data) Relationships established by matching.
Chapter 5 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
Unit 4 Object Relational Modeling. Key Concepts Object-Relational Modeling outcomes and process Relational data model Normalization Anomalies Functional.
© 2005 by Prentice Hall 1 The Database Development Process Dr. Emad M. Alsukhni The Database Development Process Dr. Emad M. Alsukhni Modern Database Management.
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 10 Normalization Pearson Education © 2009.
Pree Thiengburanathum, CAMT, Chiang Mai University 1 Database System Logical Database Design and the Relational Model November 1 st, 2009 Software Park,
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part c): Logical Database Design and the Relational Model Modern Database Management.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Normalization Hour1,2 Presented & Modified by Mahmoud Rafeek Alfarra.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
6-1 © Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 3: LOGICAL DATABASE.
Chapter 5 MODULE 6: Normalization © 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Prepared by: KIM GASTHIN M. CALIMQUIM.
© 2007 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B.
8-1 © Prentice Hall, 2007 Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Chapter 4, Part A: Logical Database Design and the Relational Model
Lecture 4: Logical Database Design and the Relational Model 1.
Logical Database Design and Relational Data Model Muhammad Nasir
Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 4: Logical Database Design and the Relational Model Modern Database Management.
Lecture # 17 Chapter # 10 Normalization Database Systems.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 4: PART C LOGICAL.
N ORMALIZATION 1. Chapter 5 R ELATION Definition: A relation is a named, two-dimensional table of data Table consists of rows (records) and columns (attribute.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 8: Object-Relational Modeling
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
Normalization Karolina muszyńska
Modern Database Management Jeff Hoffer, Ramesh Venkataraman,
Chapter 5: Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
Example Question–Is this relation Well Structured? Student
Unit 4: Normalization of Relations
Chapter 9 Designing Databases
Relational Database.
Chapter 5: Logical Database Design and the Relational Model
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Presentation transcript:

Chapter 4: Logical Database Design and the Relational Model (Part II) Modern Database Management 11th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi

Objectives Define terms List five properties of relations State two properties of candidate keys Define first, second, and third normal form Describe problems from merging relations Transform E-R and EER diagrams to relations Create tables with entity and relational integrity constraints Use normalization to convert anomalous tables to well-structured relations

NOTE: all relations are in 1st Normal form A relation is a named, two-dimensional table of data. A table consists of rows (records) and columns (attribute or field). Requirements for a table to qualify as a relation: It must have a unique name. Every attribute value must be atomic (not multivalued, not composite). Every row must be unique (can’t have two rows with exactly the same values for all their fields). Attributes (columns) in tables must have unique names. The order of the columns must be irrelevant. The order of the rows must be irrelevant. NOTE: all relations are in 1st Normal form

Correspondence with E-R Model Relations (tables) correspond with entity types and with many-to-many relationship types. Rows correspond with entity instances and with many-to-many relationship instances. Columns correspond with attributes. NOTE: The word relation (in relational database) is NOT the same as the word relationship (in E-R model).

Data Normalization (Start of new slide; after Slide#46 of Part 1) Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data The process of decomposing relations with anomalies to produce smaller, well-structured relations

Well-Structured Relations A relation that contains minimal data redundancy and allows users to insert, delete, and update rows without causing data inconsistencies Goal is to avoid anomalies Insertion Anomaly–adding new rows forces user to create duplicate data Deletion Anomaly–deleting rows may cause a loss of data that would be needed for other future rows Modification Anomaly–changing data in a row forces changes to other rows because of duplication General rule of thumb: A table should not pertain to more than one entity type i.e., convert ONLY ONE entity to one table

Example–Figure 4-2b Question–Is this a relation? Answer–Yes: Unique rows and no multivalued attributes Question–What’s the primary key? Answer–Composite: EmpID, CourseTitle

Anomalies in this Table Insertion–can’t enter a new employee without having the employee take a class Deletion–if we remove employee 140, we lose information about the existence of a Tax Acc class Modification–giving a salary increase to employee 100 forces us to update multiple records Why do these anomalies exist? Because there are two themes (entity types) in this one relation. This results in data duplication and an unnecessary dependency between the entities

Example–Figure 4-2b

Functional Dependencies and Keys Functional Dependency: The value of one attribute (the determinant) determines the value of another attribute (the determinee) Candidate Key: A unique identifier. One of the candidate keys will become the primary key E.g. perhaps there is both credit card number and SS# in a table…in this case both are candidate keys

Figure 4.22 Steps in normalization 3rd normal form is generally considered sufficient

No multivalued attributes First Normal Form No multivalued attributes Every attribute value is atomic Fig. 4-25 is not in 1st Normal Form (multivalued attributes)  it is not a relation Fig. 4-26 is in 1st Normal form All relations are in 1st Normal Form

Table with multivalued attributes, not in 1st normal form Note: this is NOT a relation

Table with no multivalued attributes and unique rows, in 1st normal form Note: this is a relation, but not a well-structured one

Anomalies in this Table Insertion–if new product is ordered for order 1007 of existing customer, customer data must be re-entered, causing duplication Deletion–if we delete the Dining Table from Order 1006, we lose information concerning this item's finish and price Update–changing the price of product ID 4 requires update in multiple records Why do these anomalies exist? Because there are multiple themes (entity types) in one relation. This results in duplication and an unnecessary dependency between the entities

Intuitive examination for the “themes” in the following table

Second Normal Form 1NF, PLUS every non-key attribute is fully functionally dependent on the ENTIRE primary key Every non-key attribute must be defined by the entire key, not by only part of the key  No partial functional dependencies Discussion: “Entire primary key” implies that this key is a ________ ___? Therefore, 2NF is relevant only when the original relationship is __________________?

Therefore, NOT in 2nd Normal Form Figure 4-27 Functional dependency diagram for INVOICE OrderID  OrderDate, CustomerID, CustomerName, CustomerAddress CustomerID  CustomerName, CustomerAddress ProductID  ProductDescription, ProductFinish, ProductStandardPrice OrderID, ProductID  OrderQuantity Therefore, NOT in 2nd Normal Form

Second Normal Form Solution (p.185): create a new relation for each primary key attribute that is determinant in a partial dependency That attribute is the primary key in the new relation Move the non-key attributes that are dependent on this primary key attribute from the old relation to the new relation (remove them from the old relation) If A+B is key, then (A+B) must c, d, e, f IF (A+B)f, and Ac,d; Be - violation

Second Normal Form If A+B is key, then (A+B) must c, d, e, f IF (A+B)f, and Ac,d; Be - violation A B C D E F

Figure 4-28 Removing partial dependencies Getting it into Second Normal Form Partial dependencies are removed, but there are still transitive dependencies IF (1) (A+B) f, and (2) Ac,d; (3) Be, then solution: Relation (1), (2) , and relation (3)

Second Normal Form - Solution IF (A+B)f, and Ac,d; Be – violation Solution: Relation (1), (2) , and relation (3) 1 A B F A C D 2 3 B E

Third Normal Form 2NF PLUS no transitive dependencies (functional dependencies on non-primary-key attributes) Note: called transitive because the primary key is a determinant for another attribute, which in turn is a determinant for a third Wrong: Ac and c  d in a relation Solution (p186): Non-key determinant (“c”here) with transitive dependencies go into a new table/ relation; non-key determinant becomes primary key in the new table and stays as foreign key in the old table Dependents are REMOVED from the old relation

Transitive dependency: Acd. Solution: Ac, and also Figure 4-29 Removing partial dependencies Getting it into Third Normal Form Transitive dependencies are removed Transitive dependency: Acd. Solution: Ac, and also cd , a different relation (table)

Partial vs Transitive dependency Partial: “part” of the key determines others; So only happens when there is a __________ key (A+B)  f; yet also exists B  e Transitive: Key determines non-key-1, and non-key-1 determines non-key-2 “you are NOT a key! So you can’t determine others!” A (key)  c (non-key-1)  d (non-key-2)

Partial vs Transitive dependency 1 2 A B C D E F 3 1: _________________________ dependency? 2: _________________________ dependency? 3: _________________________ dependency?

Partial vs Transitive - normalized 1 2 A B C D E F 3 1 2 A B F B E A C D A C C D 3 3

Partial vs Transitive dependency 1 A B C D E 3 1: _________________________ dependency? 3: _________________________ dependency? Q: Will we have the issue of partial dependency in this case?  conclusion re where would each exist

Simple rules by examining arrows Arrow situation Field type/Dependency type One arrow out One arrow in Two arrows out One in, one out Two arrows in “No in, no out”

This arrow is not “that arrow” The arrows we’re discussing here are about ________________________ In Part I of the chapter we also had arrows, that were about __________________ In “1” above, arrow starts from __________ and ends at _____________ (in a _______ _______) In “2” above, arrow starts from __________ and ends at _____________ (in a _______ _______) -- so, don’t confuse the two!

Merging Relations View Integration–Combining entities from multiple ER models into common relations Issues to watch out for when merging entities from different ER models: Synonyms–two or more attributes with different names but same meaning Homonyms–attributes with same name but different meanings Transitive dependencies–even if relations are in 3NF prior to merging, they may not be after merging Supertype/subtype relationships–may be hidden prior to merging

Enterprise Keys Primary keys that are unique in the whole database, not just within a single relation Corresponds with the concept of an object ID in object-oriented systems

Figure 4-31 Enterprise keys a) Relations with enterprise key b) Sample data with enterprise key

Recap: Identify PD and TD 2NF: No partial dependency Implies: composite key Dependencies with the determinant being PART of the composite key 3NF: No transitive dependency Dependencies with the determinant being non-key A B C D E F G H