Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)



Similar documents
CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

MCQs~Databases~Relational Model and Normalization

Fundamentals of Database System

DATABASE NORMALIZATION

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Normalization of Database

Functional Dependencies

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

CS143 Notes: Normalization Theory

DATABASE MANAGEMENT SYSTEMS. Question Bank:

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

Databases What the Specification Says

RELATIONAL DATABASE DESIGN

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

BCA. Database Management System

Database Design and Normalization

DATABASE SYSTEMS. Chapter 7 Normalisation

Database Constraints and Design

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

IT2305 Database Systems I (Compulsory)

Database Design Methodology

Theory of Relational Database Design and Normalization

Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Design of Relational Database Schemas

If it's in the 2nd NF and there are no non-key fields that depend on attributes in the table other than the Primary Key.

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Functional Dependencies and Finding a Minimal Cover

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

The University of British Columbia

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

Schema Refinement, Functional Dependencies, Normalization

Normal forms and normalization

Normalization. CIS 3730 Designing and Managing Data. J.G. Zheng Fall 2010

Chapter 10 Functional Dependencies and Normalization for Relational Databases

Database Management System

Chapter 10. Functional Dependencies and Normalization for Relational Databases

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

IT2304: Database Systems 1 (DBS 1)

Chapter 7: Relational Database Design

Relational Database Design

Introduction to normalization. Introduction to normalization

Lecture 2 Normalization

CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

Theory of Relational Database Design and Normalization

SQL Server. 1. What is RDBMS?

The class slides, your notes, and the sample problem that we worked in class may be helpful for reference.

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005

Database Design and Normal Forms

Normalisation 6 TABLE OF CONTENTS LEARNING OUTCOMES

Functional Dependency and Normalization for Relational Databases

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Normalization. Normalization. Normalization. Data Redundancy

The process of database development. Logical model: relational DBMS. Relation

Relational Database Design: FD s & BCNF

Module 5: Normalization of database tables

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

Graham Kemp (telephone , room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

DBMS. Normalization. Module Title?

Normalization. Functional Dependence. Normalization. Normalization. GIS Applications. Spring 2011

Normalization in Database Design

normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

Normalization. CIS 331: Introduction to Database Systems

C# Cname Ccity.. P1# Date1 Qnt1 P2# Date2 P9# Date9 1 Codd London Martin Paris Deen London

Tutorial on Relational Database Design

Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.

1.264 Lecture 10. Data normalization

Database Normalization. Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center

Objectives, outcomes, and key concepts. Objectives: give an overview of the normal forms and their benefits and problems.

Database Management Systems. Redundancy and Other Problems. Redundancy

Chapter 6. Database Tables & Normalization. The Need for Normalization. Database Tables & Normalization

Schema Refinement and Normalization

DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF)

Fundamentals of Database Design

Relational Database Basics Review

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

Limitations of DB Design Processes

The Relational Data Model: Structure

Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015

Chapter 7: Relational Database Design

Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

Part 6. Normalization

Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Introduction This document s purpose is to define Microsoft SQL server database design standards.

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

Database Design Final Project

Normalization in OODB Design


7. Databases and Database Management Systems

Physical Database Design and Tuning

1. Physical Database Design in Relational Databases (1)

Improving Data Quality in Relational Databases: Overcoming Functional Entanglements

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

Transcription:

Announcements IT0: Database Management and Organization Normalization (Chapter 3) Department coin design contest deadline - February -week exam Monday, February 1 Lab SQL SQL Server: ALTER TABLE tname ADD COLUMN newcol int NOT NULL SQL is hot! http://money.cnn.com/galleries/00/news/00/gallery.jobs_in_demand/.html Facebook Relational databases are accessed in much the same way across the board: SQL. Learning how SQL works is crucial to getting anything done in databases, and any GUI is largely a wrapper around the SQL statements one uses to make those actions happen. Knowing a little about database design (layout, B-trees, file storage, normalization) is good, mostly for helping you understand good queries. We run the LAMP stack here, so we primarily use MySQL databases across the site. I hope this helps a little. Another good motivation may be found in the requirements for most engineering positions here on http://www.facebook.com/jobs.php#opportunities ;) Database Design Process Requirements analysis Conceptual design: Entity-Relationship Model Logical design: transform ER model into relational schema Schema refinement: Normalization Physical tuning Goal Understand normal forms 1

Premise Data Redundancy We have one or more tables with data The data is to be stored in a new database QUESTION: keep or change tables structure? 3 31 15 son 1 Rule: All mids with same have the same ( ) Problems due to data redundancy? Modification Anomalies Deletion Anomaly: What if we delete all mids in 5? Insertion Anomaly: What if we want to record the fact the for 1 is? Update Anomaly: What if we change the for to be 3? Update Anomalies The MID table before and after an incorrect update operation on for = 3 31 15 son 3 31 1 1 5 15 son Table decomposition Decisions Number LastName FirstName 3 31 1 Do we have to decompose / merge? 15 son 3 31 15 son 1 1 How do we identify problems caused by redundancy? Functional dependencies Disadvantage?

Functional Dependency (FD) X Y (X determines Y) If same value for X then same value for Y Examples: Any primary key Alpha (Name, Class, DateOfBirth) EmployeeRating Wage (NbHours, HourlyPrice) Charge Functional Dependency (FD) Rules If A (B, C), then A B and A C If (A,B) C, then neither A nor B determines C by itself A and B determine C FD Facts A functional dependency is a statement about all allowable instances of a table You cannot find the functional dependencies simply by looking at some data: Data set limitations Must be logically a determinant Given some data in a table R, we can check if it violates some FD, but we cannot tell if the FD holds over R! Functional Dependencies in the MIDSHIPMAN Table Assuming data is representative, determine the FD Alpha 1113 1138 11 118 1311 10908 11198 19 1983 LastName Mikalson son Jefferson FirstName Sarah Michael t Sarah Major IEA IFA IFA IEA Advisor Lewis Jones Skapanski Skapanski Lefferton Jones Lewis Lefferton Lefferton Functional Dependencies in the MIDSHIPMAN Table Alpha (LastName, FirstName, Major, Advisor) Advisor Major What Makes Determinant Values Unique? A determinant is unique in a relation if, and only if, it determines every other column in the relation Unique determinants = superkey 3

Key A set of columns is a key for a relation if : 1. a) No two distinct rows can have same values in all key columns or equivalently Normal Forms Relations are categorized as a normal form based on which modification anomalies or other problems that they are subject to: b) determines all of the other columns in a relation. This is not true for any subset of the key Candidate key = key Primary key, Alternate key Normal Forms Number Last Name 3 31 15 son First Name 1 Eliminating Modification Anomalies from Functional Dependencies in Relations 1NF A table that qualifies as a relation is in 1NF Boyce-Codd Normal Form (BCNF) A relation is in BCNF if every determinant is a (candidate) key Put all relations into Boyce-Codd Normal Form (BCNF): I swear to construct my tables so that all nonkey columns are dependent on the key, the whole key and nothing but the key, so help me Codd. Putting a Relation into BCNF: ASSIGNMENT_GRADES Alpha 19 19 19 1 1 1 1993 1993 1993 Assignment QUIZ QUIZ QUIZ Points.5 18 8 0 PointsTotal 0 0 0 Putting a Relation into BCNF: ASSIGNMENT_GRADES ASSIGNMENT_GRADES (Alpha, Assignment, Points, PointsTotal) (Alpha, Assignment) (Points, PointsTotal) Assignment (PointsTotal) ASSIGNMENT (Assignment, PointsTotal) GRADES (Alpha, Assignment, Points) Where GRADES.Assignment must exist in ASSIGNMENT.Assignment

Putting a Relation into BCNF: New Relations Redundancy Example Alpha 19 Assignment Points PartKit Part, PartKit Price 19 QUIZ.5 Assignment PointsTotal 19 1 QUIZ 1 QUIZ 0 1 18 1993 1993 QUIZ 8 1993 0 Multivalued Dependencies Eliminating Anomalies from Multivalued Dependencies Multivalued dependencies are not a problem if they are in a separate relation, so: Always put multivalued dependencies into their own relation This is known as Fourth Normal Form (NF) Normalize or Not? Customer(CustID, Name, City, State, Zip) Assuming that city and state determine zip code, is Customers table in BCNF? If Customers table is not in BCNF, would you or would you not normalize it to BCNF? Give one reason for the choice you make Class Exercise R(A, B, C, D, E, F) A (B,C,D,E,F) B C (D,E) F Is A a key? Why? Is R in BCNF? Why? If R not in BCNF, decompose to BCNF 5

Class Exercise ID 1 3 5 Name son Chris Brown Ric Crabbe University Cornell MIT Ithaca College USNA Cornell USNA Example of deletion anomaly? Do these FDs hold? Why? ID University Name ID University MainCampus MainCampus Name MainCampus Ithaca Boston Ithaca Annapolis Ithaca Annapolis Summary Modification anomalies Functional dependency X Y (X determines Y) Unique determinant (candidate) key 1NF A table that qualifies as a relation is in 1NF Boyce-Codd Normal Form (BCNF) A relation is in BCNF if every determinant is a (candidate) key NF Multivalued dependencies are in a relation by themselves