11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.

Slides:



Advertisements
Similar presentations
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
Advertisements

+ Review: Normalization and data anomalies CSCI 2141 W2013 Slide set modified from courses.ischool.berkeley.edu/i257/f06/.../Lecture06_257.ppt.
Functional Dependencies and Normalization for Relational Databases.
The Relational Model System Development Life Cycle Normalisation
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Normalization I.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
The Relational Model Codd (1970): based on set theory Relational model: represents the database as a collection of relations (a table of values --> file)
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Database Architecture The Relational Database Model.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 4 The Relational Model Pearson Education © 2014.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Chapter 4 The Relational Model.
DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design.
Lecture 12 Inst: Haya Sammaneh
Web-Enabled Decision Support Systems
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Concepts and Terminology Introduction to Database.
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall, Modified by Dr. Mathis 3-1 David M. Kroenke’s Chapter Three: The Relational.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
Functional Dependencies and Normalization for Relational Databases.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
1 Functional Dependencies and Normalization Chapter 15.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Lecture 3 Functional Dependency and Normal Forms Prof. Sin-Min Lee Department of Computer Science.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
Logical Database Design and the Relational Model.
IST Database Normalization Todd Bacastow IST 210.
Ch 7: Normalization-Part 1
Lecture 4: Logical Database Design and the Relational Model 1.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
11/06/97J-1 Principles of Relational Design Chapter 12.
ITD1312 Database Principles Chapter 4C: Normalization.
Logical Database Design and Relational Data Model Muhammad Nasir
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Logical Design & the Relational Model
Functional Dependency and Normalization
Normalization Karolina muszyńska
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Lecture 2 The Relational Model
Relational Database.
Database Normalization
Normalization.
Presentation transcript:

11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003

11/07/2003Akbar Mokhtarani (LBNL)2 Overview Relational Model Basics Functional Dependencies Modification Anomalies Normalization

11/07/2003Akbar Mokhtarani (LBNL)3 Relational Model Introduced by E. F. Codd in 1970 It consists of: Data structure: in the form of tables Data manipulation: operation used to manipulate data in the relations (e.g SQL) Data integrity: facilities to maintain the integrity of data when they are manipulated

11/07/2003Akbar Mokhtarani (LBNL)4 Data structure (tables) Each table consists of a set of named columns (attributes corresponding to some real-world entity) Each row corresponds to a record containing data values for a single entity attributes are single-valued and have domains (set of values)

11/07/2003Akbar Mokhtarani (LBNL)5 Properties of Relations (Not all tables are relations) A table is called a relation if: The table has a unique name Values are atomic (no repeating group) Each row is uniquely determined by a key Each attribute has a unique name The order of columns is insignificant The order of rows is insignificant

11/07/2003Akbar Mokhtarani (LBNL)6 Keys A super key is a group of one or more attributes that uniquely identifies a row Candidate keys: irreducible super keys Primary key: candidate key selected to identify the row Alternate key: candidate key other than the primary key Foreign key:a set of attributes of one relation whose values match values of some candidate key of another relation

11/07/2003Akbar Mokhtarani (LBNL)7 Example Custumer_IDCustumer_nameAddressCityStateZip Order_IDOrder_DateCustomer_ID Order_IDProduct_IDQuantity Product_IDProduct_DecriptionProduct_FinfishProd_PriceOn_Hand CUSTOMER ORDER ORDERLINE PRODUCT FK

11/07/2003Akbar Mokhtarani (LBNL)8 Integrity Constraints Major integrity constraints (business rules): Domain constraints Values in a column have the same domain (data type and size) Entity integrity Non-null primary key Referential integrity If there is a foreign key, each FK must either match the primary key value in another relation or the FK must be null Action assertions Action constraints (e.g no student can take more than 15 units per term)

11/07/2003Akbar Mokhtarani (LBNL)9 Functional Dependency (FD) (Relationship Among Attributes) A Functional Dependency is a special integrity constraint that states: FD: X  Y means if t 1.X = t 2.X then t 1.Y = t 2.Y Where: X and Y are subsets of attributes of a relation R t 1 and t 2 are tuples of any relational instance of R X is said to functionally determine Y, or Y is functionally dependent on X X is called determinant

11/07/2003Akbar Mokhtarani (LBNL)10 Functional Dependency (Cont’d) Full FD: FD X  Y is a full FD if removal of any attribute from X destroys the dependency Partial FD: FD X  Y is partial if one or more non-key attributes are determined by a subset of X

11/07/2003Akbar Mokhtarani (LBNL)11 FD Rules 1.Reflexive If X  Y, then Y  X 2.Augmentation: If X  Y, then XZ  YZ 3.Transitive: If X  Y and Y  Z, then X  z 4.Decomposition: If X  YZ, then X  Y and X  Z 5.Union: If X  Y and X  Z, then X  YZ 6.Pseudo transitive: If X  Y and WY  Z, then WX  Z

11/07/2003Akbar Mokhtarani (LBNL)12 FD Example A BCD a1b1c1d1 a1b2c2d1 a2b1c1d2 a1b1c1d2 AB  C, but AB  D

11/07/2003Akbar Mokhtarani (LBNL)13 Modification Anomalies Anomalies are unexpected side effects that occurs when modifying the contents of a table with excessive redundancies Insertion anomaly: Need to add extra data in order to add the desired data to DB Deletion anomaly: Deleting a row causes other data to be deleted Update anomaly: Need to change multiple rows to modify a single fact

11/07/2003Akbar Mokhtarani (LBNL)14 Normalization Normalization is the process of decomposing relations with anomalies to produce smaller, well structured relations It is built around the concept of Normal Forms A relation is said to be in a particular normal form if it satisfies certain conditions

11/07/2003Akbar Mokhtarani (LBNL)15 Levels of Normalization a 1NF 2NF BCNF 3NF 4NF 5NF Domain/Key NF

11/07/2003Akbar Mokhtarani (LBNL)16 A relation is in 1NF if it contains no multivalued attributes 2NF if it is in 1NF and every non-key attribute is fully functionally dependent on the PK 3NF if it is in 2NF and no transitive dependencies exit BCNF if every determinant is a candidate key

11/07/2003Akbar Mokhtarani (LBNL)17 Steps in Normalization First normal form Second normal form Third formal form Boyce-Codd normal form Table with multivalued attributes Remove Multivalued attributes Remove partial dependencies Remove remaining Anomalies resulting From FD Remove transitive dependencies

11/07/2003Akbar Mokhtarani (LBNL)18 First Normal Form This relation contains : Insertion anomaly: adding new department or class require a student to sign up for it Deletion anomaly: deleting “Lisa Gilmore” causes information about “Sociology” department and “Soc 101” class Update anomaly: if course description for “Math 105” changes, many rows need to be updated

11/07/2003Akbar Mokhtarani (LBNL)19 FD diagram SID StName Major ClassName Desc. Grade SSN

11/07/2003Akbar Mokhtarani (LBNL)20 2NF and 3NF Normal Form We still have insertion and deletion anomalies for the “Major”

11/07/2003Akbar Mokhtarani (LBNL)21 Anomaly free Form

11/07/2003Akbar Mokhtarani (LBNL)22 Another example A B C D E G 1NF B C D E GC A 2NF B C D E D GC A 3NF B C D E C D E D GC A E B BCNF Switch keys

11/07/2003Akbar Mokhtarani (LBNL)23 Relational Algebra The manipulative part of relational model is called relational algebra. It is a collection of operators that take relations as their operand and return a relation as their result. Two groups of operators: Set operators: union, intersection, difference, and cartesian product Relational operators: restrict (select), project, join, and divide.

11/07/2003Akbar Mokhtarani (LBNL)24 Set Operators Restrict: Returns a relation containing all tuples from a special relation that satisfy a specified condition. Project: Returns a relation containing all (sub)tuples that remain in a specified relation after specified attributes have been removed

11/07/2003Akbar Mokhtarani (LBNL)25 Set Operators (cont’d) Product: Returns a relation containing all possible tuples that are a combination of two tuples, one from each two specified relations. Union: Returns a relation containing all tuples that appear in either or both of two specified relations.

11/07/2003Akbar Mokhtarani (LBNL)26 Relational Operators Intersect: Returns a relation containing all tuples that appear in both of two specified relations. Difference: Returns a relation containing all tuples that appear in the first and not in the second of two specified relations.

11/07/2003Akbar Mokhtarani (LBNL)27 Relational operators (cont’d) Join:Returns a relation containing all possible tuples that are a combination of two tuples, one from each of two specified relations, such that the two tuples contributing to any given combination have a common value for the common attributes of the two relations

11/07/2003Akbar Mokhtarani (LBNL)28 Relational Operators (cont’d) Divide: Takes two unary relations and one binary relation and returns a relation containing all tuples from one unary relation that appear in the binary relation matched with all tuples in the other unary relation