Bad DB Design Duplicate of data Duplicate of data Updating Updating Deleting Deleting.

Slides:



Advertisements
Similar presentations
Database Management Systems Chapter 3 The Relational Data Model (II) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
Advertisements

Topics to be discusses Functional Dependency Key
Athabasca University Under Development for COMP 200 Gary Novokowsky
Functional Dependencies. Babies At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses, and a doctor.
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
1 The Relational Data Model Functional Dependencies.
1 Functional Dependencies Meaning of FD’s Keys and Superkeys Inferring FD’s.
1 Functional Dependencies Meaning of FD’s Keys and Superkeys Inferring FD’s Source: slides by Jeffrey Ullman.
Normalization.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Normalization. Database Normalization Database normalization is the process of removing redundant data from your tables in to improve storage efficiency,
Cambridge TEC - Level 3 Certificate/Diploma IT. ICT Dept ScenarioLO1LO2LO3.
A Guide to SQL, Eighth Edition Chapter Two Database Design Fundamentals.
Databases 1 Seventh lecture. Topics of the lecture Extended relational algebra Normalization Normal forms 2.
Normalization Goal = BCNF = Boyce-Codd Normal Form = all FD’s follow from the fact “key  everything.” Formally, R is in BCNF if for every nontrivial FD.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
Logical Database Design ( 補 ) Unit 7 Logical Database Design ( 補 )
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
1 A Guide to MySQL 2 Database Design Fundamentals.
Database Normalization.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
CORE 2: Information systems and Databases NORMALISING DATABASES.
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
1 A Guide to MySQL 2 Database Design Fundamentals.
1 5 Normalization. 2 5 Database Design Give some body of data to be represented in a database, how do we decide on a suitable logical structure for that.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
IST 210 Normalization 2 Todd Bacastow IST 210. Normalization Methods Inspection Closure Functional dependencies are key.
Normalization Is the gradual and sequential process of efficiently organizing data in a database that follows the rules listed in the previous slide –
In this session, you will learn to: Describe data redundancy Describe the first, second, and third normal forms Describe the Boyce-Codd Normal Form Appreciate.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
Normalization.
Lection №4 Development of the Relational Databases.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
Normalisation RELATIONAL DATABASES.  Last week we looked at elements of designing a database and the generation of an ERD  As part of the design and.
The Normal Forms 3NF and BCNF
NORMALIZATION. What is Normalization  The process of effectively organizing data in a database  Two goals  To eliminate redundant data  Ensure data.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
CS 405G: Introduction to Database Systems Database Normalization.
Functional Dependencies Zaki Malik September 25, 2008.
IST 220 – Intro to DB Lecture 4 Database Design thru ER Modeling.
Functional Dependencies. Babies Exercise 2.2.5: At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses,
Databases 1 Sixth lecture. 2 Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
Logical Database Design and Relational Data Model Muhammad Nasir
2006­02-08 | Database Normalization | © MySQL AB 2006 | 1 An Introduction to Database Normalization Mike Hillyer – MySQL AB.
Lecture # 17 Chapter # 10 Normalization Database Systems.
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.
Database Normalization. What is Normalization Normalization allows us to organize data so that it: Normalization allows us to organize data so that it:
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
Understanding Data Storage
Database, tables and normal forms
Design Theory for Relational Databases
INFORMATION TECHNOLOGY – INT211
CPSC-310 Database Systems
Normalization Referential Integrity
Entity relationship diagrams
Normalization By Jason Park Fall 2005 CS157A.
Multivalued Dependencies & Fourth Normal Form (4NF)
Functional Dependencies
Multivalued Dependencies
Normalization By Jason Park Fall 2005 CS157A.
Anomalies Boyce-Codd Normal Form 3rd Normal Form
Presentation transcript:

Bad DB Design Duplicate of data Duplicate of data Updating Updating Deleting Deleting

Redundant

Deleting

Update

Normalization is a design technique that is widely used as a guide in designing relational databases. Normalization is essentially a two step process that puts data into tabular form by removing repeating groups and then removes duplicated data from the relational tables. Normalization is a design technique that is widely used as a guide in designing relational databases. Normalization is essentially a two step process that puts data into tabular form by removing repeating groups and then removes duplicated data from the relational tables. Normalization theory is based on the concepts of normal forms. A relational table is said to be a particular normal form if it satisfied a certain set of constraints. There are currently five normal forms that have been defined. In this course, we will cover the first three normal forms Normalization theory is based on the concepts of normal forms. A relational table is said to be a particular normal form if it satisfied a certain set of constraints. There are currently five normal forms that have been defined. In this course, we will cover the first three normal forms Normalization

cont The goal of normalization is to create a set of relational tables that are free of redundant data and that can be consistently and correctly modified. This means that all tables in a relational database should be in the third normal form (3NF). The goal of normalization is to create a set of relational tables that are free of redundant data and that can be consistently and correctly modified. This means that all tables in a relational database should be in the third normal form (3NF).

Normalization A relational table is in 3NF if and only if all non-key columns are: A relational table is in 3NF if and only if all non-key columns are: mutually independent and mutually independent and fully dependent upon the primary key fully dependent upon the primary key Mutual independence means that no non-key column is dependent upon any combination of the other columns Mutual independence means that no non-key column is dependent upon any combination of the other columns The first two normal forms are intermediate steps to achieve the goal of having all tables in 3NF The first two normal forms are intermediate steps to achieve the goal of having all tables in 3NF In order to better understand the 2NF and higher forms, it is necessary to understand the concepts of functional dependencies In order to better understand the 2NF and higher forms, it is necessary to understand the concepts of functional dependencies

Functional Dependencies The concept of functional dependencies is the basis for the first three normal forms. A column, Y, of the relational table R is said to be functionally dependent upon column X of R if and only if each value of X in R is associated with precisely one value of Y at any given time. X and Y may be composite. Saying that column Y is functionally dependent upon X is the same as saying the values of column X identify the values of column Y. If column X is a primary key, then all columns in the relational table R must be functionally dependent upon X. The concept of functional dependencies is the basis for the first three normal forms. A column, Y, of the relational table R is said to be functionally dependent upon column X of R if and only if each value of X in R is associated with precisely one value of Y at any given time. X and Y may be composite. Saying that column Y is functionally dependent upon X is the same as saying the values of column X identify the values of column Y. If column X is a primary key, then all columns in the relational table R must be functionally dependent upon X. A short-hand notation for describing a functional dependency is: A short-hand notation for describing a functional dependency is: R.x —> R.y which can be read as in the relational table named R, column x functionally determines (identifies) column y. which can be read as in the relational table named R, column x functionally determines (identifies) column y.

Motivation: “normalization,” the process where we break a relation schema into two or more schemas. Motivation: “normalization,” the process where we break a relation schema into two or more schemas. Example: ABCD with FD’s AB ->C, C ->D, and D ->A. Example: ABCD with FD’s AB ->C, C ->D, and D ->A. Decompose into ABC, AD. What FD’s hold in ABC ? Decompose into ABC, AD. What FD’s hold in ABC ? Not only AB ->C, but also C ->A ! Not only AB ->C, but also C ->A ! AB ->C and C ->B. AB ->C and C ->B. Example: A = street address, B = city, C = zip code. Example: A = street address, B = city, C = zip code. There are two keys, {A,B } and {A,C }. There are two keys, {A,B } and {A,C }. Functional Dependencies, example

Example FD Drinkers(name, addr, drinkLiked, manf, favdrink). Drinkers(name, addr, drinkLiked, manf, favdrink). Reasonable FD’s to assert: Reasonable FD’s to assert: 1. name -> addr 2. name -> favdrink 3. drinkLiked -> manf

Example DF nameaddr drinkLiked manffavDrink JanewayVoyager Bud A.B.WickedAle JanewayVoyager WickedAle Pete’sWickedAle SpockEnterprise Bud A.B.Bud Because name -> addr Because name -> favBeer Because beersLiked -> manf

FD’s With Multiple Attributes No need for FD’s with > 1 attribute on right. No need for FD’s with > 1 attribute on right. But sometimes convenient to combine FD’s as a shorthand. But sometimes convenient to combine FD’s as a shorthand. Example: name -> addr and name -> favDrink become name -> addr favDrink Example: name -> addr and name -> favDrink become name -> addr favDrink > 1 attribute on left may be essential. > 1 attribute on left may be essential. Example: Resturnt Drink -> price Example: Resturnt Drink -> price

Example, Cont Consider relation Drinkers(name, addr, drinkLiked, manf, favdrink). Consider relation Drinkers(name, addr, drinkLiked, manf, favdrink). {name, beersLiked} is a superkey because together these attributes determine all the other attributes. {name, beersLiked} is a superkey because together these attributes determine all the other attributes. name -> addr favBeer name -> addr favBeer beersLiked -> manf beersLiked -> manf {name, drinksLiked} is a key because neither {name} nor {drinkLiked} is a superkey. {name, drinksLiked} is a key because neither {name} nor {drinkLiked} is a superkey. name doesn’t -> manf; drinkLiked doesn’t -> addr. name doesn’t -> manf; drinkLiked doesn’t -> addr.

Basic Idea To know what FD’s hold in a projection, we start with given FD’s and find all FD’s that follow from given ones. To know what FD’s hold in a projection, we start with given FD’s and find all FD’s that follow from given ones. Then, restrict to those FD’s that involve only attributes of the projected schema. Then, restrict to those FD’s that involve only attributes of the projected schema.

normalization What is normalization? Basically, it's the process of efficiently organizing data in a database. What is normalization? Basically, it's the process of efficiently organizing data in a database. There are two goals of the normalization process: There are two goals of the normalization process: Eliminate redundant data (for example, storing the same data in more than one table) and Eliminate redundant data (for example, storing the same data in more than one table) and Ensure data dependencies make sense (only storing related data in a table). Ensure data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored. Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored.

First Normalization Form 1FN Eliminate duplicative columns from the same table. BY the values in each column of a table are atomic. By atomic we mean that there are no sets of values within a column. Eliminate duplicative columns from the same table. BY the values in each column of a table are atomic. By atomic we mean that there are no sets of values within a column. Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key). Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).

exampleTitleAuthorBioISBNSubjectPagePubli Beginning MySQL Database Design and Optimization Chad Russell, Jon Stephens Chad Russell is a programmer and network administrator who owns his own Internet hosting company., MySQL, Database Design 512Apress Book (ISBN, Title, Pages) Author(Author_ID, First_Name, Last_name) Subject(Subject_ID, Name) Publisher (Publisher_ID, Name, Address, City, State, Zip) The relationship between the Book table and the Author table is a many-to-many relationship: Book_Author (ISBN, Author_ID) Book_Subject (ISBN Subject_ID) One-to-many relationship exists between the Book table and the Publisher table: Book (ISBN, Title, Pages, Publisher_ID)

Second normal form 2NF Where the First Normal Form deals with atomicity of data, the Second Normal Form (or 2NF) deals with relationships between composite key columns and non-key columns: Where the First Normal Form deals with atomicity of data, the Second Normal Form (or 2NF) deals with relationships between composite key columns and non-key columns: Meet all the requirements of the first normal form. Meet all the requirements of the first normal form. Any non-key columns must depend on the entire primary key. In the case of a composite primary key, this means that a non-key column cannot depend on only part of the composite key. Any non-key columns must depend on the entire primary key. In the case of a composite primary key, this means that a non-key column cannot depend on only part of the composite key. Create relationships between these new tables and their predecessors through the use of foreign keys. Create relationships between these new tables and their predecessors through the use of foreign keys. A relation R is in 2nf if every non-primary attribute A in R is fully Functionally dependent on the primary key. A relation R is in 2nf if every non-primary attribute A in R is fully Functionally dependent on the primary key.

Example 2NF StudentAdvisorAdv-RoomClass# MohammedMohammedMohammedSamiSamiIbrahiemKhalid Cs424Cs424Cs424Cs416Cs416Cs491Cs412 StudentClass# Cs424Cs424Cs424Cs416Cs416Cs491Cs412 StudentAdvisorAdv-Room MohammedSami Registration Student

Third normal form 3NF Remove columns that are not dependent upon the primary key. Remove columns that are not dependent upon the primary key. Third Normal Form (3NF) requires that all columns depend directly on the primary key. Third Normal Form (3NF) requires that all columns depend directly on the primary key. Example: Example: Publisher (Publisher_ID, Name, Address, City, State, Zip) Publisher (Publisher_ID, Name, Address, City, State, Zip) Zip (Zip, City, State) Zip (Zip, City, State)

Example 3NF StudentAdvisorAdv-Room MohammedSami StudentAdvisor MohammedSami In the last example, Adv-Room (the advisor's office number) is functionally dependent on the Advisor attribute. The solution is to move that attribute from the Students table to the Faculty table, as shown below: In the last example, Adv-Room (the advisor's office number) is functionally dependent on the Advisor attribute. The solution is to move that attribute from the Students table to the Faculty table, as shown below:NameRoomDepMohammedSami500501CSIT Student Faculty