CS 3630 Database Design and Implementation

Slides:



Advertisements
Similar presentations
Unnormalized Form (UNF) student courses John CS363 CS334 CS323 Multi-Value attribute Common in reports 1.
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
1 Assignment 4 Map entities with relationships to relational schemas. Use DBDL to describe the table schemas.
Assignment Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the.
Boyce-Codd Normal Form (BCNF) Definition R in 1NF and Every determinant (the left side of a FD) is a candidate key. 1.
1 Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Need for Normalization
1 Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the process of design.
CS 3630 Database Design and Implementation. First Normal Form (1NF) No multi-value attributes Done when mapping E-R model to relational schema DBDL 2.
1 CS 3630 Database Design and Implementation. 2 Final Exam 7:00 – 8:52 PM, Thursday, May 16 Section 1: Ull 009 Section 2: Ull Points –50 points.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Assignment 5-1 Functional Dependencies Attributes within one table True for all table instances Part of table schema (Assumptions) Cannot get FDs just.
Chapter 6 Normalization 正規化. 6-2 In This Chapter You Will Learn:  更動異常  How tables that contain redundant data can suffer from update anomalies ( 更動異常.
Avoiding Database Anomalies
Lecture9:Functional Dependencies and Normalization for Relational Databases Prepared by L. Nouf Almujally Ref. Chapter Lecture9 1.
CSC271 Database Systems Lecture # 28.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
1 CS 3630 Database Design and Implementation. 2 Sets Foundation of relational database. Basic Operations Power set Mapping.
Normal Forms through BCNF CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
CS 3630 Database Design and Implementation. 2 Functions y = f(x) x1 = x2  f(x1) = f(x2) Same x value, then same function value. Yes, it’s a function!
CS 3630 Database Design and Implementation. 2 Design Methodology Three main phases 1.Conceptual database design Understanding client data E-R (EER) Model.
CS 3630 Database Design and Implementation. Unnormalized Form (UNF) student courses John CS363 CS334 CS323 Multi-Value attribute Common in reports 2.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Second Normal Form (2NF) A relation R is in 1NF, and every non-primary-key attribute is fully functionally dependent on the primary key Then R is in 2NF.
Quiz Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo.
Assignment 5–2 For each new relation, Use DBDL to specify the relation scheme Give the functional dependencies Give the corresponding relation instance.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Chapter 9 Normalization Chapter 14 & 15 in Textbook.
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Functional Dependency and Normalization
CS 3630 Database Design and Implementation
Normalization DBMS.
Normalization Dongsheng Lu Feb 21, 2003.
CS 3630 Database Design and Implementation
Canonical Cover & Normal Forms
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
CS 3630 Database Design and Implementation
Advanced Normalization
Normalization Lecture 7 May Aldoayan.
Assignment 4 Map entities with relationships to relational schemas.
Chapter 14 Normalization
CS 3630 Database Design and Implementation
CHAPTER 5 Normalization Of Database Tables (Part II: The Process)
Assignment 5–2 For each table, Give a meaningful name
Normalization 2NF & 3NF Presented by: Dr. Samir Tartir
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
Normalization.
Canonical Cover & Normal Forms
CS 3630 Database Design and Implementation
Boyce-Codd Normal Form (BCNF)
Normalization.
Normalization and FD.
Normalization Dongsheng Lu Feb 21, 2003.
Chapter 7 Normalization Chapter 13 in Textbook.
Normalization and Databases
CS 3630 Database Design and Implementation
ITS232 Introduction To Database Management Systems
Normalization Dale-Marie Wilson, Ph.D..
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Normalization.
Chapter 14 Normalization.
Normalization February 28, 2019 DB:Normalization.
國立臺北科技大學 課程:資料庫系統 2015 fall Chapter 14 Normalization.
Database Normalisation
Sampath Jayarathna Cal Poly Pomona
NORMALIZATION FIRST NORMAL FORM (1NF):
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Database Normalization.
Presentation transcript:

CS 3630 Database Design and Implementation

Unnormalized Form (UNF) student courses Joe Clifton CS3630 CS3340 CS3230 Multi-Value attribute Common in reports 2NF and 3NF could be in one note.

First Normal Form (1NF) No multi-value attributes Done when mapping E-R model to relational schema DBDL

Second Normal Form (2NF) A relation R is in 1NF, and every non-primary-key attribute is fully functionally dependent on the primary key Then R is in 2NF No Partial FDs on the PK.

Partial FDs X, Y  W is a partial FD if X  W or Y  W is true Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PAddress, Start  All PAddress, Start  PNo, ONo, OName PAddress  PNo, ONo, OName

Second Normal Form (2NF) No Partial FDs on the PK. PK  All other attributes Assume a table with a simple PK of Att1 Att1  All other attributes Is it in 2NF? Cannot have partial FD on simple PK Assume a table with a composite PK of Att1 and Att2 Att1, Att2  Att3, Att4, Att5 (All other attributes) It’s possible Att2  Att5 Att1, Att2  Att3, Att4

Example Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PK: PNo, Start AK: PNo, Finish PAddress, Start PAddress, Finish FDs: PNo, Start  All PNo, Finish  All PAddress, Start  All PAddress, Finish  All RNo  RName ONo  Oname PAddress  PNo, ONo, OName PNo  PAddress, ONo, OName Partial FD on Primary Key?

Table Instance Not in 2NF! Poor Performance Redundancy Inconsistency RNo RName PNo PAddress Start Finish Rent Ono OName R101 John P1001 1001 main 1-1-04 12-31-04 350 O100 Tina R102 Mike P1001 1001 main 1-1-05 2-28-05 380 O100 Tina R103 Kay P1001 1001 main 3-1-05 12-31-05 380 O100 Tina R101 John P1002 2001 main 1-1-05 12-31-05 550 O110 Tony R105 Scot P1009 1009 first 1-1-04 5-31-04 350 O109 Tony PNo, Start  All other attributes (Partial on Primary Key) PNo  PAddress, ONo, OName Not in 2NF! Poor Performance Redundancy Inconsistency What to Do? Move the attributes to another table!

Decompose Lease into 2NF Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PK: PNo, Start Partial FD on Primary Key PNo  PAddress, ONo, OName Remove partial dependent on Primary Key Create a new relation Which attributes are in the new relation? All attributes in the partial FD (both side of) Lease1 (PNo, PAddress, ONo, OName) Which attributes are left in the original relation? PK remains the same Lease (RNo, RName, PNo, Start, Finish, Rent) PK? FK?

Lease1 (PNo, PAddress, ONo, OName) PK: PNo AK: PAddress FK: None (from this conversion) Functional Dependencies: PNo  All other attributes PAddress  PNo, ONo, OName ONo  OName In 2NF? Lease (RNo, RName, PNo, Start, Finish, Rent) PK: PNo, Start AK: PNo, Finish FK: PNo references Lease1 Functional Dependencies: PNo, Start  All other attributes PNo, Finish  All other attributes RNo  Rname In 2NF?

Relation/Table Instances Lease Rno RName PNo PAddress Start Finish Rent Ono OName R101 John P1001 1001 main 1-1-04 12-31-04 350 O100 Tina R102 Mike P1001 1001 main 1-1-05 2-28-05 380 O100 Tina R103 Kay P1001 1001 main 3-1-05 12-31-05 380 O100 Tina R101 John P1002 2001 main 1-1-05 12-31-05 550 O110 Tony R105 Scot P1009 1009 first 1-1-04 5-31-04 350 O109 Tony Lease1 PNo PAddress ONo OName P1001 1001 main O100 Tina P1002 2001 main O110 Tony P1009 1009 first O109 Tony PNo, PAddress, Ono, OName (Lease)

Removing Duplicates Lease1 PNo PAddress ONo OName P1001 1001 main O100 Tina P1002 2001 main O110 Tony P1009 1009 first O109 Tony P1001 1001 main O100 Tina P1002 2001 main O110 Tony P1009 1009 first O109 Tony

Lease (before) Lease (after) RNo RName PNo Start Finish Rent RNo RName PNo PAddress Start Finish Rent Ono OName R101 John P1001 1001 main 1-1-04 12-31-04 350 O100 Tina R102 Mike P1001 1001 main 1-1-05 2-28-05 380 O100 Tina R103 Kay P1001 1001 main 3-1-05 12-31-05 380 O100 Tina R101 John P1002 2001 main 1-1-05 12-31-05 550 O110 Tony R105 Scot P1009 1009 first 1-1-04 5-31-04 350 O109 Tony Lease (after) RNo RName PNo Start Finish Rent R101 John P1001 1-1-04 12-31-04 350 R102 Mike P1001 1-1-05 2-28-05 380 R103 Kay P1001 3-1-05 12-31-05 380 R101 John P1002 1-1-05 12-31-05 550 R105 Scot P1009 1-1-04 5-31-04 350 RNo, RName, RNo, Start, Finish, Rent (Lease)

Some FDs are lost Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PAddress, Start  All PAddress, Finish  All Lease1 (PNo, PAddress, ONo, OName) Lease (RNo, RName, PNo, Start, Finish, Rent)

Assignment 5-1

Assumptions Identify all non-trivial FDs NIN  eName contractNo  hNo, hLoc hNo  hLoc NIN, contractNo  All ( NIN, contractNo  hours) Choose a PK: NIN, contractNo List all AKs: NONE

Schedule Assignment 61 Due Thursday, March 1, by 5 pm Quiz 2 Wednesday, March 7 Covers A4 and A51, A61

Assignment 4