INLS 623 – D ATABASE N ORMALIZATION Instructor: Jason Carter.

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

ALAK ROY. Assistant Professor Dept. of CSE NIT Agartala N ATIONAL I NSTITUTE OF T ECHNOLOGY A GARTALA Aug-Dec,2010 Normalization 2 CSE-503 :: D ATABASE.
NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
Boyce-Codd normal form (BCNF) Kai Zhu CS157B Professor: Dr. Lee.
Normalization continued CMSC 461 Michael Wilson. Normalization clarification  Normalization is simply a way of reducing anomalous database behavior 
NORMALIZATION FIRST NORMAL FORM (1NF): A relation R is in 1NF if all attributes have atomic value = one value for an attribute = no repeating groups =
Ch 10, Functional Dependencies and Normal forms
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 4 Normalization 2NF & 3NF Presented by: Dr. Samir Tartir.
Functional Dependencies and Normalization for Relational Databases.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Normalization.
Normal Forms By Christopher Archibald October 16 th 2007.
Ms. Hatoon Al-Sagri CCIS – IS Department Normalization.
Functional Dependencies and Normalization for Relational Databases
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
METU Department of Computer Eng Ceng 302 Introduction to DBMS Functional Dependencies and Normalization for Relational Databases by Pinar Senkul resources:
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Announcements Homework 1 due Friday. Slip it under my office door (1155) or put in my mailbox on 5 th floor. Program 2 has been graded ;-( Program 3 out.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 6 NORMALIZATION FOR RELATIONAL DATABASES Instructor Ms. Arwa Binsaleh.
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Topic 10 Functional Dependencies and Normalization for Relational Databases Faculty of Information Science and Technology Mahanakorn University of Technology.
Instructor: Churee Techawut Functional Dependencies and Normalization for Relational Databases Chapter 4 CS (204)321 Database System I.
Lecture9:Functional Dependencies and Normalization for Relational Databases Prepared by L. Nouf Almujally Ref. Chapter Lecture9 1.
Design Theory for Relational Databases 2015, Fall Pusan National University Ki-Joune Li.
Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
By Abdul Rashid Ahmad. E.F. Codd proposed three normal forms: The first, second, and third normal forms 1NF, 2NF and 3NF are based on the functional dependencies.
Chapter Functional Dependencies and Normalization for Relational Databases.
1 Functional Dependencies and Normalization Chapter 15.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
Lecture9:Functional Dependencies and Normalization for Relational Databases Ref. Chapter Lecture9 1.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
Normalization MIS335 Database Systems. Why Normalization? Optimizing database structure Removing duplications Accelerating the instructions Data integrity!
Normalization.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Al-Imam University Girls Education Center Collage of Computer Science 1 nd Semester, 1432/1433H Chapter 10_part2 Functional Dependencies and Normalization.
INLS 623 – D ATABASE N ORMALIZATION Instructor: Jason Carter.
Databases : Design of Relational Database Schemas 2007, Fall Pusan National University Ki-Joune Li.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
10/3/2017.
COP 6726: New Directions in Database Systems
INLS 623 – Database Normalization
Functional Dependencies and Normalization for Relational Databases
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Normal forms First Normal Form (1NF) Second Normal Form (2NF)
Normalization 2NF & 3NF Presented by: Dr. Samir Tartir
Database Management systems Subject Code: 10CS54 Prepared By:
Design Theory for Relational Databases
Chapter 14 & Chapter 15 Normalization Pearson Education © 2009.
Outline: Normalization
Normalization.
Normalization February 28, 2019 DB:Normalization.
Sampath Jayarathna Cal Poly Pomona
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

INLS 623 – D ATABASE N ORMALIZATION Instructor: Jason Carter

K EYS Primary Key Secondary Key(s) Candidate Key(s) Foreign Key(s)

S ET T HEORY Set A collection of zero or more distinct objects. What does set theory have to do with databases? A record is a set of attribute/property values Columns are a set of attributes Rows are a set of records Conventionally sets are denoted with capital letters A = {1,2,3} B = {2,1,5} C = {red, green, blue}

S ETS Equality {6, 11} = {11, 6} = {11, 6, 6, 11}. {1,2} = {2,1} Membership A = {1,2,3,4} ∈ = member of 4 ∈ A, 1 ∈ A, 3 ∈ A, 2 ∈ A ∉ = not a member of 6 ∉ A

S ETS Subsets a set A is a subset of a set B if all members of set A is also a member of set B ⊆ = subset A = {1,3} B = {1,2,3,4} {1, 3} ⊆ {1, 2, 3, 4} A ⊆ B

S ETS Superset a set B is a superset of a set A if all members of set A are members of set B ⊋ = superset A = {1,3} B = {1,2,3,4} {1, 2, 3, 4} ⊋ {1, 3} B ⊋ A

S UPER K EY Formal definition A superkey of a relation schema R = {A1, A2,...., An} is a set of attributes S subset-of R with the property that no two tuples t1 and t2 in any legal relation state r of R will have t1[S] = t2[S] A key K is a superkey with the additional property that removal of any attribute from K will cause K not to be a superkey any more. A superkey is a combination of attributes that can be uniquely used to identify a database record. A superkey can be just one column.

S UPER K EY E XAMPLE A superkey is a combination of attributes that can be uniquely used to identify a database record. A relation book R(BookId, BookName, Author) What are possible superkeys? (BookId) (BookId,BookName) (BookId, BookName, Author) (BookId, Author) (BookName, Author)

M INIMAL S UPERKEY The minimum number of columns, which when combined, will give a unique value for every row in the table Candidate keys are minimal superkeys A relation book R(BookId, BookName, Author) What are possible candidate keys? BookId (BookName,Author)

K EYS AND A TTRIBUTES A Prime attribute is a member of some candidate key R(BookId, BookName, Author) BookId (BookName,Author) A Nonprime attribute is not a prime attribute—that is, it is not a member of any candidate key. R(BookId, BookName, Author) Author BookName

T ERMINOLOGY

W HAT IS N ORMALIZATION ? A technique to organize “efficiently” organize data in a database “Efficiently”: Eliminating redundant data Not storing the same data in more than one table Ensuring that functional dependencies make sense

F UNCTIONAL D EPENDENCIES Let R be a relation and X and Y be two sets of attributes/properties in that relation. X → Y (X determines Y) if and only if each X value is associated with precisely one Y value Formal Definition A dependency occurs when information stored in the same table uniquely determines other information stored in the same table.

F UNCTIONAL D EPENDENCIES E XAMPLES SSNFirst NameLast Name Age Jack Doe Jane Doe Jill Roy Jane Doe50 A dependency occurs when information stored in the same table uniquely determines other information stored in the same table. SSN → AgeSSN → FN SSN → LN

N ORMAL F ORM 1 st Normal Form 2 nd Normal Form 3 rd Normal Form Boyce-Codd Normal Form (3.5 Normal Form) 4 th Normal Form

1 ST N ORMAL F ORM Every cell in the table is atomic A cell value cannot be divided further Seen differently – there are no grouping of information inside a cell. No duplicate rows

1 ST N ORMAL F ORM Student Does this table violate first normal form? IdFirst name Last name GradesClasses 1BobWoodC,B401, 623 2JoeSmithA,D550, 823 3AliceBooneA,A890,991 4ShellyKentA,B770,881

1 ST N ORMAL F ORM Student Grades and Classes have multiple rows of data in one column IdFirst name Last name GradesClasses 1BobWoodC,B401, 623 2JoeSmithA,D550, 823 3AliceBooneA,A890,991 4ShellyKentA,B770,881

1 ST N ORMAL F ORM Student Create new rows IdFirst name Last name GradesClasses 1BobWoodC401 2JoeSmithA550 3AliceBooneA890 4ShellyKentA770 5BobWoodB623 6JoeSmithD823 7AliceBooneA991 8ShellyKentB881

2 ND N ORMAL F ORM Table must be in 1 st Normal Form An attribute is in a 2NF table if and only if it is fully functionally dependent on every candidate key. Example: R(CourseId, SectionNum, Instructor, TA) Candidate Key: CourseId, SectionNum Functional Dependency = {CourseId, SectionNum →Insructor, CourseId, SectionNum → TA}

2 ND N ORMAL F ORM Full functional dependency: a FD Y → Z where removal of any attribute from Y (LHS) means the FD does not hold any more {EmployeeName, Project} → HrsWkd is a full FD since neither EmployeeName → HrsWkd nor Proj → HrsWkd hold A partial dependency occurs if some attribute can be removed and the dependency still holds {SSN, Proj} → EmployeeName is not a full FD since SSN → EmployeeName also holds

2 ND N ORMAL F ORM Ssn = Social Security Number Pnumber = Project Number Hours = # of hours person worked on project Ename = Employee Name Pname = Project name Plocation = Project location Is this table in 2NF?

2 ND N ORMAL F ORM What is the primary key? Are there other candidate keys? What are the non prime attributes? Ssn Pnumber Hours, Ename, Pname, Plocation

2 N D N ORMAL F ORM Hours Is {Ssn, Pnum}  {hours} a FFD? Yes Ename Is {Ssn, Pnum}  {Ename} a FFD? No, problem is FD2 Non prime attributes Pname Is {Ssn, pnum}  {Pname} a FFD? No, problem is FD3 Plocation Is {Ssn, pnum}  {Plocation} a FFD? No, problem is FD3

2 ND N ORMAL F ORM Table 1Table 2Table 3

3 RD N ORMAL F ORM Table must be in 2 nd Normal Form A relation is in 3NF if it is in 2NF AND no nonprime attributes are transitively dependent on all candidate keys.

T RANSITIVELY D EPENDENT Formal definition Y is transitively dependent on X if the only way to derive X → Y is through using X → Z and Z → Y for some Z that is not a subset of Z or Y.

3 RD N ORMAL F ORM X = {Ssn}, Y = {Dmgr_ssn}, Z = {Dnumber} Definition: A FD X  Y is a transitive dependency if there is a set of attributes Z that is neither a candidate key nor a subset of any key, and both X  Z and Z  Y hold. Ssn  Dnumber and Dnumber  Dmgr_ssn Ssn  Dmgr_ssn

3 RD N ORMAL F ORM Dmgr_ssn is a nonprime attribute {ssn}  {Dmgr_ssn} is a transitive dependency (based on {Dnumber}) EMP_DEPT is NOT in 3 rd Normal Form

D ECOMPOSITION TO 3 RD N ORMAL F ORM Goal: Decompose to remove the transitive dependency that caused the problem {ssn}  {Dmgr_ssn} is a transitive dependency (based on {Dnumber}) Notice: Must put Dnumber in BOTH tables

3 RD N ORMAL F ORM TournamentYearWinner Winner Date of Birth Indiana Invitational 1998Al Fredrickson21 July 1975 Cleveland Open1999Bob Albertson 28 September 1968 Des Moines Masters 1999Al Fredrickson21 July 1975 Indiana Invitational 1999Chip Masterson14 March Table is in 2 nd normal form, but not in 3 rd normal form Tournament Winners Candidate key? {Tournament, Year}

3 RD N ORMAL F ORM Winner Date of Birth is transitively dependent on the candidate key {Tournament, Year} TournamentYearWinnerWinner Date of Birth Indiana Invitational 1998Al Fredrickson21 July 1975 Cleveland Open1999Bob Albertson28 September 1968 Des Moines Masters 1999Al Fredrickson21 July 1975 Indiana Invitational 1999Chip Masterson14 March 1977 Tournament Winners Non-prime attribute Winner Winner Date of Birth  Winner Winner Date of Birth is fully dependent on Winner Winner  {Tournament, Year} Winner Date of Birth is transitively dependent on {Tournament, Year}

3 RD N ORMAL F ORM There is nothing to stop the same person from being shown with different dates of birth on different records. TournamentYearWinner Indiana Invitational1998Al Fredrickson Cleveland Open1999Bob Albertson Des Moines Masters1999Al Fredrickson Indiana Invitational1999Chip Masterson WinnerDate of Birth Chip Masterson14 March 1977 Al Fredrickson21 July 1975 Bob Albertson28 September 1968 Tournament Winners Winner Dates of Birth