ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: www.cse.yorku.ca/~gordon/itec3220S07 Office: CSEB3020.

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

Database Tables and Normalization
5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
1 Logical Database Design and the Relational Model Modern Database Management.
DBS201: Introduction to Normalization
1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Chapter 5 Normalization of Database Tables
Normalization of Database Tables Special adaptation for INFS-3200
Normalization of Database Tables
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.
Need for Normalization
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Normalization of Database Tables
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
4 Chapter 4 Normalization Hachim Haddouti. 4 Hachim Haddouti, CH4, see also Rob & Coronel 2 In this chapter, you will learn: What normalization is and.
Normalization of Database Tables
Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
NORMALIZATION N. HARIKA (CSC).
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Chapter 5 Normalization of Database Tables
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
Chapter 5: Logical Database Design and the Relational Model
Database Systems: Design, Implementation, and Management Tenth Edition
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
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 – Lecture 8
Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management Peter Rob & Carlos Coronel.
Database Principles: Fundamentals of Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables Carlos Coronel, Steven.
Normalization of Database Tables
Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building.
E-R Modeling: Table Normalization. Normalization of DB Tables Normalization ► Process for evaluating and correcting table structures determines the optimal.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Logical Database Design and the Relational Model.
Entity Relationship Model: E-R Modeling 1 Database Design.
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.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Introduction to Database Systems
Lecture 4: Logical Database Design and the Relational Model 1.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Normalizing Database Designs. 2 Objectives In this chapter, students will learn: –What normalization is and what role it plays in the database design.
Normalization.
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
Chapter 5: Relational Database Design
Chapter 4: Part B Logical Database Design and the Relational Model
Chapter 4: Relational Database Design
Chapter 5: Logical Database Design and the Relational Model
Normalization of Database Tables PRESENTED BY TANVEERA AKHTER FOR BCA 2ND YEAR dated:15/09/2015 DEPT. OF COMPUTER SCIENCE.
Chapter 6 Normalization of Database Tables
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Systems Instructor Name: Lecture-11.
Normalization of Database Tables Uploaded by: mysoftbooks.ml
Normalization of DB relations examples Fall 2015
Review of Week 3 Relation Transforming ERD into Relations
Presentation transcript:

ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020

2 Supertypes and Subtypes Generalization hierarchy: depicts relationships between higher-level supertype and lower-level subtype entities Supertype:Supertype: contains the shared attributes Subtype:Subtype: contains the unique attributes Inheritance:Inheritance: –Subtype entities inherit values of all attributes of the supertype –An instance of a subtype is also an instance of the supertype

3 Supertypes and Subtypes (Cont’d) Supertype/ subtype relationships SUPERTYPE Attributes shared by all entities SUBTYPE1 Attributes unique to subtype2 SUBTYPE2 Attributes unique to subtype1 General entity type And so forth Specialized version of supertype

4 Supertypes and Subtypes (Cont’d) Disjoint relationships –Unique subtypes –Non-overlapping –Indicated with a ‘G’ Overlapping subtypes –An instance of the supertype could be more than one of the subtypes –Indicated with a ‘Gs’

5 Generalization Hierarchy with Overlapping Subtypes

Chapter 5 Logical Database Design and Normalization of Database Tables

7 In this chapter, you will learn: How to transform ERD into relations What normalization is and what role it plays in database design About the normal forms 1NF, 2NF, 3NF, BCNF, and 4NF How normal forms can be transformed from lower normal forms to higher normal forms Normalization and E-R modeling are used concurrently to produce a good database design Some situations require denormalization to generate information efficiently

8 Transforming ERD into Relations Step one: Map regular entities –Each regular entity type in an ER diagram is transformed into a relation –The name given to the relation is generally the same as the entity type –Each simple attribute of the entity type becomes an attribute of the relation and the identifier of entity becomes the primary key of the corresponding relation

9 Example Student_ID Student_Name Other_Attributes STUDENT

10 Transforming ERD into Relations (Cont’d) Step two: Map weak entities –Create a new relation and include all of the simple attributes as the attributes of this relation. Then include the primary key of the identifying relation as a foreign key attribute in this new relation. The primary key of the new relation is the combination of this primary key of the identifying relation and the partial identifier of the weak entity type.

11 Example EMPLOYEE Has DEPENDENT Employee_IDEmployee_Name Dependent_Name Gender Date_of_birth Employee_IDEmployee_Name EMPLOYEE DEPENDENT Dependent_NameEmployee_IDDate_of_birthGender

12 Transforming ERD into Relations (Cont’d) Step three: Map binary relationship –Map Binary one-to-many relations First create a relation for each of the two entity types participating in the relationship, using the procedure described in step one. Next, include the primary key attribute of the entity on the one-side of the relationship as a foreign key in the relation that is on the many-side of the relationship.

13 Example M Order_DateOrder_ID Customer Customer_NameCustomer_ID SubmitsOrder 1 (1,1)(0,N) Customer_IDCustomer_Name Customer Order Order_IDOrder_DateCustomer_ID

14 Transforming ERD into Relations (Cont’d) Step three: Map binary relationship (Cont’d) –Map binary one-to-one relationships First, two relationships are created one for each of the participating entity types. Second, the primary key of one of the relations is included as a foreign key in the other relation.

15 Example Location Centre_Name Nurse Nurse_NameNurse_ID In_charge Care Centre 1 (1,1) (0,1) 1 Nurse_IDNurse_Name Nurse Centre_NameLocationNurse_in_c harge Care Centre

16 Transforming ERD into Relations (Cont’d) Step Four: Map composite Entities –First step Create three relations: one for each of the two participating entities, and the third for the composite entity. We refer to the relation formed from the composite entity as the composite relation –Second step Identifier not assigned: The default primary key for the composite relation consists of the two primary key attributes from the other two relations. Identifier assigned: The primary key for the composite relation is the identifier. The primary keys for the two participating entity types are included as foreign keys in the composite relation.

17 Example 1 Order Order Line Order_DateOrder_IDQuantity ProductPrice Description Product_ID (1,N) M M 1 (1,1) (0,N)

18 Example Order_IDOrder_Date Product_IDDescriptionStandard_Price Product_IDOrder_IDQuantity Order Order Line Product

19 Example Customer_IDCustomer_Name Customer Shipment_N o Vendor_I D Customer_I D DateAmount Shipment Vendor Vendor_IDAddress M Vendor_ID Customer Name Customer_ID Shipment Vendor Shipment_No Amount Date 1M1

20 Transforming ERD into Relations (Cont’d) Step Five: Map unary relationship –Map unary one-to-many relationship The entity type in the unary relationship is mapped to a relation using the procedure described in Step one. Then a foreign key attribute is added within the same relation that references the primary key values. A recursive foreign key is a foreign key in a relation that references the primary key values of that same relation.

21 Example Manages Employee_IDBirthdate Name Employee 1 M (1,1) (0,N) Employee_IDNameBirthdateManager_ID Employee

22 Transforming ERD into Relations (Cont’d) Step six: Map ternary relationship –Convert a ternary relationship to a composite entity –To map a composite entity that links three regular entities, we create a new composite relation. The default primary key of their relation consists of the three primary key attributes for the participating entities. Any attributes of the composite entity become attributes of the new relation

23 Example 1 1 (1,1) (0,N) (1,1) (0,N) (1,1) M M 1 Treatment Physician Patient Physician_ID Physician_Name Patient_ID Patient_Name Description Treatment_ Code Patient Treatment Time Date Results M

24 Example Patient_IDPatient_Name Treatment_CodeDescription Physician_IDPhysician_Name Patient_ ID Physician_I D Treatment_C ode DateTimeResult Patient Physician Treatment Patient Treatment

25 Transforming ERD into Relations (Cont’d) Step seven: Map supertype/subtype relationships 1.Create a separate relation for the supertype and for each of its subtype 2.Assign to the relation created for the supertype the attributes that are common to all members of the supertype, including the primary key 3.Assign to the relation for each subtype the primary key of the supertype, and only those attributes that are unique to that subtype 4.Assign one attribute of the supertype to function as the subtype discriminator

26 Example Employee_Name Address Date_Hired EmployeeEmployee_Number Employee_Type Salaried Employee Hourly Employee Gs Hourly_Rate Stock_OptionAnnual_Salary

27 Example Employee_Nu mber Employee_N ame AddressEmployee_Ty pe Date_Hi red S_Employee_NumberAnnual_SalaryStock_Option H_Employee_NumberHourly_Rate Employee Hourly_Employee Salaried_Employee

28 Database Tables and Normalization Table is the basic building block in database design Normalization is the process for assigning attributes to entities –Reduces data redundancies –Helps eliminate data anomalies –Produces controlled redundancies to link tables Normalization stages –1NF - First normal form –2NF - Second normal form –3NF - Third normal form –4NF - Fourth normal form

29 Need for Normalization

30 Anomalies In the Table PRO_NUM intended to be primary key Table displays data anomalies –Update Modifying JOB_CLASS –Insertion New employee must be assigned project –Deletion If employee deleted, other vital data lost

31 Conversion to 1NF Step 1: Eliminate the Repeating Groups –Present data in a tabular format, where each cell has a single value and there are no repeating groups –Eliminate repeating groups by eliminating nulls, making sure that each repeating group attribute contains an appropriate data value Step 2: Identify the Primary Key –Primary key must uniquely identify attribute value

32 Dependency Diagram (1NF)

33 1NF Summarized All key attributes defined No repeating groups in table All attributes dependent on primary key All relational tables satisfy 1NF requirements

34 Conversion to 2NF Start with 1NF form: Write each key component on separate line Write original key on last line Each component is new table Write dependent attributes after each key PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS, CHG_HOUR) ASSIGN (PROJ_NUM, EMP_NUM, HOURS)

35 2NF Conversion Results

36 2NF Summarized In 1NF Includes no partial dependencies –No attribute dependent on a portion of primary key Still possible to exhibit transitive dependency –Attributes may be functionally dependent on nonkey attributes

37 Conversion to 3NF Create separate table(s) to eliminate transitive functional dependencies –For every transitive dependency, write its determinant as a PK for a new table –Identify the Dependent Attributes PROJECT (PROJ_NUM, PROJ_NAME) ASSIGN (PROJ_NUM, EMP_NUM, HOURS) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS) JOB (JOB_CLASS, CHG_HOUR)

38 3NF Summarized In 2NF Contains no transitive dependencies

39 Boyce-Codd Normal Form (BCNF) Every determinant in the table is a candidate key –Determinant is an attribute whose value determines other values within a row –3NF table with one candidate key is already in BCNF

40 3NF Table Not in BCNF

41 Decomposition of Table Structure to Meet BCNF

42 Decomposition into BCNF

43 An Example GRADE( Student_ID, Student_Name, Address, Major, Course_ID, Course_Title, Instructor_Name, Instructor_Office, Grade)

44 Normalization and Database Design Normalization should be part of the design process E-R Diagram provides macro view Normalization provides micro view of entities –Focuses on characteristics of specific entities –May yield additional entities Difficult to separate normalization from E-R diagramming Business rules must be determined

45 Higher-Level Normal Forms Fourth Normal Form (4NF) –Table is in 3NF –Has no multiple sets of multivalued dependencies

46 Conversion to 4NF Stud-IDCourseService FRed Cross FUnited Way F Stud-IDCourseService F F F 1126Red Cross 1126United Way Stud-IDCourseService FRed Cross FUnited Way F Multivalued Dependencies Set of Tables in 4NF Stud-IDCourse F F F Stud-IDService 1126Red Cross 1126United Way

47 Denormalization Normalization is one of many database design goals Normalized table requires –Additional processing –Loss of system speed Normalization purity is difficult to sustain due to conflict in: –Design efficiency –Information requirements –Processing

48 Exercise Part_ No DescriptionVendor_Nam e AddressUnit_C ost 1234Logic ChipsFast Chips Smart Chips Cupertino Phoenix Memory ChipsFast Chips Quality Chips Smart Chips Cupertino Austin Phoenix Part Supplier Data

49 Exercise(Cont’d) Convert the table to a relation in first normal form (Named Part Supplier) List the functional dependency in the Part Supplier and identify a candidate key For the relation Part Supplier, identify the followings: an insert anomaly, a delete anomaly, and a modification anomaly. Draw a relation schema and show the functional dependencies Develop a set of 3NF relations from Part Supplier

50 Chapter 5 Review How to transform ERD into relations Definitions: 1NF, 2NF, 3NF, BCNF, and 4NF How normal forms can be transformed from lower normal forms to higher normal forms