Third Normal Form And Database Design.

Slides:



Advertisements
Similar presentations
Time Sheet Training Press the F5 Key to view the Presentation. It may be helpful to have a printed copy of this slide presentation for the practice sessions.
Advertisements

Database Fundamentals
The Relational Model and Normalization (1)
The Relational Model and Normalization (2) IS 240 – Database Management Lecture # Prof. M. E. Kabay, PhD, CISSP Norwich University
Copyright: ©2005 by Elsevier Inc. All rights reserved. 1 Author: Graeme C. Simsion and Graham C. Witt Chapter 3 The Entity-Relationship Approach.
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Relational Database and Data Modeling
Relational data integrity
Normal forms - 1NF, 2NF and 3NF
Microsoft ® Office Outlook ® 2007 Training Retrieve, back up, or share messages Sweetwater ISD presents:
Information Systems Today: Managing in the Digital World
Microsoft® Access® 2010 Training
Chapter 5 Normalization of Database Tables
CHAPTER OBJECTIVE: NORMALIZATION THE SNOWFLAKE SCHEMA.
First Normal Form Second Normal Form Third Normal Form
Benchmark Series Microsoft Excel 2013 Level 2
Functional Dependencies and Normalization for Relational Databases
What is a Database By: Cristian Dubon.
 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Microsoft Access 2002 By Ian Cole Lecturer in ICT.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Database Normalization CP3410 Daryle Niedermayer, I.S.P., PMP.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Advanced Tables Lesson 9. Objectives Creating a Custom Table When a table template doesn’t suit your needs, you can create a custom table in Design view.
Database Principles Relational Database Design I.
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 4: Logical Database Design and the Relational Model (Part II)
Week 6 Lecture Normalization
Web-Enabled Decision Support Systems
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
Concepts of Database Management, Fifth Edition
Module III: The Normal Forms. Edgar F. Codd first proposed the process of normalization and what came to be known as the 1st normal form. The database.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.
Database Normalization Lynne Weldon July 17, 2000.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
1 What is database 2? What is normalization? What is SQL? What is transaction?
Normalization Information Systems II Ioan Despi. Informal approach Building a database structure : A process of examining the data which is useful & necessary.
Introduction to Databases Trisha Cummings. What is a database? A database is a tool for collecting and organizing information. Databases can store information.
Copyright © 2005 Ed Lance Fundamentals of Relational Database Design By Ed Lance.
1 A Guide to MySQL 2 Database Design Fundamentals.
M1G Introduction to Database Development 2. Creating a Database.
(Spring 2015) Instructor: Craig Duckett Lecture 10: Tuesday, May 12, 2015 Mere Mortals Chap. 7 Summary, Team Work Time 1.
M1G Introduction to Database Development 4. Improving the database design.
Microsoft Access. Microsoft access is a database programs that allows you to store retrieve, analyze and print information. Companies use databases for.
Microsoft Access 2010 Chapter 3 Maintaining a Database.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
©NIIT Normalizing and Denormalizing Data Lesson 2B / Slide 1 of 18 Objectives In this section, you will learn to: Describe the Top-down and Bottom-up approach.
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.
TOPIC 6 DATABASES CONTENT : 6.1 DATABASE DESIGN 6.2 NORMOLISATION AND DATA MODELING 6.3 METHODS AND TOOLS FOR ANALYZING AND IMPLEMENTING DATABASE DESIGN.
A337 - Reed Smith1 Structure What is a database? –Table of information Rows are referred to as records Columns are referred to as fields Record identifier.
U:/msu/course/cse/103 Day 03, Slide 1 CSE 103 Day 15: Database Design Students: –Read Day 2 in your textbook –Your BT feedback.
Database Design Process For many businesses, the database is the most important set of computer files they have. For some, like EBay or Facebook, the database.
Sample Table Standard Notation Entity name in uppercase
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Lecture 4: Logical Database Design and the Relational Model 1.
Database Planning Database Design Normalization.
Normalisation Unit 6: Databases. Just to recap  What is an Entity  What is an Attribute?
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.
1 Normalization David J. Stucki. Outline Informal Design Guidelines Normal Forms  1NF  2NF  3NF  BCNF  4NF 2.
Database Normalization
Database Normalization
System Analysis and Design
Normalization Normalization theory is based on the observation that relations with certain properties are more effective in inserting, updating and deleting.
Presentation transcript:

Third Normal Form And Database Design

Are you sick of this slide yet? Good relational database design is about optimizing how the data is STORED, not how it is DISPLAYED. Most “tables” you have seen—in books, in lectures, on the web—were probably optimized for display, not for storage. Relational database tables are designed for consistency and to reduce redundancy. They are not designed for appearance. When we learn SQL and Visual Basic, we will look at various ways to display the data stored in relational database tables.

Three Anomalies The three anomalies all are problems caused by trying to put data for more than one entity into a single table. The anomalies are: Insert Update Delete

Insert Anomaly Above is a partial table of Major League Soccer players. To save time, the database manager has put the team information into the players table. When I try to add a Detroit expansion team, Access won’t let me because I don’t yet have any players associated with the team. To add a record to this table, I must have a PlayerID to enter as the primary key. This is the insert anomaly.

Insert Anomaly Imagine you have a small store, and you are keeping all of your customer records in your orders table. One day, Bill Gates (or some other billionaire) comes in and says “I like what you’ve got for sale here. I’d like to set up an account.” You reply: “What do want to buy?” He says: “Nothing yet. But I want to be able to get something quickly when I need it.” Are you going to tell him that you can’t enter him as a customer because your (Microsoft) database won’t allow it? Putting customers and orders in different tables allows you to keep records of customers who don’t have any orders yet. Not being able to store that information is the Insert Anomaly.

Update Anomaly David Beckham’s wife decides to buy his team. You duly record this in his player record. But now you have Landon Donovan and David Beckham playing for the same team, but different owners! Your data is now inconsistent. This is the update anomaly.

Delete Anomaly Cuatehemoc Blanco suffers a career-ending injury playing for Mexico in the World Cup. Que lastima! You remove him from your MLS roster. Oh-oh! You’ve removed all your information about the Chicago Fire team as well! This is the delete anomaly.

One Entity Per Table All three anomalies result from the same cause: Putting attributes of multiple entities into a single table. Codd and others recognized this, and codified (Coddified?) the principles of table and database design that prevent this from happening. Implementing these principles is called “normalization,” and the goal of normalization is, in most cases, Third Normal Form. I will abbreviate Third Normal Form as “3NF”.

Normalization Most of the database books refer to normalization as a process—you start from some horribly messed-up database, put it through your normalizer, and out comes a proper database in 3NF. In general, I don’t think it works that way. If you are designing a new database from scratch, you can stick to the one-entity-per-table rule (and a few other rules) and create a properly normalized database the first time. I’ll outline this procedure later in the lecture.

Normal Forms Nevertheless, you should have some familiarity with the first three normal forms, even if you don’t have to go through them step-by-step. For online quiz 2 and the in-class quiz 3 next Tuesday, you will be expected to be able to identify whether a table or database is in 3NF or not. The distinctions of 1NF and 2NF will not be tested (since a table must be in both 1NF and 2NF to have a chance of being in 3NF).

First Normal Form First Normal Form is poorly defined in most books, and the books generally don’t agree with each other. It is easiest to define negatively. The next few slides will describe the things that keep a table from being in 1NF.

A table is NOT in 1NF if it doesn’t have a primary key A table without a primary key has no way to keep out duplicate entries.

A table is NOT in 1NF if cells contain multiple data items This is a fairly common beginner’s mistake. Putting multiple data items into a cell, as is done in the FriendsIDs column here, is very bad database design. It makes querying the table very difficult.

Putting Multiple Similar (Numbered) Fields in a Table Violates 1NF A very common mistake. Wastes space with all of the empty cells. And someone always comes along and signs up for six classes. And it’s hard to search! (Answering “Which students are taking IOE 373?” requires searching 5 columns.)

Having Multiple Fields That Are Similar Violates 1NF This is a variation on the previous slide. Probably a little better, but still wrong. The course fields are all instances of the “course” entity. They don’t belong in a Students table.

So what’s wrong? The last three slides are examples of trying to represent one-to-many or many-to-many relationships in a single table. That violates 1NF, not to mention 3NF. BTW, to mention 3NF—a table must be in 1NF and 2NF before it has a possibility to be in 3NF.

Second Normal Form The definition for 2NF is much clearer. To be in 2NF, a table must: Be in 1NF. Have all non-key fields be attributes of the ENTIRE key. 2NF applies only to compound keys; tables with simple keys that are in 1NF are automatically in 2NF as well.

2NF 2NF is only an issue with tables having compound primary keys. 2NF is especially important when you have a chain of tables linked by relationships between their primary keys. The basic idea with 2NF is to put an attribute into the proper table—the table in which it is a property of the entire key, no more, no less. The following two examples will hopefully make this clear.

Example: University In which table should each non-key field go?

University: Solution

Example: Invoices Where should each non-key field go?

Invoices Issues: If you don’t have different product codes for items that differ only in color or size, those two attributes could be included in OrderDetails instead. Similarly, Cost depends on whether you have fixed prices (in which case cost belongs with Products), or if your prices change with time or if certain customers or orders get discounts.

2NF Summary Second Normal Form is only an issue with compound keys (more than one field in the primary key). If a table is in 1NF and has a simple key it is automatically in 2NF. All non-key fields in a table with a compound key should be properties of the entire key (in combination)—not simply attributes of a part of the key.

Third Normal Form 3NF is also fairly straightforward. A table in 3NF must be: In 2NF; and All attributes must be attributes of the key only; the table should include no attributes of attributes. Attributes of attributes are technically referred to as “transitive dependencies”. Don’t put them in your tables!

The Golden Rule for 3NF Every non-key field in a table should depend on the key, the whole key, and nothing but the key, so help me Codd.

Online Quiz 2 It is easiest to learn 3NF by example, and I’ve prepared plenty of examples for you. There’s no outside reading for online quiz 2. Review this slide show quickly before taking the quiz. For each problem that is not in 3NF, read the feedback which explains why. Before long, you’ll be able to quickly recognize what is 3NF, and what isn’t. There are a few gray areas, and these are discussed in the quiz as well. I’ll now demonstrate the quiz and explain a few of the problems.

Last Time! Good relational database design is about optimizing how the data is STORED, not how it is DISPLAYED. Most “tables” you have seen—in books, in lectures, on the web—were probably optimized for display, not for storage. Relational database tables are designed for consistency and to reduce redundancy. They are not designed for appearance. When we learn SQL and Visual Basic, we will look at various ways to display the data stored in relational database tables.

Rarely Simple, Never Finished A reminder of a couple of things I’ve said before: Database design is as much art as science. The only database designs that are completely finished are the ones that are no longer in use. These things apply to programming as well. However, there are guidelines, like 3NF, which guide you towards creating good databases. The programming guidelines that we will be following in this class fall under the heading of “Object-Oriented Programming.” (OOP)