Michael F. Price College of Business Chapter 6: Logical database design and the relational model.

Slides:



Advertisements
Similar presentations
BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Advertisements

Chapter 4: Logical Database Design and the Relational Model (Part I)
1 Logical Database Design and the Relational Model Modern Database Management.
Modeling the Data: Conceptual and Logical Data Modeling
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
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.
Modern Systems Analysis and Design Third Edition
Mapping from E-R Model to Relational Model Yong Choi School of Business CSUB.
© 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.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
10-1 Chapter 10 Designing Databases Modern Systems Analysis and Design Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Chapter 4 The Relational Model.
© 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.
Mapping from Data Model (ERD) to Relational Model Yong Choi School of Business CSUB.
Web-Enabled Decision Support Systems
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Concepts and Terminology Introduction to Database.
Mapping from Data Model (ERD) to Relational Model
Chapter 5: Logical Database Design and the Relational Model
Lecture 12 Designing Databases 12.1 COSC4406: Software Engineering.
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.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
10/3/2012ISC329 Isabelle Bichindaritz1 Logical Design.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL (PART I) Modern Database.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
Chapter 5 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
© 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 9 Logical Database Design : Mapping ER Model To Tables.
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.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
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.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 3: LOGICAL DATABASE.
© 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.
Lecture 4: Logical Database Design and the Relational Model 1.
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Converting ER/EER to logical schema; physical design issues 1.
Lecture 5 Supplement – ER Model & Mapping to Relational Model
Logical Database Design and the Rational Model
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
Chapter 4: Part B Logical Database Design and the Relational Model
Chapter 5: Logical Database Design and the Relational Model
Example Question–Is this relation Well Structured? Student
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:

Michael F. Price College of Business Chapter 6: Logical database design and the relational model

Michael F. Price College of Business Objectives of logical design... u Translate the conceptual design into a logical database design that can be implemented on a chosen DBMS Input: conceptual model (ERD) Output: relational schema, normalized relations u Resulting database must meet user needs for: Data sharing Ease of access Flexibility u Translate the conceptual design into a logical database design that can be implemented on a chosen DBMS Input: conceptual model (ERD) Output: relational schema, normalized relations u Resulting database must meet user needs for: Data sharing Ease of access Flexibility

Michael F. Price College of Business Relational database components u Data structure Data organized into tables u Data manipulation Add, delete, modify, and retrieve using SQL u Data integrity Maintained using business rules u Data structure Data organized into tables u Data manipulation Add, delete, modify, and retrieve using SQL u Data integrity Maintained using business rules

Michael F. Price College of Business Why do I need to know this? u Mapping conceptual models to relational schema is straight-forward u CASE tools can perform many of the steps, but.. Often CASE cannot model complexity of data and relationship (e.G., Ternary relationships, supertype/subtypes) There are times when legitimate alternates must be evaluated You must be able to perform a quality check on CASE tool results u Mapping conceptual models to relational schema is straight-forward u CASE tools can perform many of the steps, but.. Often CASE cannot model complexity of data and relationship (e.G., Ternary relationships, supertype/subtypes) There are times when legitimate alternates must be evaluated You must be able to perform a quality check on CASE tool results

Michael F. Price College of Business Some rules... u Every table has a unique name. u Attributes in tables have unique names. u Every attribute value is atomic. Multi-valued and composite attributes? u Every row is unique. u The order of the columns is irrelevant. u The order of the rows is irrelevant. u Every table has a unique name. u Attributes in tables have unique names. u Every attribute value is atomic. Multi-valued and composite attributes? u Every row is unique. u The order of the columns is irrelevant. u The order of the rows is irrelevant.

Michael F. Price College of Business The key... u Relational modeling uses primary keys and foreign keys to maintain relationships u Primary keys are typically the unique identifier noted on the conceptual model u Foreign keys are the primary key of another entity to which an entity has a relationship u Composite keys are primary keys that are made of more than one attribute Weak entities Associative entities u Relational modeling uses primary keys and foreign keys to maintain relationships u Primary keys are typically the unique identifier noted on the conceptual model u Foreign keys are the primary key of another entity to which an entity has a relationship u Composite keys are primary keys that are made of more than one attribute Weak entities Associative entities

Michael F. Price College of Business Implementing it Instance Attribute Entity Field

Michael F. Price College of Business What about relationships?

Michael F. Price College of Business Constraints u Domain constraints Allowable values for an attribute as defined in the domain u Entity integrity constraints No primary key attribute may be null u Operational constraints Business rules u Referential integrity constraints u Domain constraints Allowable values for an attribute as defined in the domain u Entity integrity constraints No primary key attribute may be null u Operational constraints Business rules u Referential integrity constraints

Michael F. Price College of Business Referential integrity constraint u Maintains consistency among rows of two entities matching of primary and foreign keys u Enforcement options for deleting instances Restrict Cascade Set-to-Null u Maintains consistency among rows of two entities matching of primary and foreign keys u Enforcement options for deleting instances Restrict Cascade Set-to-Null

Michael F. Price College of Business Transforming the EER diagram into relations The steps: u Map regular entities u Map weak entities u Map binary relationships u Map associative entities u Map unary relationships u Map ternary relationships u Map supertype/subtype relationships The steps: u Map regular entities u Map weak entities u Map binary relationships u Map associative entities u Map unary relationships u Map ternary relationships u Map supertype/subtype relationships

Michael F. Price College of Business Transforming E-R diagrams into relations Mapping regular entities to relations Composite attributes: use only their simple, component attributes Multi-valued attributes: become a separate relation with a foreign key taken from the superior entity Mapping regular entities to relations Composite attributes: use only their simple, component attributes Multi-valued attributes: become a separate relation with a foreign key taken from the superior entity

Michael F. Price College of Business Mapping a composite attribute

Michael F. Price College of Business Looks like this using relational schema notation

Michael F. Price College of Business Transforming E-R diagrams into relations Mapping weak entities Becomes a separate relation with a foreign key taken from the superior entity Mapping weak entities Becomes a separate relation with a foreign key taken from the superior entity

Michael F. Price College of Business Example of mapping a weak entity

Michael F. Price College of Business Looks like this using relational schema notation

Michael F. Price College of Business Transforming E-R diagrams into relations Mapping binary relationships One-to-many - primary key on the one side becomes a foreign key on the many side Many-to-many - create a new relation (associative entity) with the primary keys of the two entities as its primary key –I like to call these intersection entities to distinguish them from associative entities created at the conceptual level One-to-one - primary key on the mandatory side becomes a foreign key on the optional side Mapping binary relationships One-to-many - primary key on the one side becomes a foreign key on the many side Many-to-many - create a new relation (associative entity) with the primary keys of the two entities as its primary key –I like to call these intersection entities to distinguish them from associative entities created at the conceptual level One-to-one - primary key on the mandatory side becomes a foreign key on the optional side

Michael F. Price College of Business Example of mapping a 1:M relationship

Michael F. Price College of Business Looks like this using relational schema notation

Michael F. Price College of Business Example of mapping an M:M relationship

Michael F. Price College of Business Looks like this using relational schema notation

Michael F. Price College of Business Mapping a binary 1:1 relationship

Michael F. Price College of Business Looks like this using relational schema notation

Michael F. Price College of Business Transforming E-R diagrams into relations Mapping associative entities Identifier not assigned –Default primary key for the association relation is the primary keys of the two entities Identifier assigned –It is natural and familiar to end-users –Default identifier may not be unique Mapping associative entities Identifier not assigned –Default primary key for the association relation is the primary keys of the two entities Identifier assigned –It is natural and familiar to end-users –Default identifier may not be unique

Michael F. Price College of Business Mapping an associative entity with an identifier

Michael F. Price College of Business Looks like this using relational schema notation

Michael F. Price College of Business Transforming E-R diagrams into relations Mapping unary relationships One-to-many - recursive foreign key in the same relation Many-to-many - two relations: –One for the entity type –One for an associative relation in which the primary key has two attributes, both taken from the primary key of the entity Mapping unary relationships One-to-many - recursive foreign key in the same relation Many-to-many - two relations: –One for the entity type –One for an associative relation in which the primary key has two attributes, both taken from the primary key of the entity

Michael F. Price College of Business For example... EMPLOYEE Supervises Emp-Name Emp_Address Emp_Num

Michael F. Price College of Business Would look like... Emp_Num Emp_Name Emp_Address Boss_Num references

Michael F. Price College of Business And.. COMPONENT BOM Description Unit_of-Measure Comp_Num Num_Units

Michael F. Price College of Business Would look like... Comp_Num Desc Unit_of_Measure COMPONENT Num-of_Units Comp_Num Subassembly_Num BOM

Michael F. Price College of Business Transforming E-R diagrams into relations Mapping ternary (and n-ary) relationships One relation for each entity and one for the associative entity Mapping ternary (and n-ary) relationships One relation for each entity and one for the associative entity

Michael F. Price College of Business Mapping a ternary relationship

Michael F. Price College of Business Looks like this using relational schema notation

Michael F. Price College of Business Transforming E-R diagrams into relations Mapping Supertype/subtype relationships Create a separate relation for the supertype and each of the subtypes Assign common attributes to supertype Assign primary key and unique attributes to each subtype Assign an attribute of the supertype to act as subtype discriminator Mapping Supertype/subtype relationships Create a separate relation for the supertype and each of the subtypes Assign common attributes to supertype Assign primary key and unique attributes to each subtype Assign an attribute of the supertype to act as subtype discriminator

Michael F. Price College of Business Mapping Supertype/subtype relationships

Michael F. Price College of Business Would look like this...

Michael F. Price College of Business Let’s try a couple….

Michael F. Price College of Business Well-structured relations u Well-structured relations contain minimal redundancy and allow insertion, modification, and deletion without errors or inconsistencies u Anomalies are errors or inconsistencies resulting from redundancy Insertion anomaly Deletion anomaly Modification anomaly u Well-structured relations contain minimal redundancy and allow insertion, modification, and deletion without errors or inconsistencies u Anomalies are errors or inconsistencies resulting from redundancy Insertion anomaly Deletion anomaly Modification anomaly

Michael F. Price College of Business Data normalization u Normalization is a formal process for deciding which attributes should be grouped together in a relation Objective: to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data Definition: the process of decomposing relations with anomalies to produce smaller, well-structured relations u Normalization is a formal process for deciding which attributes should be grouped together in a relation Objective: to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data Definition: the process of decomposing relations with anomalies to produce smaller, well-structured relations

Michael F. Price College of Business Steps in normalization

Michael F. Price College of Business Functional dependencies and keys u Functional dependency: the value of one attribute (the determinant) determines the value of another attribute A -> B, for every valid instance of A, that value of A uniquely determines the value of B u Candidate key: an attribute or combination of attributes that uniquely identifies an instance Uniqueness: each non-key field is functionally dependent on every candidate key Non-redundancy u Functional dependency: the value of one attribute (the determinant) determines the value of another attribute A -> B, for every valid instance of A, that value of A uniquely determines the value of B u Candidate key: an attribute or combination of attributes that uniquely identifies an instance Uniqueness: each non-key field is functionally dependent on every candidate key Non-redundancy

Michael F. Price College of Business First normal form u No multi-valued attributes. u Every attribute value is atomic. u No multi-valued attributes. u Every attribute value is atomic.

Michael F. Price College of Business Second normal form u 1NF and every non-key attribute is fully functionally dependent on the primary key. u Every non-key attribute must be defined by the entire key, not by only part of the key. u No partial functional dependencies. u 1NF and every non-key attribute is fully functionally dependent on the primary key. u Every non-key attribute must be defined by the entire key, not by only part of the key. u No partial functional dependencies.

Michael F. Price College of Business Third normal form u 2NF and no transitive dependencies (functional dependency between non-key attributes.)

Michael F. Price College of Business Relation with transitive dependency

Michael F. Price College of Business Transitive dependency in SALES relation

Michael F. Price College of Business Removing a transitive dependency

Michael F. Price College of Business Relations in 3NF

Michael F. Price College of Business Let’s practice...

Michael F. Price College of Business Other considerations... u Synonyms: different names, same meaning. u Homonyms: same name, different meanings. u Synonyms: different names, same meaning. u Homonyms: same name, different meanings.