1 CMPT 275 Phase: Design. Janice Regan, 2008 2 Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces Data Persistance.

Slides:



Advertisements
Similar presentations
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Advertisements

Normalization Rules for Database Tables
 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
1 Class Agenda (04/03 and 04/08)  Review and discuss HW #8 answers  Present normalization process Enhance conceptual knowledge of database design. Improve.
Accounting 6500 Relational Databases: Accounting Applications Introduction to Normalization.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
The Relational Database 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.
Normalization I.
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
Normalization A337. A337 - Reed Smith2 Structure What is a database? ◦ Tables of information  Rows are referred to as records  Columns are referred.
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
Chapter 5 Normalization of Database Tables
Normalization. Introduction Badly structured tables, that contains redundant data, may suffer from Update anomalies : Insertions Deletions Modification.
Normalization of Tables “Between two evils, choose neither; between two goods, choose both.” Tryon Edwards.
Week 6 Lecture Normalization
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 3 Objectives: Identifying and Eliminating Database.
1 Class Agenda (04/09 through 04/16)  Review HW #8  Present normalization process Enhance conceptual knowledge of database design. Improve practical.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
1 Class Agenda (11/07 and 11/12)  Review HW #8 answers  Present normalization process Enhance conceptual knowledge of database design. Improve practical.
Functional Dependence An attribute A is functionally dependent on attribute(s) B if: given a value b for B there is one and only one corresponding value.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Concepts and Terminology Introduction to Database.
Normalization. 2 Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various types of update anomalies.
Database Systems: Design, Implementation, and Management Tenth Edition
Concepts of Database Management, Fifth Edition
A Normalisation Example Mark Kelly McKinnon Secondary College Vceit.com Based on work by Robert Timmer-Arends.
Normalization. We will take a look at –First Normal Form –Second Normal Form –Third Normal Form There are also –Boyce-Codd, Fourth and Fifth normal forms.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Database Normalization Lynne Weldon July 17, 2000.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
Normalization Transparencies
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
MS Access: Creating Relational Databases Instructor: Vicki Weidler Assistant: Joaquin Obieta.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
M1G Introduction to Database Development 4. Improving the database design.
Lecture 5 Normalization. Objectives The purpose of normalization. How normalization can be used when designing a relational database. The potential problems.
Chapter 10 Normalization Pearson Education © 2009.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Normalization Transparencies 1. ©Pearson Education 2009 Objectives How the technique of normalization is used in database design. How tables that contain.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
Database Design Normalisation. Last Session Looked at: –What databases were –Where they are used –How they are used.
A337 - Reed Smith1 Structure What is a database? –Table of information Rows are referred to as records Columns are referred to as fields Record identifier.
Lecture Nine: Normalization
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Normalization Example. Database Systems, 8 th Edition 2 Database Tables and Normalization Normalization –Process for evaluating and correcting table structures.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
1 Class Agenda (04/06/2006 and 04/11/2006)  Discuss use of Visio for ERDs  Learn concepts and ERD notation for data generalization  Introduce concepts.
Logical Database Design and the Relational Model.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Lecture 4: Logical Database Design and the Relational Model 1.
Normalization. Overview Earliest  formalized database design technique and at one time was the starting point for logical database design. Today  is.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Normalization ACSC 425 Database Management Systems.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
Database Planning Database Design Normalization.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Dr Gordon Russell, Napier University Normalisation 1 - V2.0 1 Normalisation 1 Unit 3.1.
Normalization.
INLS 623 – Database Normalization
Functional Dependencies
Example Question–Is this relation Well Structured? Student
Entity relationship diagrams
Normalization A337.
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
DATABASE DESIGN & DEVELOPMENT
Database Normalization.
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

1 CMPT 275 Phase: Design

Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces Data Persistance Subsystem User Manual architecture LOW LEVEL DESIGN Classes Class Interfaces Interaction Diagrams Implementation

3 Implementation issues related to Data Persistence NORMALIZATION

Janice Regan, Relational DB Design  We will structure our relational database table(s) using Normalization  process of assigning attributes to tables  series of stages called Normal Forms  1 st normal form: fixed length records  2 nd normal form: remove partial dependencies  3 rd normal form: remove transitive dependencies

Janice Regan, Relational DB Design  We will structure our relational database table(s) using Normalization  Advantage:  assures equal length records  reduces data redundancies hence helps eliminate problems that result from redundancies  Disadvantage:  decrease performance as we normalize to higher forms, higher forms require more tables

Janice Regan, An example…  To illustrate how to normalize, we shall use the example of a Student Registration System. Here are some requirements: 1. For each student, we need to remember: student-id, name, address, phone, courses 2. For each of the course taken, must remember: credit, semester, grade, room, instructor’s office, instructor.

Janice Regan, An example…  To illustrate how to normalize, we shall use the example of a Student Registration System. Here are some requirements: 3. Students can repeat same course in a later semester 4. There is only one offering a a given course in a semester 5. For each of the course attempted, must remember: semester, grade, room, instructor, instructor's office

Janice Regan, OO Classes: Class diagram StudentCourse offering Receives a grade for takes Student ID name address phone Course name semester room Instructor Instructor’s office List of courses List of students 0..* Course Name credit 0..* 1 List of grades

Janice Regan, Our First Table  From our requirements, we could create the following database table: (horizontal lines separate records, representing single student objects) Instructor’s office Std-id Std-nameStd-address Std-phone CoursenameSem Grade Credit Room Instructor Paul K. Will B. Kim L. Xiao T. Brook St., Bby Elf Ave., Van. Mer Cr., Poco Alpha St., Bby Cmpt 101 Cmpt 150 Bus 152 Engl 102 Biol 234 Cmpt C- B A- A+ B+ D A AQ2 AQ1 ASB WM EDC AQ1 AQ2 ASB985 ASB352 WM543 AQ834 EDC243 ASB985 ASB111 Dr. Klaus M. Nole V. Karu W. Loti Dr. Quel Dr. Klaus Dr. Yu Each record is uniquely identified by the student number (Std-id). The primary key for the table is therefore Std-id. This table is unnormalized (contains records of varying length)

Janice Regan,  So far, attributes are in an unnormalized form.  Objects, transformed into DB records, will not all be of same length. Each record contains all information about one student. student-id name address phone course credit semester grade room instructor instructor’s office Group of attributes repeated each time a particular course is attempted by 1 student Group of attributes repeated for each course taken by 1 student Our First Table: Is there a problem? NOT ALL RECORDS ARE OF THE SAME LENGTH !!

Janice Regan, What is the problem?  Problem: attributes that are lists (multiple courses per student, multiple attempts per course) do not produce fixed length records  Solution: remove lists by adding additional rows one to hold each attribute in the list  Consider the example: for a student, have 1 complete row per course attempted/taken  This results in a table in First Normal Form

Janice Regan, First Normal Form  Definition of First Normal Form (1NF):  Tables do not have repeating groups, i.e., each row/column intersection can contain one and only one value, not a set of values.  All the key attributes are defined, no blank (null) values of keys are permitted

Janice Regan, Our example Defining primary key attributes  Which attributes are needed to assure each record is uniquely identified  Std-Id is not enough  a student can take multiple courses  Std-id and course name is not enough  a student can take the same course more than once if they wish  Std-id, course name and semester is enough  Each time the student takes a course it is uniquely identified as a single record in the table

Janice Regan, Std-phone First Normal Form of Table (1NF) Std-id Std-name Std-address Course-nameSemester Grade Credit Room Instructor Instructor’s office Paul K. Will B. Kim L.Xiao T. Brook St., Bby Elf Ave., Van. Merry Cr., Poco Alpha St., BBY Alpha St., Bby Cmpt 101 Cmpt 150 Bus 152 Engl 102 Biol 234 Cmpt C- B A- A+ B+ D A AQ2 AQ1 ASB WM EDC AQ1 AQ2 ASB985 ASB352 WM543 AQ834 EDC243 ASB 985 ASB111 Dr. Klaus M. Nole V. Karu W. Loti Dr. Quel Dr. Klaus Dr. Yu  Result: Single table with compound (multi-attribute) primary key.  Primary Key: each row uniquely identified by one single attribute  Compound Primary Key: each row uniquely identify by a or group of attributes  The compound primary key for the above table is: Std-id, Course-name, Semester

Janice Regan, Is there still a problem? Y es!  Our table in First Normal Form could still contain data redundancies due to partial dependencies.  Partial dependencies are based only on a part of the compound primary key.  Consider an attribute A, that is dependent on the compound primary key K  If A is dependent on all components of the compound primary key the A is fully dependent on K  If A is dependent on some but not all of the components of the primary key then A is partially dependent on K

Janice Regan, Redundancy: Examples + problems  Examples of redundancy and partial dependence:  For each course a student takes the student’s name, address and phone number are repeated. A student’s name and address are dependent on the student’s id but not on the course name or semester  For each course a student repeats the course credit is repeated. The course credit is dependent on the course name but not the student’s id or the semester

Janice Regan, Problems related to Redundancy  Redundancy  Insert anomalies: e.g. Each time a student takes a course the student information must be entered, this adds to the potential for error  Delete anomalies: if delete the row where info about Std-id is stored will also delete info that cannot be found anywhere else in DB table namely that Dr. Quel’s office is EDC243  Update problems: because of redundant data, if a student moves, need to change student's address in all rows corresponding to every instance of every course the student had ever taken. Problems occur if one occurrence is missed or an error is made in one occurrence

Janice Regan, Partial Dependencies  Definition: non-key attribute(s) dependent on only some of primary key(s)  Examples:  Phone #, Std-name, and address depend only on Std- id (not course name or semester)  Credit depends only on course name (not on Std-id or semester)  Instructor, Instructor’s office, room, and grade depend on course and semester (not Std-id)

Janice Regan, Partial Dependencies  Definition: non-key attribute(s) dependent on only some of primary key(s)  When an attribute is only partially dependent on the primary keys of the table there may be redundant occurrences of that attribute in the table  Therefore, To remove redundancies we should remove partial dependencies

Janice Regan, Problem with 1NF  non-key attribute(s) may depend on some but not all of the primary key(s)  e.g.: primary keys are Std_id, Course- name and semester address depends only on Std-id

Janice Regan, From 1NF to 2NF  Solution: Remove partial dependencies  Determine if there are any partial dependencies.  If so, divide 1NF table into several tables such that in each table each non-primary key attribute is dependent on only the primary key (or compound primary key) of that table.  Note that if primary key of 1NF table is not a compound primary key, there cannot be partial dependencies and hence the 1NF table is already in 2NF.

Janice Regan, Second Normal Form - Example Transform our 1NF table into a 2NF table  STEP 1: We determine dependencies on single primary key:  Std-id Phone #, Std-name, Std-address  Course-name credit  Semester none dependent only on semester

Janice Regan, NF Example - Step 1  DB tables look like: Std-id Std-name Std-address Std-phone Paul K. Brook St. Bby Xiao T. Alpha St., Bby Will B. Elf Ave., Van Student Table Kim L. Merry Cr., Poco Course Table Course-name credit Cmpt Cmpt Engl Bus Cmpt Biol 234 3

Janice Regan, Second Normal Form - Example  STEP 2: We determine dependencies on pairs of primary keys:  Course-name + Semester room, instructor, instructor’s office  Course-name + Std-id none  Semester + Std-id none

Janice Regan, Course-name Semester Room Instructor Instructor’s office 2NF Example - Step 2 Cmpt AQ2 Dr. Klaus ASB985 Cmpt AQ1 M. Nole ASB352 Bus ASB V. Karu WM543 Engl WM W. Loti AQ834 Course Offering Table Biol EDC Dr. Quel EDC243 Cmpt AQ1 Dr. Klaus ASB985 Cmpt AQ2 Dr. Yu ASB111

Janice Regan, Second Normal Form - Example Step 3  We determine dependencies on whole compound primary key:  Course-name + Semester + Std-id grade

Janice Regan, NF Example - Step 3 Student Registration Table Std-id Course-name Semester Grade Cmpt 101 Cmpt 150 Bus 152 Engl 102 Biol 234 Cmpt C- B A- A+ B+ D A-

Janice Regan, NF Example, alternate Step 3-1 Introducing Association  Looking at the data model (class diagram), we can recognize the “many-to-many” multiplicity relationship between Student, grade and CourseOffering StudentCourse offering Receives a grade fo r takes Student ID name address phone Course name semester List of grades room Instructor Instructor’s office List of courses List of students Course Name credit 0..* 1  These 3 attributes are used to implement “many-to-many” multiplicity relationships

Janice Regan, Association Class  However, this data model does not lead to DB tables with records of fixed length because these 3 attributes are of varying size for each object of Student and Course Offering class types, so…  … we introduce yet another “class” that associates 1 student to many attempts at (registrations to) one course and 1 course to many attempts (registrations) per 1 student. For each of these attempts there is one grade

Janice Regan, Association Class  An association class takes a many-many relation and breaks it into two 1-many relationships  Student and Student Registration have a “1-to-many” multiplicity relationship  Course Offering and Student Registration have a “1-to- many” multiplicity relationship  The association class will contain the attributes that are lists (that cause the many to may relationship)  The association class wil contain the attributes that depend upon all the variables (lists) in the association class.

Janice Regan, NF Example, alternate Step  This relationship can be broken down into 2 “1-to-many” multiplicity relationships by creating an association class Student-Registration StudentCourse offering Student ID name address phone Course name semester room Instructor Instructor’s office Course Name credit 0..* 1 Student Registration Course name semester grade 0..* Student ID *

Janice Regan, NF Example, alternate Step  We can therefore store the attributes that depend on this association into a Student Registration table. The compound primary key of this table is the union of the primary keys of the Student and the Course Offering tables: C- B A- A+ B+ D A- Student Registration Table Std-id Course-name Semester Grade Cmpt 101 Cmpt 150 Bus 152 Engl 102 Biol 234 Cmpt Std-id Std-name Std-address Std-phone Xiao T. Alpha St., Bby Will B. Elf Ave., Van Student Table Kim L. Merry Cr., Poco Course-name Semester Room Instructor Instructor’s office Cmpt AQ2 Dr. Klaus ASB985 Cmpt AQ1 M. Nole ASB352 Bus ASB V. Karu WM543 Engl WM W. Loti AQ834 Course Offering Table Biol EDC Dr. Quel EDC243 Cmpt AQ1 Dr. Klaus ASB985 Cmpt AQ2 Dr. Yu ASB111 Course Table Course-name credit Cmpt Cmpt Engl Bus Cmpt Biol 234 3

Janice Regan, Second Normal Form  To get Student Registration System in 2NF we need 4 tables (files)  Multiplicities come from our Requirement Analysis phase  With this 2NF DB, students do not have to register to a course to be admitted to an institution  Room and instructor for a course offering can be entered even if there are no students registered yet  Less redundancy: Most update problems have been eliminated, but we can still have multiple occurrences of instructor and instructor’s office

Janice Regan, Second Normal Form  Definition of 2NF:  The table is in 1NF  The table includes no partial dependencies

Janice Regan, Is there still a problem? Yes!  Our tables in 2NF could still contains data redundancies due to transitive dependencies.  When one non-primary key attribute is dependent on another non-primary key attribute, the second non-primary key attribute is transitively dependent on the first non-primary key attribute.

Janice Regan, Transitive Dependencies: example  instructor’s office (non-primary key attribute) is transitively dependent on instructor (another non- primary key attribute) but not on any of the primary key attributes for that particular table (course and/or semester)  Solution: Conversion from 2NF to 3NF  Determine the transitive dependencies.  Split 2NF table containing the transitive dependency such that the dependency is represented by its own table.

Janice Regan, NF Example C- B A- A+ B+ D A- Student Registration Table Std-id Course-name Semester Grade Cmpt 101 Cmpt 150 Bus 152 Engl 102 Biol 234 Cmpt Std-id Std-name Std-address Std-phone Xiao T. Alpha St., Bby Will B. Elf Ave., Van Student Table Kim L. Merry Cr., Poco Course-name Semester Room Instructor Cmpt AQ2 Dr. Klaus Cmpt AQ1 M. Nole Bus ASB V. Karu Engl WM W. Loti Course Offering Table Biol EDC Dr. Quel Cmpt AQ1 Dr. Klaus Cmpt AQ2 Dr. Yu Course Table Course-name credit Cmpt Cmpt Engl Bus Cmpt Biol Dr. Klaus ASB985 W. Loti AQ834 Dr. Quel EDC243 Dr. Yu ASB111 M. Nole ASB352 V. Karu WM543 Instructor Instructor’s office Instructor Table

Janice Regan, Third Normal Form  Definition:  Every table is in 2NF.  There are no transitive dependencies.

Janice Regan, Normalization Summary  When normalizing, we seek to make sure that attributes depend  on the key (1NF)  on the whole key (2NF)  on nothing but the key (3NF)  When normalized:  records have fixed length  no insert/delete/update anomalies  minimize redundancy