DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 COS 346 Day 8.

Slides:



Advertisements
Similar presentations
Database Lecture Notes Mapping ER Diagrams to Tables 2 Dr. Meg Murray
Advertisements

(wrapping up from last week)
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 5/1 Copyright © 2004 Please……. No Food Or Drink in the class.
Entity-Relationship Model
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 6.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 8.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke’s Chapter Three: The Relational Model and Normalization.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the ER Model.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 9.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 COS 346 Day 11.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke Database Processing Chapter 6 Transforming Data.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 COS 346 Day 11.
Prentice Hall © COS 346 Day Agenda Questions? Assignment 7 Corrected –4 A’s and 4 B’s Assignment 8 posted –Due April 6 Quiz 2 next class.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 COS 346 Day 10.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 10.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 COS 346 Day 7.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 7.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 8.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 17.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 8.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 6.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 Strong Entity Patterns: 1:1 Strong Entity Relationships.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 9.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the Entity-Relationship.
Database Design Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition.
Database Design Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Entity-Relationship Model
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 7.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 7.
Transforming Data Models into Database Designs
Chapter 3 The Relational Model and Normalization
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the Entity-Relationship.
KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall 5-1 Chapter Objectives Learn how to transform E-R data models into relational.
Chapter Six Professor Adams’ Slides. Note that entities are shadowed, tables are not. Note that entities have no physical existence (blueprint) Note.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Six: Transforming Data Models into Database Designs.
Database Design IST210 Class Lecture
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
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 Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 What Makes Determinant Values Unique? A determinant is unique in.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
Gegevens Analyse Les 5: van ERD naar DSD.
1 SY306: Web and Databases for Cyber Operations Slide Set: 11 Databases - 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.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the Entity-Relationship.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the Entity-Relationship.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Six: Transforming Data Models into Database Designs.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Three: The Relational Model and Normalization.
Chapter Six: Transforming Data Models into Database Designs 6-1.
Database Processing: David M. Kroenke’s Chapter Five:
Chapter 5 Database Design
Chapter 4: Logical Database Design and the Relational Model
Transforming Data Models
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
COS 346 Day 8.
Transforming Data Models into Database Designs
Database Processing: David M. Kroenke’s Chapter Five:
Database Processing: David M. Kroenke’s Chapter Six:
Database Processing: David M. Kroenke’s Chapter Three:
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Processing: David M. Kroenke’s Chapter Six:
Database Processing: David M. Kroenke’s Chapter Five:
Database Processing: David M. Kroenke’s Chapter Six:
Database Processing: David M. Kroenke’s Chapter Six:
Presentation transcript:

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 COS 346 Day 8

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-2 Agenda Questions? Assignment Two Corrected –1 A, No B’s, 5 C’s, 3 D’s –We will cover the assignment in class Assignment 3 posted –Due Feb 16 –Use VISIO Assignment 4 will be posted next Class AMD WILL Due Feb 23 Start Thinking about a Capstone Project –Must be a database project Quiz 1 –Feb 23 –DP Chap 1-6, SQL Chap 1 & 2 –20 M/C and 5 Short Essay Transforming Data Models into Database Designs

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-3 Assignment 2 Explain the conditions under which each of the following are true: 1.Phone  (FirstName, LastName) 2.(Phone, FirstName)  LastName 3.(Phone, LastName)  FirstName 4.(LastName, FirstName)  Phone 5.Phone  LastName 6.Phone  FirstName 7.Phone  (FirstName, LastName) Is condition 7 the same as conditions 5 and 6? Why or why not?

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-4 Assignment 2 Consider the tables: CUSTOMER (Phone, FirstName, LastName) ORDER (OrderNumber, DateIn, DateOut, Phone) State an appropriate referential integrity constraint. Consider the tables: CUSTOMER (Phone, FirstName, LastName) ORDER (OrderNumber, DateIn, DateOut, FirstName, LastName) What does the following referential integrity constraint mean? ORDER (FirstName, LastName) must be in CUSTOMER (FirstName, LastName) Is this constraint the same as: ORDER (FirstName) must be in CUSTOMER (FirstName) and ORDER. (LastName) must be in CUSTOMER (LastName) Explain why or why not.

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-5 Assignment 2 Do you prefer the design in B or the design in C? Explain your reasoning B. CUSTOMER (Phone, FirstName, LastName) ORDER (OrderNumber, DateIn, DateOut, Phone) C CUSTOMER (Phone, FirstName, LastName) ORDER (OrderNumber, DateIn, DateOut, FirstName, LastName) Transform the following table into two or more tables in BCNF and 4NF. Indicate the primary keys, candidate keys, foreign keys, and referential integrity constraints. Make and state assumptions as necessary. ORDER (CustomerNumber, FirstName, LastName, Phone, OrderNumber, DateIn, DateOut, ItemType, Quantity, ItemPrice, ExtendedPrice, SpecialInstructions)

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-6 Assignment 2 Explain how your answer to question E changes depending on whether you assume CustomerNumber  (FirstName, LastName) or CustomerNumber  (FirstName, LastName)

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-7 David M. Kroenke’s Chapter Six: Transforming Data Models into Database Designs Part One Database Processing: Fundamentals, Design, and Implementation

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-8 Steps for Transforming a Data Model into a Database Design

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-9 Create a Table for Each Entity EMPLOYEE (EmployeeNumber, EmployeeName, Phone, , HireDate, ReviewDate, EmpCode) Note shadowless table Primary key is designated by key symbol

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-10 Select the Primary Key The ideal primary key is short, numeric and fixed Surrogate keys meet the ideal, but have no meaning to users

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-11 Specify Candidate (Alternate) Keys The terms candidate key and alternate key are synonymous Candidate keys are alternate identifiers of unique rows in a table ERwin uses AKn.m notation, where n is the number of the alternate key, and m is the column number in that alternate key

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-12 Specify Candidate (Alternate) Keys

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-13 Specify Column Properties: Null Status Null status indicates whether or not the value of the column can be NULL

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-14 Specify Column Properties: Data Type Generic Data Types: –CHAR(n) –VARCHAR(n) –DATE –TIME –MONEY –INTEGER –DECIMAL

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-15 Specify Column Properties: SQL Server Data Types

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-16 Specify Column Properties: Oracle Data Types

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-17 Specify Column Properties: Default Value A default value is the value supplied by the DBMS when a new row is created

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-18 Specify Column Properties: Data Constraints Data constraints are limitations on data values: –Domain constraint - Column values must be in a given set of specific values –Range constraint - Column values must be within a given range of values –Intrarelation constraint – Column values are limited by comparison to values in other columns in the same table –Interrelation constraint - Column values are limited by comparison to values in other columns in other tables [Referential integrity constraints on foreign keys]

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-19 Verify Normalization The tables should be normalized based on the data model Verify that all tables are: –BCNF –4NF

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-20 Create Relationships: 1:1 Strong Entity Relationships Place the key of one entity in the other entity as a foreign key: –Either design will work – no parent, no child –Minimum cardinality considerations may be important: O-M will require a different design that M-O, and One design will be very preferable

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-21 Create Relationships: 1:1 Strong Entity Relationships

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-22 Create Relationships: 1:N Strong Entity Relationships Place the primary key of the table on the one side of the relationship into the table on the many side of the relationship as the foreign key The one side is the parent table and the many side is the child table, so “Place the key of the parent in the child”

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-23 Create Relationships: 1:N Strong Entity Relationships

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-24 Create Relationships: N:M Strong Entity Relationships In an N:M strong entity relationship there is no place for the foreign key in either table: –A COMPANY may supply many PARTs –A PART may be supplied by many COMPANYs

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-25 Create Relationships: N:M Strong Entity Relationships The solution is to create an intersection table that stores data about the corresponding rows from each entity The intersection table consists only of the primary keys of each table which form a composite primary key Each table’s primary key becomes a foreign key linking back to that table COMPANY_PART_INT (CompanyName, PartNumber)

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-26 Create Relationships: N:M Strong Entity Relationships COMPANY_PART_INT (CompanyName, PartNumber)

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-27 David M. Kroenke’s Database Processing Fundamentals, Design, and Implementation (10 th Edition) End of Presentation: Chapter Six Part One

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-28 COS 346 Day 9

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-29 Agenda Questions? Assignment 3 posted –Due Today Assignment 4 is posted –Due Feb 23 Start Thinking about a Capstone Project –Must be a database project Quiz 1 –Feb 23 –DP Chap 1-6, SQL Chap 1 & 2 –20 M/C and 5 Short Essay Transforming Data Models into Database Designs

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-30 David M. Kroenke’s Chapter Six: Transforming Data Models into Database Designs Part Two Database Processing: Fundamentals, Design, and Implementation

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-31 Relationships Using ID-Dependent Entities: Four Uses for ID-Dependent Entities Representing N:M Relationships –We just discussed this Association Relationships Multivalued Attributes Archtype/Instance Relationships

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-32 Relationships Using ID-Dependent Entities: Association Relationships An intersection table: –Holds the relationships between two strong entities in an N:M relationship –Contains only the primary keys of the two entities: As a composite primary key As foreign keys An association table: –Has all the characteristics of an intersection table –PLUS it has one or more columns of attributes specific to the associations of the other two entities

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-33 Relationships Using ID-Dependent Entities: Association Relationships QUOTATION (CompanyName, PartNumber, Price)

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-34 Relationships Using ID-Dependent Entities: Multivalued Attributes As a data model As a set of tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-35 Relationships Using ID-Dependent Entities: Archetype/Instance Pattern As a data model As a set of tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-36 Relationships Using Weak Entities: Archetype/Instance Pattern As a data model As a set of tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-37 Mixed Entity Relationships: The Line-Item Pattern As a data model

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-38 Mixed Entity Relationships: The Line-Item Pattern As a set of tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-39 Mixed-Entity Relationships As a data model As a set of tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-40 Subtype Relationships As a data model As a set of tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-41 Recursive Relationships: 1:1 Recursive Relationships As a data model As a table

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-42 Recursive Relationships: 1:N Recursive Relationships As a data model As a table

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-43 Recursive Relationships: N:M Recursive Relationships As a data model As a set of tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-44 Representing Ternary and Higher- Order Relationships Ternary and higher-order relationships may be constrained by the binary relationship that comprise them: –MUST constraint - Requires that one entity must be combined with another entity in the ternary (or higher- order) relationship –MUST NOT constraint - Requires that certain combinations of two entities are not allowed to occur in the ternary (or higher-order) relationship –MUST COVER constraint – A binary relationship specifies all combinations of two entities that must appear in the ternary (or higher-order) relationship

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-45 MUST Constraint

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-46 MUST NOT Constraint

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-47 MUST COVER Constraint

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-48 HighLine University

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-49 HighLine University

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-50 Design for Minimum Cardinality 4 possibilities –O-O FK = null allowed Do nothing! –O-M –M-O –M-M

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-51 When Parent =M

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-52 When Child = M

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-53 Actions to apply

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-54 Minimum Cardinality

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-55 Minimum Cardinality

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-56 View Ridge

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-57 View Ridge

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-58 View Ridge

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-59 View Ridge

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-60 David M. Kroenke’s Database Processing Fundamentals, Design, and Implementation (10 th Edition) End of Presentation: Chapter Six Part Two