Converting ER/EER to logical schema; physical design issues 1.

Slides:



Advertisements
Similar presentations
Chapter 4: Logical Database Design and the Relational Model (Part I)
Advertisements

Chapter 5: Physical Database Design and Performance
1 Logical Database Design and the Relational Model Modern Database Management.
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.
© 2007 by Prentice Hall 1 Chapter 6: Physical Database Design and Performance Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
Chapter 4: Logical Database Design and the Relational Model
© 2005 by Prentice Hall 1 Chapter 6: Physical Database Design and Performance Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
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
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.
© 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 3: The Enhanced E-R Model
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 The Relational Model (Advanced)
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
© 2005 by Prentice Hall 1 Chapter 6: Physical Database Design and Performance Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
Chapter 6: Physical Database Design and Performance
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 6 Physical Database Design. Introduction The purpose of physical database design is to translate the logical description of data into the technical.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 4: Logical Database Design and the Relational Model Modern Database Management 10.
1 © Prentice Hall, 2002 Physical Database Design Dr. Bijoy Bordoloi.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Concepts and Terminology Introduction to Database.
TM 7-1 Copyright © 1999 Addison Wesley Longman, Inc. Physical Database Design.
Chapter 5: Logical Database Design and the Relational Model
1 © Prentice Hall, 2002 Chapter 6: Physical Database Design and Performance Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
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 COP4540, SCS, FIU Physical Database Design (ch. 16 & ch. 3)
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)
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,
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 6: Physical Database Design and Performance Modern Database Management 9 th Edition.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 5: Physical Database Design and Performance Modern Database Management 9 th Edition Jeffrey.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Logical Database Design and the Relational Model.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
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.
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.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 2: MODELING DATA.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
Lecture 4: Logical Database Design and the Relational Model 1.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Lecture 6: Physical Database Design and Performance Modern Database Management 9 th Edition.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 5: PHYSICAL DATABASE.
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
Physical Database Design
Chapter 5: Logical Database Design and the Relational Model
ITD1312 Database Principles Chapter 5: Physical Database Design
CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE
Chapter 9 Designing Databases
Physical Database Design
Chapter 6: Physical Database Design and Performance
Chapter 5: Logical Database Design and the Relational Model
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited)
Presentation transcript:

Converting ER/EER to logical schema; physical design issues 1

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall TRANSFORMING EER DIAGRAMS INTO RELATIONS Mapping Regular Entities to Relations  Simple attributes: E-R attributes map directly onto the relation  Composite attributes: Use only their simple, component attributes  Multivalued Attribute: Becomes a separate relation with a foreign key taken from the superior entity 2

(a) CUSTOMER entity type with simple attributes Figure 4-8 Mapping a regular entity (b) CUSTOMER relation 3 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

4 (a) CUSTOMER entity type with composite attribute Figure 4-9 Mapping a composite attribute (b) CUSTOMER relation with address detail 4 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 5 Figure 4-10 Mapping an entity with a multivalued attribute One–to–many relationship between original entity and new relation (a) Multivalued attribute becomes a separate relation with foreign key (b)

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall TRANSFORMING EER DIAGRAMS INTO RELATIONS (CONT.) Mapping Weak Entities  Becomes a separate relation with a foreign key taken from the superior entity  Primary key composed of:  Partial identifier of weak entity  Primary key of identifying relation (strong entity) 6

7 Figure 4-11 Example of mapping a weak entity a) Weak entity DEPENDENT 7 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

8 NOTE: the domain constraint for the foreign key should NOT allow null value if DEPENDENT is a weak entity Foreign key Composite primary key Figure 4-11 Example of mapping a weak entity (cont.) b) Relations resulting from weak entity 8 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall TRANSFORMING EER DIAGRAMS INTO RELATIONS (CONT.) 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 with the primary keys of the two entities as its primary key  One-to-One–Primary key on mandatory side becomes a foreign key on optional side 9

10 Figure 4-12 Example of mapping a 1:M relationship a) Relationship between customers and orders Note the mandatory one b) Mapping the relationship Again, no null value in the foreign key…this is because of the mandatory minimum cardinality. Foreign key 10 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

11 Figure 4-13 Example of mapping an M:N relationship a) Completes relationship (M:N) The Completes relationship will need to become a separate relation. 11 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

12 new intersection relation Foreign key Composite primary key Figure 4-13 Example of mapping an M:N relationship (cont.) b) Three resulting relations 12 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

13 Figure 4-14 Example of mapping a binary 1:1 relationship a) In charge relationship (1:1) Often in 1:1 relationships, one direction is optional 13 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

14 b) Resulting relations Figure 4-14 Example of mapping a binary 1:1 relationship (cont.) Foreign key goes in the relation on the optional side, matching the primary key on the mandatory side 14 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall TRANSFORMING EER DIAGRAMS INTO RELATIONS (CONT.) Mapping Associative Entities  Identifier Not Assigned  Default primary key for the association relation is composed of the primary keys of the two entities (as in M:N relationship)  Identifier Assigned  It is natural and familiar to end-users  Default identifier may not be unique 15

16 Figure 4-15 Example of mapping an associative entity a) An associative entity 16 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

17 Figure 4-15 Example of mapping an associative entity (cont.) b) Three resulting relations Composite primary key formed from the two foreign keys 17 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

18 Figure 4-16 Example of mapping an associative entity with an identifier a) SHIPMENT associative entity 18 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

19 Figure 4-16 Example of mapping an associative entity with an identifier (cont.) b) Three resulting relations Primary key differs from foreign keys 19 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall TRANSFORMING EER DIAGRAMS INTO RELATIONS (CONT.) 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 20

21 Figure 4-17 Mapping a unary 1:N relationship (a) EMPLOYEE entity with unary relationship (b) EMPLOYEE relation with recursive foreign key 21 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 22 Figure 4-18 Mapping a unary M:N relationship (a) Bill-of-materials relationships (M:N) (b) ITEM and COMPONENT relations

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall TRANSFORMING EER DIAGRAMS INTO RELATIONS (CONT.) Mapping Ternary (and n-ary) Relationships  One relation for each entity and one for the associative entity  Associative entity has foreign keys to each entity in the relationship 23

24 Figure 4-19 Mapping a ternary relationship a) PATIENT TREATMENT Ternary relationship with associative entity 24 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

25 b) Mapping the ternary relationship PATIENT TREATMENT Remember that the primary key MUST be unique. Figure 4-19 Mapping a ternary relationship (cont.) This is why treatment date and time are included in the composite primary key. But this makes a very cumbersome key… It would be better to create a surrogate key like Treatment#. 25 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall TRANSFORMING EER DIAGRAMS INTO RELATIONS (CONT.) Mapping Supertype/Subtype Relationships  One relation for supertype and for each subtype  Supertype attributes (including identifier and subtype discriminator) go into supertype relation  Subtype attributes go into each subtype; primary key of supertype relation also becomes primary key of subtype relation  1:1 relationship established between supertype and each subtype, with supertype as primary table 26

27 Figure 4-20 Supertype/subtype relationships 27 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

28 Figure 4-21 Mapping supertype/subtype relationships to relations These are implemented as one-to-one relationships. 28 Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE © 2013 Pearson Education, Inc. Publishing as Prentice Hall 29 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall PHYSICAL DATABASE DESIGN  Purpose–translate the logical description of data into the technical specifications for storing and retrieving data  Goal–create a design for storing data that will provide adequate performance and ensure database integrity, security, and recoverability 30

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall DESIGNING FIELDS  Field: smallest unit of application data recognized by system software  Field design  Choosing data type  Coding, compression, encryption  Controlling data integrity 31

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall CHOOSING DATA TYPES 32

33 Figure 5-2 Example of a code look-up table (Pine Valley Furniture Company) Code saves space, but costs an additional lookup to obtain actual value 33 Chapter 5 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall HANDLING MISSING DATA  Substitute an estimate of the missing value (e.g., using a formula)  Construct a report listing missing values  In programs, ignore missing data unless the value is significant (sensitivity testing) 34 Triggers can be used to perform these operations.

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall DENORMALIZATION  Transforming normalized relations into non-normalized physical record specifications  Benefits:  Can improve performance (speed) by reducing number of table lookups (i.e. reduce number of necessary join queries)  Costs (due to data duplication)  Wasted storage space  Data integrity/consistency threats  Common denormalization opportunities  One-to-one relationship (Fig. 5-3)  Many-to-many relationship with non-key attributes (associative entity) (Fig. 5-4)  Reference data (1:N relationship where 1-side has data not used in any other relationship) (Fig. 5-5) 35

36 Figure 5-3 A possible denormalization situation: two entities with one- to-one relationship 36 Chapter 5 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

37 Figure 5-4 A possible denormalization situation: a many-to-many relationship with nonkey attributes Extra table access required Null description possible 37 Chapter 5 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

38 Figure 5-5 A possible denormalization situation: reference data Extra table access required Data duplication 38 Chapter 5 © 2013 Pearson Education, Inc. Publishing as Prentice Hall

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall DENORMALIZE WITH CAUTION  Denormalization can  Increase chance of errors and inconsistencies  Reintroduce anomalies  Force reprogramming when business rules change  Perhaps other methods could be used to improve performance of joins  Organization of tables in the database (file organization and clustering)  Proper query design and optimization 39

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall PARTITIONING  Horizontal Partitioning: Distributing the rows of a logical relation into several separate tables  Useful for situations where different users need access to different rows  Three types: Key Range Partitioning, Hash Partitioning, or Composite Partitioning  Vertical Partitioning: Distributing the columns of a logical relation into several separate physical tables  Useful for situations where different users need access to different columns  The primary key must be repeated in each file  Combinations of Horizontal and Vertical 40

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall PARTITIONING PROS AND CONS  Advantages of Partitioning:  Efficiency: Records used together are grouped together  Local optimization: Each partition can be optimized for performance  Security: data not relevant to users are segregated  Recovery and uptime: smaller files take less time to back up  Load balancing: Partitions stored on different disks, reduces contention  Disadvantages of Partitioning:  Inconsistent access speed: Slow retrievals across partitions  Complexity: Non-transparent partitioning  Extra space or update time: Duplicate data; access from multiple partitions 41

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall RULES FOR USING INDEXES 1. Use on larger tables 2. Index the primary key of each table 3. Index search fields (fields frequently in WHERE clause) 4. Fields in SQL ORDER BY and GROUP BY commands 5. When there are >100 values but not when there are 100 values but not when there are <30 values 42

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall RULES FOR USING INDEXES (CONT.) 6. Avoid use of indexes for fields with long values; perhaps compress values first 7. If key to index is used to determine location of record, use surrogate (like sequence number) to allow even spread in storage area 8. DBMS may have limit on number of indexes per table and number of bytes per indexed field(s) 9. Be careful of indexing attributes with null values; many DBMSs will not recognize null values in an index search 43

Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall RULES FOR USING INDEXES (CONT.) 6. Avoid use of indexes for fields with long values; perhaps compress values first 7. If key to index is used to determine location of record, use surrogate (like sequence number) to allow even spread in storage area 8. DBMS may have limit on number of indexes per table and number of bytes per indexed field(s) 9. Be careful of indexing attributes with null values; many DBMSs will not recognize null values in an index search 44