The Relational Model and Normalization (3) IS 240 – Database Management Lecture #9 2004-02-19 Prof. M. E. Kabay, PhD, CISSP Norwich University

Slides:



Advertisements
Similar presentations
Chapter 16 Unemployment: Search and Efficiency Wages.
Advertisements

Advanced Piloting Cruise Plot.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
The Relational Model and Normalization (1)
Foundations of Relational Implementation (2) IS 240 – Database Management Lecture #14 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Introduction to Database Processing IS 240 – Database Management Lecture #1 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Database Design (1) IS 240 – Database Management Lecture #10 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Foundations of Relational Implementation (1) IS 240 – Database Management Lecture #13 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Application Design (2) Database – IS 240 Lecture #23 – M. E. Kabay, PhD, CISSP Dept of Computer Information Systems Norwich University
Database Design (3) IS 240 – Database Management Lecture #12 – Prof. M. E. Kabay, PhD, CISSP Norwich University
The Relational Model and Normalization (2) IS 240 – Database Management Lecture # Prof. M. E. Kabay, PhD, CISSP Norwich University
DB Application Design (1) IS 240 – Database Management Lecture #16 – Prof. M. E. Kabay, PhD, CISSP Norwich University
1 Copyright © 2004 M. E. Kabay. All rights reserved. Database Design (2) IS 240 – Database Management Lecture #11 – Prof. M. E. Kabay, PhD,
Introduction to Database Development (1) IS 240 – Database Management Lecture #3 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Managing Multi-User Databases (2) IS 240 – Database Management Lecture #19 – Prof. M. E. Kabay, PhD, CISSP Norwich University
SQL IS 240 – Database Management Lecture #15 – Prof. M. E. Kabay, PhD, CISSP Norwich University
E-R Model (1) IS 240 – Database Management Lecture #5 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Managing Multi-User Databases (1) IS 240 – Database Management Lecture #18 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Working with MS-ACCESS IS 240 – Database Management Lecture #2 – Assoc. Prof. M. E. Kabay, PhD, CISSP Norwich University
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 5 Author: Julia Richards and R. Scott Hawley.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Graeme C. Simsion and Graham C. Witt Chapter 4 Subtypes & Supertypes.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
Determine Eligibility Chapter 4. Determine Eligibility 4-2 Objectives Search for Customer on database Enter application signed date and eligibility determination.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Fourth normal form: 4NF 1. 2 Normal forms desirable forms for relations in DB design eliminate redundancies avoid update anomalies enforce integrity constraints.
Relational data objects 1 Lecture 6. Relational data objects 2 Answer to last lectures activity.
1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
Richmond House, Liverpool (1) 26 th January 2004.
Copyright © Cengage Learning. All rights reserved.
Information Systems Today: Managing in the Digital World
Data Structures: A Pseudocode Approach with C
ABC Technology Project
3 Logic The Study of What’s True or False or Somewhere in Between.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
1 Undirected Breadth First Search F A BCG DE H 2 F A BCG DE H Queue: A get Undiscovered Fringe Finished Active 0 distance from A visit(A)
VOORBLAD.
1. 2 No lecture on Wed February 8th Thursday 9 th Feb 14: :00 Thursday 9 th Feb 14: :00.
Quadratic Inequalities
the Entity-Relationship (ER) Model
© 2012 National Heart Foundation of Australia. Slide 2.
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
Lecture plan Outline of DB design process Entity-relationship model
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Chapter 5 Test Review Sections 5-1 through 5-4.
Functional Dependencies and Normalization for Relational Databases
Addition 1’s to 20.
25 seconds left…...
Copyright © Cengage Learning. All rights reserved.
Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques
Week 1.
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Chapter 15 A Table with a View: Database Queries.
PSSA Preparation.
Immunobiology: The Immune System in Health & Disease Sixth Edition
Chapter 11 Describing Process Specifications and Structured Decisions
How Cells Obtain Energy from Food
Immunobiology: The Immune System in Health & Disease Sixth Edition
Presentation transcript:

The Relational Model and Normalization (3) IS 240 – Database Management Lecture # Prof. M. E. Kabay, PhD, CISSP Norwich University

2 Copyright © 2004 M. E. Kabay. All rights reserved. Topics Domain-Key Normal Form Going from Attributes to Relations Database Optimization Next Class – Review to Date Homework Note: Your handouts are 3 per page today because you should take lots of notes during the class – this is critically important material

3 Copyright © 2004 M. E. Kabay. All rights reserved. Domain-Key Normal Form Definition A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains. Constraint Any rule about attributes that can be judged true or false given the data at hand Constraints may not include time- dependent data; e.g., This months sales figures must be greater than last months

4 Copyright © 2004 M. E. Kabay. All rights reserved. DK/NF (contd) Key: Unique identifier of a tuple (row, record) Domain: two descriptions Physical description: The list of all allowed values of an attribute (column, field); e.g., Invoice_number begins with a 4-digit number indicating the year and terminates with a 4-digit number from 0000 to 9999 indicating the sequence number in the list of invoices for that year. Logical description: The meaning of the attribute in business terms: e.g., Invoice_number is the unique identifier for an invoice. A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

5 Copyright © 2004 M. E. Kabay. All rights reserved. DK/NF (contd) There is no algorithm known for converting relations to DK/NF Use intuition and practice Process for putting a relation into DK/NF: Define relations so that every constraint follows logically from the choice of keys and domains. Kroenke gives 3 examples pp STUDENT PROFESSOR STUDENT_ADVISOR A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

6 Copyright © 2004 M. E. Kabay. All rights reserved. Another Example: Rock Music Database College radio station wants to keep track of all the rock music played on air to answer questions such as When was the last time we played this cut? This CD? This band? On which show? Which DJ played it? How often have we played this cut / CD / band in the last period on show? Any show? What bands has a particular musician played with? What albums do we have from a particular band? What albums does a particular musician play on? What cuts does a particular musician play on?

7 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) Entities: Musician Band Album Cut DJ Show A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

8 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) Musician Artist_Name Birth_Date Death_Date Biographical_Notes A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

9 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) Band_Name Date_Formed Date_Disbanded Date_Artists_Changed?? Band_Notes A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

10 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) Album Album_Name Album_ID Date_Released Total_Minutes Number_Cuts A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

11 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) Cut Cut_Name Album_ID Cut_Minutes A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

12 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) DJ DJ_ID DJ_Name DJ_Joined DJ_Left DJ_Notes A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

13 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) Show Show_Name Show_Date Show_Time DJ_ID A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

14 Copyright © 2004 M. E. Kabay. All rights reserved. Music DB (contd) Relations M:N MusicianBandAlbumCut M:N DJShow 1:NM:N Relational links: Musician_Band Band_Album Album_Cut Cut_Show DJ_Show Basic Entities: Musician Band Album Cut DJ Show M:N MusicianBand

15 Copyright © 2004 M. E. Kabay. All rights reserved. Going from Attributes to Relations 1:1 Relationships N:1 Relationships M:N Relationships Multi-value Dependencies

16 Copyright © 2004 M. E. Kabay. All rights reserved. 1:1 Relationships A B and B A then A:B::1:1 Student_ID SSN (in theory) SSN Student ID A uniquely identifies X and B uniquely identifies X then A:B::1:1 Student_ID DNA_Fingerprint SSN DNA_Fingerprint Then Student_ID SSN and SSN Student_ID Therefore Student_ID:DNA_Fingerprint::1:1 A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

17 Copyright © 2004 M. E. Kabay. All rights reserved. 1:1 Relationships Put 1:1 attributes in the same relation at least once in the database Any other attributes that are determined by either of the original attributes may be added to that relation E.g., Student_ID, SSN, Student_Name, Student_Home_Address, Student_Etc. A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

18 Copyright © 2004 M. E. Kabay. All rights reserved. N:1 Relationships If A B but NOT B A, then A:B::N:1 E.g., suppose a DJ may host several shows but a show has only one DJ; Then Show DJ but not DJ Show For DK/NF, all constraints are defined by keys Therefore every determinant must be a key E.g., the relation DJ_SHOW has SHOW as a key but not DJ Why? A relation is in DK/NF if every constraint on the relation is a logical consequence of keys and domains.

19 Copyright © 2004 M. E. Kabay. All rights reserved. M:N Relationships If neither A B nor B A, then A:B::M:N Therefore both attributes must be a compound key Why? May add attributes that are determined by (A,B) E.g., for Cut_Show, where any cut can be on any show, one would add Date_Played and Time_Played, which are functionally dependent on Cut and Show Do not add attributes that are dependent on only one of the parts of the key E.g, would not add Album_Name, which depends on Cut and Band, neither of which is determined by (Cut_Show)

20 Copyright © 2004 M. E. Kabay. All rights reserved. Multi-value Dependencies When analyzing M:N relations, think about themes as the purpose for a relation Do not mix themes E.g., in rock-music DB, Would be a mistake to put detailed information about cuts into the Album relation Why?

21 Copyright © 2004 M. E. Kabay. All rights reserved. Database Optimization Normalization is not an absolute Normalization is a technique to avoid difficulties Can be reversed when appropriate Useful For specific purposes De-Normalization Violating some of the principles of normalization for a good reason Controlled Redundancy May be useful for performance reasons

22 Copyright © 2004 M. E. Kabay. All rights reserved. De-Normalization Think about DJ relation DJ_ID, DJ_Name, DJ_Joined, DJ_Left, DJ_Notes Theoretically, a DJ could leave and join several times Thus we might break the relation into two parts: DJ_ID, DJ_Name, DJ_Notes DJ_ID, DJ_Joined, DJ_Left However, these events may be rare enough that we dont get much benefit from the normalization – waste of effort

23 Copyright © 2004 M. E. Kabay. All rights reserved. Controlled Redundancy Notice the Album and Cut relations in the rock-music DB Album contains Total_Minutes Cut contains Cut_Minutes Why bother having the Total_Minutes field in the Album dataset? Could easily compute total from list of all the cuts in the album So whats the advantage of keeping this computed field in the Album dataset?

24 Copyright © 2004 M. E. Kabay. All rights reserved. Review to Date Tue 25 February 2003 Review of all the material we have discussed in Chapters 1, 2, 3, and 5 Come prepared to answer questions round- robin (every student answers a question in turn) Remember that your mid-term, take-home exam will be distributed on Thursday the 27 th of Feb.

25 Copyright © 2004 M. E. Kabay. All rights reserved. Homework Finish studying Chapter 5 in detail Review all the material in Chapters 1, 2, 3, & 5 REQUIRED: For submission at the start of class On Thursday 27 th of February, Complete Group 1 questions 5.18 to 5.26 for 9 points total

26 Copyright © 2004 M. E. Kabay. All rights reserved. DISCUSSION