CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak www.cs.sjsu.edu/~mak.

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

1 Logical Database Design and the Relational Model Modern Database Management.
The Relational Model System Development Life Cycle Normalisation
Monash University Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems.
Normalization of Database Tables
Systems Development Life Cycle
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
© 2005 by Prentice Hall Chapter 3a Database Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
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 of Database Tables
Chapter 5 Normalization of Database Tables
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
NORMALIZATION N. HARIKA (CSC).
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 5 Normalization of Database Tables
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
IS 325 Notes for Wednesday September 18, 2013.
Web-Enabled Decision Support Systems
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Functional Dependence An attribute A is functionally dependent on attribute(s) B if: given a value b for B there is one and only one corresponding value.
Concepts and Terminology Introduction to Database.
Chapter 5: Logical Database Design and the Relational Model
Database Systems: Design, Implementation, and Management Tenth Edition
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
Lecture 12 Designing Databases 12.1 COSC4406: Software Engineering.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
10/3/2012ISC329 Isabelle Bichindaritz1 Logical Design.
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.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Unit 4 Object Relational Modeling. Key Concepts Object-Relational Modeling outcomes and process Relational data model Normalization Anomalies Functional.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
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 of Database Tables
Logical Database Design and the Relational Model.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 3: LOGICAL DATABASE.
8-1 © Prentice Hall, 2007 Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Lecture 4: Logical Database Design and the Relational Model 1.
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Logical Database Design and Relational Data Model Muhammad Nasir
CS 160 and CMPE/SE 131 Software Engineering March 10 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Logical Database Design and the Rational Model
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
Chapter 5: Logical Database Design and the Relational Model
CMPE Database Systems Workshop Review: May 2 – 16, 2017
CMPE 226 Database Systems February 21 Class Meeting
CS 174: Server-Side Web Programming February 12 Class Meeting
Chapter 9 Designing Databases
CS 174: Server-Side Web Programming February 14 Class Meeting
Relational Database.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
CMPE/SE 131 Software Engineering March 9 Class Meeting
Review of Week 3 Relation Transforming ERD into Relations
CMPE/SE 131 Software Engineering March 7 Class Meeting
Presentation transcript:

CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Entity Integrity Constraint  No primary key column of a relational table can have null (empty) values. 2 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Entity Integrity Constraint, cont’d 3 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Foreign Keys  A foreign key is a column in a table that refers to a primary key column in another table.  In a relational schema, draw an arrow from the foreign key to the corresponding primary key. 4

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping 1:M Relationships 5 The foreign key on the M side of the 1:M relationship corresponds to the primary key on the 1 side. Mandatory participation on both sides. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping 1:M Relationships, cont’d 6 Optional participation on the 1 side. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping 1:M Relationships, cont’d 7 Optional participation on the M side. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping 1:M Relationships, cont’d 8 Rename a foreign key to better reflect the role of a relationship. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping M:N Relationships 9 Use the bridge relation BELONGSTO with two foreign keys. AKA: link table join table Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping M:N Relationships, cont’d 10 Optional participation on both sides. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping M:N Relationships, cont’d 11 Relationship with an attribute. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping 1:1 Relationships  Map 1:1 relationships similarly to 1:M relationships.  One table will have a foreign key pointing to the primary key of the other table.  It can be an arbitrary choice of which table has the foreign key. Make the choice that is most intuitive or efficient. 12

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping 1:1 Relationships, cont’d 13 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN Table VEHICLE has the foreign key.

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Referential Integrity Constraint  The value of a foreign key must either: Match one of the values of the primary key in the referred table. Be null. 14 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #1: ER Diagram 15 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #1: Relational Schema 16 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #1: Sample Data 17 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Candidate Keys 18 Choose one of the candidate keys to be the primary key. Map the other candidate keys as non-primary. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Candidate Keys, cont’d 19 Generally choose a non-composite candidate key as the primary key. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Multivalued Attributes 20 Map the multivalued attribute as a new table. This becomes a 1:M relationship with the new table on the M side. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Derived Attributes  Do not map derived attributes. 21 As seen by the front-end application. Sample data records. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #2: Attributes 22 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Unary 1:M Relationships 23 The table contains a foreign key that corresponds to its own primary key. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Unary M:N Relationships 24 Use a bridge relation where both foreign keys refer to the primary key of the same table. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Unary 1:1 Relationships 25 Map similarly to a unary 1:M relationship. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Multiple Relationships 26 Map each relationship. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Weak Entities  Map weak entities the same way you map regular entities.  The resulting table has a composite primary key that is composed of: The partial identifier of the table. The foreign key corresponding to the primary key of the owner table. 27

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Weak Entities, cont’d 28 The APARTMENT table’s composite primary key consists of AptNo (the partial key) and BuildingID (the foreign key corresponding the the primary key of the owner BUILDING table). Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #3: ER Diagram 29 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #3: Relational Schema 30 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #3: Sample Data 31 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Mapping Example #3: Sample Data, cont’d 32 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Relational Database Constraints  A constraint is a rule that a relational database must satisfy in order to be valid.  Two types of constraints: implicit constraints user-defined constraints 33

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Implicit RDB Constraints  Each relation in a relational schema must have a unique name.  For each relation: Each column name must be unique. Each row must be unique. Each column of each row must be single-valued. Domain constraint: All values in a column must be from the same predefined domain. The column order is irrelevant. The row order is irrelevant. 34

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Implicit RDB Constraints, cont’d  Primary key constraint: Each relation must have a primary key (a column or set of columns) whose value is unique for each row.  Entity integrity constraint: No primary key column can have a null value.  Referential integrity constraint: In each row containing a foreign key, either the value of the foreign key must match one of the values of the primary key of the referred table, or the foreign key is null. 35

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak User-Defined RDB Constraints  Optional attributes  Mandatory foreign key Example: Each employee must report to a department.  Exact cardinalities Example: A student can take at most 5 classes.  Business rules Usually enforced by front-end applications. Example: Each organization must have both male and female students. 36

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak User-Defined RDB Constraints, cont’d 37 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak ER Modeling and Relational Modeling  Why not skip ER modeling and go directly to logical modeling (creating relational schemas)?  ER modeling is better for visualizing requirements.  Certain concepts can be visualized graphically only in an ER diagram.  Every attribute appears only once in an ER diagram.  An ER model is better for communication and documentation. 38

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Break  Name: Sudhakar Kamanboina   phone:

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Database Update Operations  Insert operation Enter new data into a table.  Delete operation Remove data from a table.  Modify operation Change existing data in a table. 40

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Update Anomalies  Insertion anomaly  Deletion anomaly  Modification anomaly 41

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak A Table Containing Redundant Data 42 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak A Table Containing Redundant Data, cont’d 43 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Update Anomalies, cont’d 44 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Normalization  Normalize tables to eliminate update anomalies.  Normalization is based on the concept of functional dependencies. 45

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies  Functional dependency: The value of one or more columns in each row of a table determines the value of another column in the same row.  Write A  B Column(s) A functionally determines column(s) B. 46 ClientId  ClientName Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies, cont’d 47 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies, cont’d 48 (Set 1) CampaignMgrID  CampaignMgrName But not the reverse! Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies, cont’d 49 (Set 2) ModeID  Media, Range But neither Media nor Range determine ModeID. Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies, cont’d 50 (Set 3) AdCampaignID  AdCampaignName, StartDate, Duration, CampaignMgrId, CampaignMgrName Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies, cont’d 51 (Set 4) AdCampaignName  AdCampaignID, StartDate, Duration, CampaignMgrID, CampaignMgrName Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies, cont’d 52 (Set 5) AdCampaignID, ModeID  AdCampaignName, StartDate, Duration, CampaignMgrID, CampaignMgrName, Media, Range, BudgetPctg Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Functional Dependencies, cont’d 53 (Set 6) AdCampaignName, ModeID  AdCampaignID, StartDate, Duration, CampaignMgrID, CampaignMgrName, Media, Range, BudgetPctg Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Trivial Functional Dependencies  Remove trivial function dependencies (FDs): A  A A, B  A, B A, B  A 54

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Augmented Functional Dependencies  If A  B, then remove augmented FDs such as A, C  B  Because replace with 55 (Set 5) AdCampaignID, ModeID  AdCampaignName, StartDate, Duration, CampaignMgrID, CampaignMgrName, Media, Range, BudgetPctg (Set 5) AdCampaignID, ModeID  BudgetPctg (Set 2) ModeID  Media, Range (Set 3) AdCampaignID  AdCampaignName, StartDate, Duration, CampaignMgrId, CampaignMgrName

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Equivalent Functional Dependencies  Equivalent FDs: A  B B  A A  B, X B  A, X Y, A  B, X Y, B  A, X  Remove all but one from each equivalence set. 56

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Equivalent Functional Dependencies  Because are equivalent: FD Sets 3 and 4 are equivalent: Remove Set 4 FD Sets 5 and 6 are equivalent: Remove Set 6 57 AdCampaignID  AdCampaignName AdCampaignName  AdCampaignID Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Streamlined Functional Dependencies 58 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Partial Key Functional Dependency  A table column is functionally dependent on a component of a composite primary key. 59 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN (Set 2) ModeID  Media, Range (Set 3) AdCampaignID  AdCampaignName, StartDate, Duration, CampaignMgrId, CampaignMgrName

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Full Key Functional Dependency  A table column is functionally dependent on the primary key and not partially dependent on any separate component of the primary key. 60 (Set 5) AdCampaignID, ModeID  BudgetPctg Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Transitive Functional Dependency  A nonkey column is functionally dependent on another nonkey column. 61 CampaignMgrID  CampaignMgrName Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Another Functional Dependencies Example 62 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Normalization  Improve the design of database tables. Eliminate update anomalies.  Three normal forms. First normal form (1NF) Second normal form (2NF) Third normal form (3NF)  From lower to higher, each normal form has increasingly stricter conditions. Even higher normal forms mostly of theoretical value. Boyce-Codd (BCNF), 4NF, 5NF, domain key (DKNF). 63

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak First Normal Form (1NF)  A table is in 1NF if: Each row is unique. All values in a column must be from the same predefined domain. No column in any row contains multiple values.  In other words, any valid relational table is, by definition, in 1NF. 64

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak First Normal Form (1NF), cont’d 65 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Second Normal Form (2NF)  A table is in 2NF if: It is in 1NF. It does not contain partial functional dependencies. 66

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Second Normal Form (2NF), cont’d 67 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Third Normal Form (3NF)  A table is in 3NF if: It is in 2NF. It does not contain transitive functional dependencies. 68

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Third Normal Form (3NF), cont’d 69 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Third Normal Form (3NF), cont’d 70 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Third Normal Form (3NF), cont’d 71 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Third Normal Form (3NF), cont’d 72 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Another Normalization Example 73 Original table Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Another Normalization Example, cont’d 74 2NF Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Another Normalization Example, cont’d 75 3NF Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Another Normalization Example, cont’d 76 Normalized tables Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Normalization vs. Denormalization  Normalization spreads data out over more tables.  The result is slower performance.  Sometimes it make sense to denormalize in order to improve performance. 77

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Normalization vs. Denormalization, cont’d 78 Original table Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Normalization vs. Denormalization, cont’d  Suppose the query is to retrieve for each campaign: AdCampaignID, AdCampaignName, CampaignMgrID, CampaignMgrName, ModeID, Media, Range, and BudgetPctg.  It is more efficient to retrieve this data from the original table than from the several normalized tables. 79

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Normalization vs. Denormalization, cont’d 80 Database Systems by Jukić, Vrbsky, & Nestorov Pearson 2014 ISBN

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Assignment #3  Create the first draft of the logical data model (relational schema) for your project. Map your ER diagram from Assignment #2. You can modify the diagram or create a new one.  Implement your relational model as a physical model by creating a MySQL database.  Normalize your tables to 3NF.  Populate the tables with some sample data. 81

Computer Engineering Dept. Fall 2015: September 16 CMPE 226: Database Systems © R. Mak Assignment #3, cont’d  Create a zip file named after your team that contains: Latest requirements. Latest ER diagram. Relational schema (created using ERDPlus). Dump of your implemented MySQL database.  as an attachment to Subject: CMPE 226 Assignment #3 Team Name  Due Tuesday, September 22 at 11:59 PM 82