CS 3630 Database Design and Implementation. Unnormalized Form (UNF) student courses John CS363 CS334 CS323 Multi-Value attribute Common in reports 2.

Slides:



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

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.
Assignment6-1 Assignment6-2 Due Wednesday, March 13 1.
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.
Information Resources Management March 13, Agenda n Administrivia n Normalization n Homework #7 n Mid-Term #2.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
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.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
1 Test1 N = {n: n is an integer and n  0} X = {x: x = n + 5, where n  N} Y = {y: y = 7 * n - 1, where n  N} List the three smallest elements of each.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
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
Concepts of Database Management, Fifth Edition
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
Lecture9:Functional Dependencies and Normalization for Relational Databases Prepared by L. Nouf Almujally Ref. Chapter Lecture9 1.
CSC271 Database Systems Lecture # 28.
Normalization Fundamentals of Database Systems. Lilac Safadi Normalization 2 Database Design Steps in building a database for an application: Real-world.
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)
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
CS 3630 Database Design and Implementation. 2 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
Chapter 13 Normalization © Pearson Education Limited 1995, 2005.
1 Functional Dependencies and Normalization Chapter 15.
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. Database Schema Branch (Bno…) Staff (Sno…Bno) Owner (Ono…) PropertyForRent (Pno…Ono) Renter (Rno…) Viewing.
CS 3630 Database Design and Implementation. 2 Design Methodology Three main phases 1.Conceptual database design Understanding client data E-R (EER) Model.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Lecture9:Functional Dependencies and Normalization for Relational Databases Ref. Chapter Lecture9 1.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) 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,
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.
CS 3630 Database Design and Implementation. Null Value The value of an attribute could be NULL NOT known at the moment or NOT Applicable Example Cell.
IST Database Normalization Todd Bacastow IST 210.
Assignment 5–2 For each new relation, Use DBDL to specify the relation scheme Give the functional dependencies Give the corresponding relation instance.
Lecture 4: Logical Database Design and the Relational Model 1.
Al-Imam University Girls Education Center Collage of Computer Science 1 nd Semester, 1432/1433H Chapter 10_part2 Functional Dependencies and Normalization.
ITD1312 Database Principles Chapter 4C: Normalization.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
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
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Example Question–Is this relation Well Structured? Student
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
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Boyce-Codd Normal Form (BCNF)
ITS232 Introduction To Database Management Systems
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Chapter 14 Normalization.
Database Normalisation
Presentation transcript:

CS 3630 Database Design and Implementation

Unnormalized Form (UNF) student courses John CS363 CS334 CS323 Multi-Value attribute Common in reports 2

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

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. 4

5 Partial FDs X, Y  W is partial (W partially depends on X or Y) if X  W or Y  W is true Example: Sno, Bno  staffAddress, staffPhone staffAddress and staffPhone are Partially depend on Sno, since the following is true Sno  staffAddress, staffPhone

6 Full FDs A FD is a full FD if it’s not partial. A, B  X, Y is a full FD if both of the following are false: A  X, Y B  X, Y Sno  staffAddress, staffPhone Cannot be partial!

7 Full FDs A FD is a full FD if it’s not partial. Pno, Start  Rno, Rent, Finish Both of the following are false: Pno  Rno, Rent, Finish Start  Rno, Rent, Finish

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 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 8

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 on Primary Key) 9

Table Instance RNo RName PNo PAddress Start Finish Rent Ono OName R101 John P main O100 Tina R102 Mike P main O100 Tina R103 Kay P main O100 Tina R101 John P main O110 Tony R105 Scot P first 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? New Table! 10

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 Lease2 (RNo, RName, PNo, Start, Finish, Rent) PK and FK? 11

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? Lease2 (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? 12

Relation/Table Instances Lease Rno RName PNo PAddress Start Finish Rent Ono OName R101 John P main O100 Tina R102 Mike P main O100 Tina R103 Kay P main O100 Tina R101 John P main O110 Tony R105 Scot P first O109 Tony Lease1 PNo PAddress ONo OName P main O100 Tina P main O110 Tony P first O109 Tony Lease1 =  PNo, PAddress, Ono, OName (Lease) 13

Removing Duplicates Lease1 PNo PAddress ONo OName P main O100 Tina P main O110 Tony P first O109 Tony Lease1 P main O100 Tina P main O110 Tony P first O109 Tony 14

Lease RNo RName PNo PAddress Start Finish Rent Ono OName R101 John P main O100 Tina R102 Mike P main O100 Tina R103 Kay P main O100 Tina R101 John P main O110 Tony R105 Scot P first O109 Tony Lease2 RNo RName PNo Start Finish Rent R101 John P R102 Mike P R103 Kay P R101 John P R105 Scot P Lease2 =  RNo, RName, RNo, Start, Finish, Rent (Lease) 15

Some FDs are lost Lease (RNo, RName, PNo, PAddress, Start, Finish, Rent, ONo, OName) PAddress, Start ---> All other attributes PAddress, Finish ---> All other attributes Lease1 (PNo, PAddress, ONo, OName) Lease2 (RNo, RName, PNo, Start, Finish, Rent) 16

Example Relation R (A, B, C, D, E, F) PK: A, B AK: None FK: None Functional Dependencies: A, B ---> All A ---> C B ---> E, F In 2NF? NO! 17

Table Instance A B C D E F 1 x cs se 1 y cs ee 2 x cs se 2 y cs ee Functional Dependencies: A, B ---> All A ---> C B ---> E, F 18

R1 (A, C) Primary Key: A Alternate Key: None Foreign Key: None Functional Dependencies: A ---> C R2 (B, E, F) Primary Key: B Alternate Key: None Foreign Key: None Functional Dependencies: B ---> E, F R3 (A, B, D) Primary Key: A, B Alternate Key: None Foreign Key: A References R1 B References R2 Functional Dependencies: A, B ---> D 19 R (A, B, C, D, E, F) Functional Dependencies: A, B ---> All A ---> C B ---> E, F Decompose table R into 2NF

Table Instance R A B C D E F 1 x cs se 1 y cs ee 2 x cs se 2 y cs ee R1 A C R2 B E F x cs se y cs ee R3 A B D 1 x y x y

Schedule Assignment 5-1 Due Wednesday Assignment 6-1 Due Monday, March 2 Quiz 2 Friday, March 6 21

Assignment 4 DBDL Style Will Lose Points on Quiz/Test 22