Lecture 4: Logical Database Design and the Relational Model 1.

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

Chapter 4: Logical Database Design and the Relational Model (Part I)
1 Logical Database Design and the Relational Model Modern Database Management.
Database Design & Mapping
DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design II (week 3)
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.
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.
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.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Chapter 5: Logical Database Design and the Relational Model
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
© 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.
Chapter 4: Logical Database Design and the Relational Model (Part II)
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
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
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.
Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL (PART I) Modern Database.
CS 370 Database Systems Lecture 9 The Relational model.
Chapter 5 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
© 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.
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.
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.
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.
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.
Chapter 4, Part A: Logical Database Design and the Relational Model
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.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 4: PART C LOGICAL.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
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.
Converting ER/EER to logical schema; physical design issues 1.
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
Unit 4: Normalization of Relations
Relational Database.
Chapter 5: Logical Database Design and the Relational Model
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Presentation transcript:

Lecture 4: Logical Database Design and the Relational Model 1

Relation A relation is a named, two-dimensional table of data Table consists of rows (records) and columns (attribute or field) Requirements for a table to qualify as a relation: 1.It must have a unique name 2.Every attribute value must be atomic (not multivalued or composite) 2

Cont… 3.Attributes (columns) in tables must have unique names 4.The order of the columns must be irrelevant 5.The order of the rows must be irrelevant 6.Every row must be unique (can’t have two rows with exactly the same values for all their fields) Note: All relations are in 1 st Normal Form 3

Correspondence with ER Model 1. Relations (tables) correspond with entity types and with many-to-many relationship types 2.Rows correspond with entity instances and with many-to-many relationship instances 3.Columns correspond with attributes Note: The word RELATION (in relational database) is NOT the same as the word RELATIONSHIP (in ER Model) 4

Key Fields Keys are special fields that serve two main purposes: 1.Primary keys – unique identifiers of the relation in question. 2.Foreign keys – identifiers that enable a dependent relation (on the many side of a relationship) to refer to its parent relation (on the one side of the relationship) Keys can be single or composite 5

Fig 5-3 Schema for four relations (PVFC) 6

Integrity Constraints Domain Constraints – allowable values for an attribute Entity Integrity - no primary key attribute may be null. All primary key fields MUST have data Actions Assertions - business rules 7

8

Integrity Constraints Referential Integrity – rule states that any foreign key value (on the relations of the many side) MUST match a primary key value in the relation of the one side (or the foreign key can be null) 9

Cont… Ex: Delete Rules a.Restrict – don’t allow delete of “parent” side if related rows exist in “dependent” side b.Cascade – automatically delete “dependent” side rows that correspond with the “parent” side row to be deleted c.Set-to-Null – set the foreign key in the dependent side to null if deleting from the parent side = not allowed for weak entities 10

Fig 5-5 Referential Integrity Constraints 11

Fig 5-6 SQL table definitions 12

Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1.Simple attributes: ER attributes map directly onto the relation 2.Composite attributes: use only their simple component attributes 3.Multivalued attribute: becomes a separate relation with a foreign key taken from the superior entity. 13

Fig 5-8 Mapping a regular entity 14

Fig 5-9 Mapping a Composite Attribute 15

Fig 5-10 Mapping an entity with a multivalued attribute 16

Cont… 4.Mapping Weak Entities - Becomes a separate relation with a foreign key taken from the superior entity Primary key composed of: a.Partial identifier of weak entity b.Primary key of identifying relation (strong entity) 17

Fig 5-11 Ex: Mapping a Weak Entity 18

Cont… 19

Cont… 5.Mapping Binary Relationships a.One-to-Many – Primary key on the one side becomes a foreign key on the many side b.Many-to-Many – Create a new relation with the primary keys of the two entities as its primary key c.One-to-One – Primary key on the mandatory side becomes a foreign key on the optional side 20

Fig 5-12 Ex: Mapping of 1:M Relationship 21

Fig 5-13 Ex: Mapping M:N Relationship 22

Cont… 23

Fig 5-14 Ex: Mapping a 1:1 relationship 24

Cont… 25

Cont… 6.Mapping Associative Entities a.Identifier Not Assigned a.1 Default primary key for the association relation is composed of the primary keys of the two entities (as in M:N relationship) b.Identifier Assigned b.1 It is natural and familiar to end users b.2 Default identifier may not be unique 26

Fig 5-15 Ex: Associative Entity 27

Cont… 28

Fig 5-16 Ex: Mapping an Associative Entity with an Identifier 29

Cont… 30

Cont… 7.Mapping Ternary (and n-ary) Relationships a.One relation for each entity and one for the associative entity b.Associative entity has foreign keys to each entity in the relationship 31

Fig 5-19 Mapping a Ternary Relationship 32

Cont… 33

Cont.. 8.Mapping Supertype/Subtype Relationships a.One relation for supertype and for each subtype b.Supertype attributes (including identifier and subtype discriminator) go into supertype relation c.Subtype attributes go into each subtype; primary key of supertype relation also becomes primary key of subtype relation 34

Cont.., d. 1:1 relationship established between supertype and each subtype, with supertype as primary table 35

Fig 5-20 Supertype/Subtype Relationships 36

Fig 5-21 Mapping Supertype/Subtype Relationships to Relation 37

Data Normalization 1.Primary a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data 2.The process of decomposing relations with anomalies to produce smaller, well- structured relations 38

Well-Structured Relations 1.A relation that contains minimal data redundancy and allows users to insert, delete, and update rows without causing data inconsistencies 2.Goal is avoid anomalies 2.1 Insertion anomaly – adding new rows forces user to create duplicate data 2.2 Deletion anomaly – deleting rows may cause a loss of data that would be needed for other future rows 39

Cont… 2.3 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 40

Fig 5-2b Ex: 41

Anomalies: 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 a multiple records 42

Cont… Why do these anomalies exist? Because there are two themes (entity types) in this one relation. These results to data duplication and an unnecessary dependency between the entities. 43

Functional Dependencies and Keys 1.Functional Dependency – the value of one attribute (determinant) determines the value of another attribute 2.Candidate Key: 2.1 Unique Identifier – one of the candidate keys will become the primary key Ex: Perhaps both credit card number and SS# are in the table… in this case both are candidate key 2.2 Each non-key field is functionally dependent on every candidate key 44

Fig 5-22 Steps in Normalization 45

First Normal Form  No multivalued attributes  Every attribute value is atomic  Fig 5-25 is not in 1 st Normal Form (multivalued attributes) = it is not a relation  Fig 5-26 is in 1 st Normal Form  All relations are in 1 st Normal Form 46

Fig 5-25 INVOICE DATA 47

Fig 5-26 INVOICE relation (1NF) 48

Anomalies in the Table Insertion – if new product is ordered for order 1007 of existing customer, customer data must be reentered, 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 required update in several records 49

Cont.. Why do these anomalies exists? Because there are multiple themes (entity types) in one relation. This results in duplication and an unnecessary dependency between the entities 50

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 51

Fig 5-27 Functional dependency diagram for INVOICE 52

Fig 5-28 Removing Partial Dependencies 53

Third Normal Form 2 NF PLUS no transitive dependencies (functional dependencies on non-primary-key attributes) Note: This is called transitive, because the primary key is a determinant for another attribute, which in turn is a determinant for a third Solution: Non-key determinant with transitive dependencies go into a new table; non-key determinant becomes primary key in the new table and stays as foreign key in the old table. 54

Fig 5-28 Removing Partial Dependencies 55

- End - 56