MIS 3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 1 © Akhilesh Bajaj, 2000, 2002, 2003.

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

primary key constraint foreign key constraint
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Manipulating Functional Dependencies Zaki Malik September 30, 2008.
Chapter 11 Functional Dependencies. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.11-2 Topics in this Chapter Basic Definitions Trivial.
1 Design Theory. 2 Minimal Sets of Dependancies A set of dependencies is minimal if: 1.Every right side is a single attribute 2.For no X  A in F and.
Chapter 3 Notes. 3.1 Functional Dependencies A functional dependency is a statement that – two tuples of a relation that agree on some particular set.
Temple University – CIS Dept. CIS616– Principles of Data Management V. Megalooikonomou Functional Dependencies (based on notes by Silberchatz,Korth, and.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Integrity Constraints.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Lecture #16: Schema Refinement & Normalization - Functional Dependencies.
Cs3431 Constraints Sections 6.1 – 6.5. cs3431 Example CREATE TABLE Student ( sNum int, sName varchar (20), prof int, CONSTRAINT pk PRIMARY KEY (snum),
Integrity Constraints
Chapter 7: Relational Database Design. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Chapter 7: Relational Database Design First Normal.
CMSC424: Database Design Instructor: Amol Deshpande
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Databases 6: Normalization
Functional Dependencies CS 186, Spring 2006, Lecture 21 R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Functional Dependencies Prof. Yin-Fu Huang CSIE, NYUST Chapter 11.
Department of Computer Science and Engineering, HKUST Slide 1 Comp 231 Database Management Systems Comp 231 Database Management Systems 6. Integrity Constraints.
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.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Chapter 7: Relational Database Design. 7.2Unite International CollegeDatabase Management Systems Chapter 7: Relational Database Design Features of Good.
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
Relational Database Design by Relational Database Design by Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
Schema Refinement and Normal Forms Chapter 19 1 Database Management Systems 3ed, R.Ramakrishnan & J.Gehrke.
Functional Dependencies An example: loan-info= Observe: tuples with the same value for lno will always have the same value for amt We write: lno  amt.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 1 ©Akhilesh Bajaj, 2000, 2002, 2003, All.
BCNF & Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
CS 564 Database Management Systems: Design and Implementation Discussion Session Friday, Sept 18, Apul Jain.
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.
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos – A. Pavlo Lecture#16: Schema Refinement & Normalization.
1 Dept. of CIS, Temple Univ. CIS616/661 – Principles of Data Management V. Megalooikonomou Integrity Constraints (based on slides by C. Faloutsos at CMU)
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Minimum Cover of F. Minimal Cover for a Set of FDs Minimal cover G for a set of FDs F: –Closure of F = closure of G. –Right hand side of each FD in G.
1 Functional Dependencies. 2 Motivation v E/R  Relational translation problems : –Often discover more “detailed” constraints after translation (upcoming.
Chapter 2 Introduction to Relational Model. Example of a Relation attributes (or columns) tuples (or rows) Introduction to Relational Model 2.
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
Functional Dependencies R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another. Thomas Hobbes ( )
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications Lecture #16: Schema Refinement & Normalization - Functional Dependencies.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
IST Database Normalization Todd Bacastow IST 210.
Ch 7: Normalization-Part 1
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
MIS3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003,2004.
© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
©Silberschatz, Korth and Sudarshan6.1Database System Concepts Chapter 6: Integrity Constraints Domain Constraints Referential Integrity Assertions Triggers.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Relational Database Design by Dr. S. Sridhar, Ph. D
Chapter 19 (part 1) Functional Dependencies
CSC 453 Database Systems Lecture
Database.
Presentation transcript:

MIS 3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 1 © Akhilesh Bajaj, 2000, 2002, All Rights Reserved.

Goals Today Learn about integrity constraints - domain constraints - referential integrity Learn about functional dependencies - Definition - Armstrong’s axioms - 3 additional rules - Closure of an attribute set (useful in computing super keys and candidate keys)

Integrity Constraints Rules that ensure that the data in the database faithfully represents the real world. Information in the real world follows rules that make it consistent. Data should follow these rules also. Examples of Rules A class A employee cannot make less than a class B employee All salaries must be over the minimum wage An employee has one and only one manager.

Integrity Constraints One way of ensuring data integrity is to trust the end-users to always input correct data. E.g., The data operator will make sure when they input data, that everyone makes minimum wage at least, and that every employee has one and only one manager. This is a bad idea! All it needs is a few bad data items to mess up queries & reports. All database management systems provide some support for managing automated checking of integrity constraints. The basic idea is that the database designer puts checks and balances into the design, so as to ensure, as far as possible, the integrity of the data at any point in time.

Integrity Constraints Domain Constraints: The CHECK clause in SQL-92 allows the designer to specify that the values (of each row) in a column of a table need to follow certain conditions. E.g.,..... CONSTRAINT wage-value-test CHECK(VALUE>=5.25)..... CONSTRAINT account-type-test CHECK(VALUE IN (‘Checking’, ‘Saving’)).

Integrity Constraints Referential Integrity This type of constraint ensures that a value that appears in one column must also appear in another column (of another table). Used when there are common columns across tables. E.g., An r_ssn value cannot show up in the area_edits table, unless it already exists in the researchers table. This implies that the r_ssn column in the area_edits table is referentially dependent on the column in the researchers table.

Integrity Constraints Referential Integrity Consider the referential integrity of r_ssn in area_edits table and researchers table. We say that the r_ssn in the area_edits table is a foreign key, dependent on the r_ssn in the researchers table. Foreign keys are usually dependent on columns that are primary keys in the other table. Note that the foreign key can also be the primary key (or part of the primary key) in its own table. This is the case with r_ssn in area_edits.

Integrity Constraints Referential Integrity What happens if we insert a new row in the area_edits table? What happens if we delete a row in the researchers table? What happens if we delete a row in the area_edits table? What happens if we update a value of r_ssn in the area_edits table?

Integrity Constraints Support in SQL: The PRIMARY KEY clause in SQL tells the DBMS to treat a column (or maybe many columns) as the primary key for that table. Note that the primary key is always unique and non-null. The FOREIGN KEY clause in SQL tells the DBMS to treat the column as a foreign key, referencing another table. In addition, there is a UNIQUE clause that tells the DBMS that all values in a column must be unique. The NOT NULL clause tells the system that NULL values are not allowed in the column.

Functional Dependencies If the values in a column, or columns, functionally determine the values in another column, or columns, then a functional dependency exists between the first set of columns and the second. We use the --> operator to indicate that the Right Hand Side (RHS) is functionally dependent on the Left Hand Side (LHS). Example: r_ssn --> r_name, r_address, r_phone, r_institution is a FD on the researchers table. Functional dependencies exist ON a table (NOT ACROSS TABLES).

Functional Dependencies Functional dependency implies that if the same values occur on the LHS, then the same value will occur on the RHS. Note: If this sounds confusing, review the mathematical definition of a function. r_ssn --> r_name, r_address, r_phone, r_institution A superkey of a table is a column, or columns, such that the entire table (all columns) are functionally dependent on this column, or columns. Thus, the following holds on all tables: Superkey --> ALL columns of table. Recall that, for each table, candidate keys are a subset of all the superkeys of that table. Also, the primary key is an element of the set of candidate keys for the table. What does this say about candidate and primary keys?

Functional Dependencies Some examples of FDs in the POP schema:

Functional Dependencies Armstrong’s Axioms Reflexivity rule If RHS is a subset of LHS, then always LHS--> RHS. E.g., r_name, r_address --> r_name Augmentation Rule Adding the same columns to both sides is allowed. E.g.,r_ssn, art_num --> r_name, r_institution,art_num Transitivity Rule If A--> B and B--> C then A--> C. E.g., r_ssn-->r_name and r_name-->r_phone implies that r_ssn --> r_phone

Functional Dependencies Some theorems that come out of the Axioms Union Rule: If A --> B and A--> C, then A --> BC. Proof: Decomposition Rule: IF A --> BC then A --> B and A --> C. Proof:

Functional Dependencies Some theorems that come out of the Axioms Pseudotransitivity Rule: If A-->B and BC-->D then AC-->D. Proof: Notes: 1. AB --> CD DOES NOT IMPLY that A-->CD OR that B-->CD So we can split the RHS, but not the LHS. 2. A superkey functionally determines all the attributes of a table.

Functional Dependencies Closure of Attribute Sets: Used to test whether a set of columns is a superkey or not, for a table. The closure of a column, or columns, is all the columns in the table that are functionally determined by that column or columns. The closure of a superkey is all the columns of the table. Simple algorithm to find the closure, for, say, attributes A and B (“attributes” is the same as “columns”): result := AB WHILE(changes to result) DO FOR EACH FD on the table IF LHS in result, then result := result + RHS ENDFOR ENDWHILE

Functional Dependencies Examples from the POP schema: