Developing Data Models – Conversion Rules

Slides:



Advertisements
Similar presentations
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Advertisements

The Relational Database Model – some relations you might want to avoid!!!
Entity Relationship (ER) Modeling
The Relational Database Model
C ONVERTING ERD S TO R ELATIONAL T ABLES Joe Meehean 1.
Chapter 5 Understanding Entity Relationship Diagrams.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
Relational Model Stores data as tables –Each column contains values about the same attribute –Each column has a distinct name –Each row contains values.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Understanding Entity Relationship Diagrams.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Developing Data Models for Business Databases.
FIS 431/631 Financial Information Systems: Analysis and Design ERD & Normalization Joe Callaghan Oakland University Department of Accounting & Finance.
Chapter 9 Advanced Query Formulation with SQL. Outline Outer join problems Type I nested queries Type II nested queries and difference problems Nested.
Chapter 6 Developing Data Models for Business Databases.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 3 The Relational Data Model.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Class Agenda – 04/04/2006 Discuss database modeling issues
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Developing Data Models for Business Databases (Part II)
DATA MODELING AND DATABASE DESIGN
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Copyright © 2011 by Michael V. Mannino All rights reserved. Database Design, Application Development, and Administration, 5 th Edition Chapter 3 The Relational.
Chapter 2 The Relational Data Model. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Relational model basics Integrity.
Database Design, Application Development, and Administration, 5 th Edition Copyright © 2011 by Michael V. Mannino All rights reserved. Chapter 6 Developing.
Chapter 9 Advanced Query Formulation with SQL. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Outer join problems.
Database Design – Lecture 5 Conceptual Data Modeling – adding attributes.
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 Sections 11 Database relationship, Integrity, keys, mapping conceptual model to logical/physical model Previous Section 12 – DDLesson11Fa12.ppt.
Database Design Sections 11 & 12 drawing conventions, generic model, integrity, keys, mapping conceptual model to logical/physical model.
Relational Theory and Design
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Lecture 3 Book Chapter 3 (part 2 ) From ER to Relational.
Copyright © 2011 by Michael V. Mannino All rights reserved. Database Design, Application Development, and Administration, 5 th Edition Quiz G4 Hyunwoo.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
Howard Paul. Sequential Access Index Files and Data File Random Access.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
Ch 05. Basic Symbols ( manino ). Cardinalities Cardinality Notation.
Week 2 Lecture The Relational Database Model Samuel ConnSamuel Conn, Faculty Suggestions for using the Lecture Slides.
Chapter 5 Understanding Entity Relationship Diagrams.
Database Design, Application Development, and Administration, 6 th Edition Copyright © 2015 by Michael V. Mannino. All rights reserved. Chapter 5 Understanding.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Chapter 2 The Relational Data Model. Outline Relational model basics Integrity rules Rules about referenced rows Relational Algebra.
CSIS 115 Database Design and Applications for Business
Chapter 5 Database Design
Tables and Their Characteristics
Database Design – Lecture 4
CIS 207 The Relational Database Model
Lecture # 13 (After 1st Exam)
Figure Specialization Hierarchy
COS 346 Day 8.
From ER to Relational Model
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
Database Systems: Design, Implementation, and Management Tenth Edition
Session 2 Welcome: The seventh learning sequence
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Systems Instructor Name: Lecture-9.
Database Systems Instructor Name: Lecture-10.
Database Design: Relational Model
DBMS ER-Relational Mapping
Mapping an ERD to a Relational Database
Entity Relationship (ER) Modeling
Chapter # 4 Entity Relationship (ER) Modeling.
Mapping an ERD to a Relational Database
Presentation transcript:

Developing Data Models – Conversion Rules Welcome to Chapter 6 on developing data models for business databases - Extends your knowledge of the notation of ERDs - Data modeling practice on narrative problems - Convert from ERD to table design - Data modeling is challenging - Ambiguity: part science, part art - Opportunity for some creative problem solving Objectives: - Data modeling practice: - Strategies for analyzing a narrative problem - Transformations for considering alternative designs - Avoidance of common design errors - Master data modeling with lots of practice - Apply conversion rules to transform ERD into a table design

Summary of Basic Conversion Rules Each entity type becomes a table. Each 1-M relationship becomes a foreign key in the table corresponding to the child entity type (the entity type near the crow’s foot symbol). Each M-N relationship becomes an associative table with a combined primary key. Each identifying relationship adds a column to a primary key. For more details see textbook Chapter 6 (section 6.4.1) Apply rules in order: all applications of rule 1, then rule 2, then rule 3, and rule 4. Second rule: fundamental difference between models M-N relationship becomes an associative table with a combined PK.

Application of Basic Rules (I) Entity type rule: - Two applications - Convert PK and attributes in the table 1-M relationship rule: - 1 application - Offering.CourseNo becomes a FK in the child (M) table (Offering) CREATE TABLE Course (… PRIMARY KEY (CourseNo) ) CREATE TABLE Offering (… PRIMARY KEY OfferNo, FOREIGN KEY (CourseNo) REFERENCES Course )

Application of Basic Rules (II) CREATE TABLE Enrollment (… PRIMARY KEY (StdSSN, OfferNo), FOREIGN KEY (StdSSN) REFERENCES Student, FOREIGN KEY OfferNo REFERENCES Offering ) Enrolls_In conversion: - Enrollment table: name change not necessary; use noun for table name - Foreign keys: StdSSN and OfferNo

Application of Basic Rules (III) Conversion process: - Entity type rule: 3 applications - 1-M relationship rule: 2 applications (FKs in the Enrollment table) - Identifying relationship rule: 2 applications - Each application of the identifying relationship rule adds a PK component Same conversion result as the previous slide Different application of rules

Generalization Hierarchy Rule Mimic generalization hierarchy as much as possible Each subtype table contains specific columns plus the primary key of its parent table. Foreign key constraints for subtype tables CASCADE DELETE option for referenced rows Reduce need for null values Need joins and outer joins to combine tables Generalization hierarchy rule: - Simulate generalization hierarchy with tables and foreign keys - Minimize null values in the tables - Little redundancy except for PK: repeated for each subtype table - CASCADE DELETE: delete parent, automatically delete rows in subtype tables Combining tables: - Join: combine table and all of its parent tables - Full Outer join: combine a table with its sibling tables Other conversion possibilities: - One table: many null values but no need for join and outer join operations - Combine some subtype tables: fewer tables, more nulls, fewer join and outer joins

Generalization Hierarchy Example CASCADE DELETE for Foreign Keys - SalaryEmp - HourlyEmp Employee table: EmpNo (PK) SalaryEmp table: EmpNo (PK), EmpNo (FK) HourlyEmp table: EmpNo (PK), EmpNo (FK)

Optional 1-M Rule Separate table for each optional 1-M relationship Avoids null values Requires an extra table and join operation Controversial: in most cases 1-M rule is preferred Optional 1-M relationship: - Relationship in which min cardinality is 0 - No existence dependency - Offering-Faculty: offering can be stored without a faculty assigned - Order-Employee: order can be stored without an employee (internet order) Rule: - Optional 1-M relationship becomes a table instead of just a FK in the M table - Avoids null values - Adds another table and join operation to combine - Rule is controversial - Rule is not necessary - 1-M relationship rule is more widely used for optional 1-M relationships

Optional 1-M Example Other conversion: - Faculty table - Offering table: no FK Teaches conversion: - Teaches table - OfferNo: PK - FacSSN: FK - No null values: Teaches only contains rows for Offerings with assigned faculty CREATE TABLE Teaches (… PRIMARY KEY (OfferNo) , FOREIGN KEY(OfferNo) REFERENCES Offering, FOREIGN KEY(FacSSN) REFERENCES Faculty )

1-1 Relationships 1-1 relationships: not common Use FKs in each mandatory 1-1 relationship: - Can also use for optional 1-1 relationship but will have null values - Office must have an employee: use FK in Office - Employee must be assigned to an office: use FK in Employee UNIQUE constraint: - FK is unique because of the 1-1 relationship - The same employee can be assigned to only one office. CREATE TABLE Office (… PRIMARY KEY (OfficeNo) , FOREIGN KEY(EmpNo) REFERENCES Employee, UNIQUE (EmpNo) )