Ch 10, Functional Dependencies and Normal forms

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
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.
Ms. Hatoon Al-Sagri CCIS – IS Department Normalization.
Functional Dependencies and Normalization for Relational Databases
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
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
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Normalization.
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.
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Chapter Functional Dependencies and Normalization for Relational Databases.
CSE314 Database Systems Basics of Functional Dependencies and Normalization for Relational Databases Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E.
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.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
Database Design FUNCTIONAL DEPENDENCES NORMAL FORMS D. Christozov / G.Tuparov INF 280 Database Systems: DB design: Normal Forms 1.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Al-Imam University Girls Education Center Collage of Computer Science 1 nd Semester, 1432/1433H Chapter 10_part2 Functional Dependencies and Normalization.
Chapter 15 1 Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
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) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
1 Normalization David J. Stucki. Outline Informal Design Guidelines Normal Forms  1NF  2NF  3NF  BCNF  4NF 2.
10/3/2017.
10/3/2017.
COP 6726: New Directions in Database Systems
Functional Dependency and Normalization
CHAPTER 14 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for Relational Databases
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for RDBs
Normalization Introduction & 1NF Presented by: Dr. Samir Tartir
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for Relational Databases
Database Management systems Subject Code: 10CS54 Prepared By:
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Sampath Jayarathna Cal Poly Pomona
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

Ch 10, Functional Dependencies and Normal forms Bernard Chen, Ph.D. Assistant Professor Department of Computer Science University of Central Arkansas Fall 2011

Goodness of relation schemas The grouping of attributes to form "good" relation schemas There are two levels: Logical Level --- How users interpret the relation schemas and the meaning of their attributes Implementation level --- How the tuples in a base relation are stored and updated

Outline We first discuss informal guidelines for good relational design Semantics of the Relation Attributes Redundant Information in Tuples and Update Anomalies Null Values in Tuples Then we discuss formal concepts of functional dependencies and normal forms

1. Semantics of the Relation Attributes Semantics of a relation refers to the interpretation of attribute values in a tuple In general, the easier it is to explain the semantics of the relation, the better the relation schema design will be

1. Semantics of the Relation Attributes Take a look of the simplified version of COMPANY relation database:

For example

1. Semantics of the Relation Attributes All relation schemas in the example may be considered as easy to explain and hence good from the standpoint of having clear semantics Bottom Line: Design a schema that can be explained easily relation by relation. The semantics of attributes should be easy to interpret.

2. Redundant Information in Tuples and Update Anomalies One goal of schema design is to minimize the storage space Bad Design:

2. Redundant Information in Tuples and Update Anomalies The previous example not only waste spaces but also cause some anomalies: Insert Anomaly Delete Anomaly Modify Anomaly

2. Redundant Information in Tuples and Update Anomalies Consider the relation: Insert Anomaly: For a new employee, you have to assign NULL to projects Cannot insert a project unless an employee is assigned to it.

2. Redundant Information in Tuples and Update Anomalies Consider the relation: Delete Anomaly: If we delete from EMP_DEPT an employee tuple that happens to represent the last employee, the information containing that department is lost from the database

2. Redundant Information in Tuples and Update Anomalies Consider the relation: Modify Anomaly: If we change the value of the manager of department 5, we must update the tuples of all employees who work in the department

2. Redundant Information in Tuples and Update Anomalies GUIDELINE 2: Design a schema that does not suffer from the insertion, deletion and update anomalies. If there are any anomalies present, then note them so that applications can be made to take them into account.

3. Null Values in Tuples As far as possible, avoid placing attributes in a base relation whose values may frequently be NULL For example: if only 10% of employees have individual offices, DO NOT include a attribute OFFICE_NUMBER in the EMPLOYEE relation Rather, a relation EMP_OFFICES(ESSN, OFFICE_NUMBER) can be created. (just like WEAK entity type)

Outline We first discuss informal guidelines for good relational design Then we discuss formal concepts of functional dependencies and normal forms - 1NF (First Normal Form) - 2NF (Second Normal Form) - 3NF (Third Normal Form)

Functional Dependency Definition: a Functional Dependency, denoted by X -> Y holds if whenever two tuples have the same value for X, they must have the same value for Y

Functional Dependency Written as X -> Y; can be displayed graphically on a relation schema as in Figures. ( denoted by the arrow) Social security number determines employee name SSN -> ENAME

Functional Dependency Social security number determines employee name SSN -> ENAME Project number determines project name and location PNUMBER -> {PNAME, PLOCATION} Employee ssn and project number determines the hours per week that the employee works on the project {SSN, PNUMBER} -> HOURS

Functional Dependency Bad Design:

Normalization of Relations The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations Normal form: Condition using keys and FDs of a relation to certify whether a relation schema is in a particular normal form

List of Normal Forms First Normal Form (1NF) 2NF, 3NF 4NF 5NF Atomic values 2NF, 3NF based on primary keys 4NF based on keys, multi-valued dependencies 5NF based on keys, join dependencies

Practical Use of Normal Forms Most practical relational design projects take one of the following two approaches: Perform a conceptual schema design using a conceptual model (ER, EER) and map the conceptual design into relations Design the relations based on external knowledge derived from an existing implementation of files (or reports)

Practical Use of Normal Forms Normalization is carried out in practice so that the resulting designs are of high quality and meet the desirable properties The database designers need not normalize to the highest possible normal form (usually up to 3NF, BCNF or 4NF)

Definitions of Keys and Attributes Participating in Keys 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.

Definitions of Keys and Attributes Participating in Keys If a relation schema has more than one key, each is called a candidate key. One of the candidate keys is arbitrarily designated to be the primary key A Prime attribute must be a member of some candidate key A Nonprime attribute is not a prime attribute—that is, it is not a member of any candidate key.

First Normal Form Historically, it is designed to disallow composite attributes multivalued attributes Or the combination of both All the values need to be atomic

First Normal Form

First Normal Form To normalize into 1NF, we have the following 3 techniques: Remove the attribute Dlocations that violates 1NF and place it in a separate relation Expand the key (10.8 C). In this case, the PK become the combination of {Dnumber, Dlocation} If the max number of values is known, then we can replace the violate attribute by the max number atomic attributes, such as, Dlocation1, Dlocation2, Dlocation3…

Second Normal Form In this example, {Ssn, Pnummber} -> Hours is a fully dependency However, the dependency {Ssn, Pnumber}->Ename is partial because Ssn->Ename holds

Second Normal Form A relation schema R is in second normal form (2NF) if every non-prime attribute A in R is fully functionally dependent on the primary key A functional dependency X->Y is a partial dependency if some attribute A belong X can be removed from X and the dependency still holds

Second Normal Form If the primary key contains a single attribute, it is 2NF Normalization into 2NF: If a relation schema is not in 2NF, it can be normalized into a number of 2NF relations where nonprime attributes are associated with only with the part of the primary key on which they are fully functionally dependent

Second Normal Form

Third Normal Form A relation schema R is in third normal form (3NF) if it is in 2NF and no non-prime attribute A in R is transitively dependent on the primary key Transitive functional dependency: a FD X -> Z that can be derived from two FDs X -> Y and Y -> Z

Third Normal Form Examples: SSN -> DMGRSSN is a transitive FD Since SSN -> DNUMBER and DNUMBER -> DMGRSSN hold SSN -> ENAME is non-transitive Since there is no set of attributes X where SSN -> X and X -> ENAME

Third Normal Form

Normal Forms Defined Informally 1st normal form All attributes depend on the key 2nd normal form All attributes depend on the whole key 3rd normal form All attributes depend on nothing but the key

SUMMARY OF NORMAL FORMS based on Primary Keys

Practice Based on the given primary key, is this relation in 1NF, 2NF, or 3NF? Why or why not? How would you successively normalize it completely?