The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition.

Slides:



Advertisements
Similar presentations
(wrapping up from last week)
Advertisements

Database Design Chapter Five DATABASE CONCEPTS, 6th Edition
Lab Exercise This Week PHP Basics See last Friday’s slides for requirements Make sure you show the final results to TA to get credit 1IST210.
Entity-Relationship Model
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
The Relational Model Chapter Two. 2 Chapter Objectives Learn the conceptual foundation of the relational model Learn the conceptual foundation of the.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke’s Chapter Three: The Relational Model and Normalization.
The Relational Model Chapter Two Functional Dependency.
Fundamentals, Design, and Implementation, 9/e Chapter 4 The Relational Model and Normalization.
The Relational Model CIS 218. Entity A Person, Place, Thing or Transaction Something the user wants to track.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke Database Processing Chapter 3 Normalization.
The Relational Model Chapter Two (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
David M. Kroenke and David J
Database Design Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition.
Database Design Chapter Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Getting Started with Microsoft Visio 2010 Appendix G DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Getting Started with Microsoft SQL Server 2012 Express Edition Appendix A DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
David M. Kroenke and David J. Auer Database Processing—12 th Edition Fundamentals, Design, and Implementation Chapter One: Introduction KROENKE AND AUER.
Getting Started Chapter One DATABASE CONCEPTS, 7th Edition
Entity-Relationship Model
Why Databases.
Getting Started with Microsoft Access The Access Workbench: Section One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
Structured Query Language
Getting Started with Oracle Database 11g Release 2 Express Edition Appendix B DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Chapter 3 The Relational Model and Normalization
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
Database Design Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
SQL Views Appendix E DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Database Basics CPSC 4670/ Purpose of a Database The purpose of a database is to keep track of things Unlike a list or spreadsheet, a database.
© 2002 by Prentice Hall 1 Database Design David M. Kroenke Database Concepts 1e Chapter 5 5.
Chapter 4 The Relational Model and Normalization.
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.
The Relational Model Chapter Two DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
1 Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall. Access Module 1 Workshop 2 Tables, Keys, and Relationships Series Editor Amy Kinser.
Database Design IST210 Class Lecture
Chapter 2. The Relational Model IST2101. Chapter 1 Review Potential problems with Lists – Deletion – Update – Insertion Avoid these problems using a relational.
1 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall.
The Relational Model J.G. Zheng Jan 2010 CIS 8040 Database Management Systems.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 4/1 Copyright © 2004 Please……. No Food Or Drink in the class.
+ Relational Model IST210 Class Lecture. + Premiere Products A new company that is going to sells random merchandise via sales representatives You have.
THE RELATIONAL MODEL I IST 210: Organization of Data IST210 1.
© 2002 by Prentice Hall 1 The Relational Model David M. Kroenke Database Concepts 1e Chapter 2 2.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter One: Introduction.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Three: The Relational Model and Normalization.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Appendix A: Getting Started with Microsoft Access 2013.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Appendix E: Getting Started with MySQL Workbench Data Modeling.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Three: The Relational Model and Normalization.
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Ten: Managing Databases with SQL Server 2012,
CSIS 115 Database Design and Applications for Business
The Relational Model and Database Normalization
Database Design Chapter Five DATABASE CONCEPTS, 4th Edition
The Relational Model Chapter Two DATABASE CONCEPTS, 3rd Edition
ISQS 6339, Business Intelligence Database vs. Data Warehouse
David M. Kroenke and David J
MIS 322 – Enterprise Business Process Analysis
Database Processing: David M. Kroenke’s Chapter Three:
David M. Kroenke and David J
Copyright © 2018, 2015, 20 Pearson Education, Inc. All Rights Reserved Database Concepts Eighth Edition Chapter # 2 The Relational Model.
Getting Started Chapter One DATABASE CONCEPTS, 5th Edition
Chapter 4 The Relational Model and Normalization
Getting Started Chapter One DATABASE CONCEPTS, 4th Edition
Presentation transcript:

The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition

Chapter Objectives Learn the conceptual foundation of the relational model Understand how relations differ from nonrelational tables Learn basic relational terminology Learn the meaning and importance of keys, foreign keys, and related terminology Understand how foreign keys represent relationships 2-2 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Chapter Objectives (Cont’d) Learn the purpose and use of surrogate keys Learn the meaning of functional dependencies Learn to apply a process for normalizing relations 2-3 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Entity An entity is something of importance to a user that needs to be represented in a database. An entity represents one theme or topic. In an entity-relationship model (discussed in Chapter 4), entities are restricted to things that can be represented by a single table. 2-4 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Relation A relation is a two-dimensional table that has specific characteristics. The table dimensions, like a matrix, consist of rows and columns. 2-5 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Characteristics of a Relation 1.Rows contain data about an entity. 2.Columns contain data about attributes of the entity. 3.Cells of the table hold a single value. 4.All entries in a column are of the same kind. 5.Each column has a unique name. 6.The order of the columns is unimportant. 7.The order of the rows is unimportant. 8.No two rows may be identical. 2-6 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Sample Relation 2-7 EmployeeNumberFirstNameLastName 100MaryAbernathy 101JerryCadley 104AlexCopley 107MeganJackson KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Nonrelation Example 2-8 EmployeeNumberPhoneLastName , Abernathy Cadley Copley Jackson Cells of the table hold multiple values KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Example of a Nonrelational Table 2-9 EmployeeNumberPhoneLastName Abernathy Cadley Copley Abernathy Jackson No two rows may be identical KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Terminology TableRowColumn FileRecordField RelationTupleAttribute 2-10 Synonyms… Figure 2-6: Equivalent Sets of Terms KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Key A key is one (or more) column(s) of a relation that is (are) used to identify a row KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Uniqueness of Keys 2-12 Unique KeyNonunique Key Data value is unique for each row. Consequently, the key will uniquely identify a row. Data value may be shared among several rows. Consequently, the key will identify a set of rows. KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Composite Key A composite key is a key that contains two or more attributes. For a key to be unique, it must often become a composite key KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Composite Key Characteristics To identify a family member, you need to know a FamilyID, a FirstName, and a Suffix (e.g., Jr.). The composite key is: (FamilyID, FirstName, Suffix). One needs to know the value of all three columns to uniquely identify an individual KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Candidate Key A candidate key is called “candidate” because it is a candidate to become the primary key. A candidate key is a unique key KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Primary Key A primary key is a candidate key chosen to be the main key for the relation. If you know the value of the primary key, you will be able to uniquely identify a single row KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Defining the Primary Key in Microsoft Access 2-17 Figure 2.7: Defining a Primary Key in Microsoft Access 2013 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Defining the Primary Key in Microsoft SQL Server Figure 2.8: Defining a Primary Key in Microsoft SQL Server 2014 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Defining the Primary Key in Oracle Database Express Edition 11g Release Figure 2-9: Defining a Primary Key in Oracle Database Express Edition 11g Release 2 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Defining the Primary Key in Oracle MySQL 5.6 Community Server 2-20 Figure 2-10: Defining a Primary Key in Oracle MySQL 5.6 Community Server KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Surrogate Key A surrogate key is a unique, numeric value that is added to a relation to serve as the primary key. Surrogate key values have no meaning to users and are usually hidden on forms, queries, and reports. A surrogate key is often used in place of a composite primary key KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Surrogate Key Example If the Family Member primary key is FamilyID, FirstName, Suffix, it would be easier to append and use a surrogate key of FamMemberID. FamilyID, FirstName and Suffix remain in the relation KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Relationships Between Tables A table may be related to other tables. For example –An Employee works in a Department –A Manager controls a Project 2-23 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

A Foreign Key To preserve relationships, you may need to create a foreign key. A foreign key is a primary key from one table placed into another table. The key is called a foreign key in the table that received the key KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Foreign Key Example I 2-25 Project ProjID ProjName MgrID Manager MgrID MgrName Foreign Key Primary Key KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Foreign Key Example II 2-26 Department DeptID DeptName Location Employee EmpID DeptID EmpName Foreign Key Primary Key KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Referential Integrity Referential integrity states that every value of a foreign key must match a value of an existing primary key. Example (see previous slide): –If EmpID = 4 in EMPLOYEE has a DeptID = 7 (a foreign key), a Department with DeptID = 7 must exist in DEPARTMENT. –The primary key value must exist before the foreign key value is entered KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Referential Integrity (Cont’d) Another perspective… The value of the Foreign Key EmployeeID in EQUIPMENT must exist in The values of the Primary Key EmployeeID in EMPLOYEE 2-28 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Foreign Keys in Microsoft Access Figure 2-11: Enforcing Referential Integrity in Microsoft Access 2013 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Foreign Keys in Microsoft SQL Server Figure 2-12: Enforcing Referential Integrity in Microsoft SQL Server 2014 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Foreign Keys in Oracle Database Express Edition 11g Release Figure 2-13: Enforcing Referential Integrity in Oracle Database Express Edition 11g Release 2 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Foreign Keys in Oracle MySQL 5.6 Community Server 2-32 Figure 2-14: Enforcing Referential Integrity in Oracle MySQL 5.6 Community Server KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

The Null Value A Null value means that no data was entered. This is different from a zero, space character, or tab character KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

The Problem of Null Values A Null is often ambiguous. It could mean… –The column value is not appropriate for the specific row. –The column value is not decided. –The column value is unknown. Each may have entirely different implications KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Functional Dependency Functional Dependency—A relationship between attributes in which one attribute (or group of attributes) determines the value of another attribute in the same table Illustration… –The price of one cookie can determine the price of a box of 12 cookies (CookiePrice, Qty)BoxPrice KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Determinants The attribute (or attributes) that we use as the starting point (the variable on the left side of the equation) is called a determinant (CookiePrice, Qty)BoxPrice Determinant KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Candidate/Primary Keys and Functional Dependency By definition… A candidate key of a relation will functionally determine all other attributes in the row. Likewise, by definition… A primary key of a relation will functionally determine all other attributes in the row KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Primary Key and Functional Dependency Example 2-38 (EmployeeID) (EmpLastName, EmpPhone) (ProjectID)(ProjectName, StartDate) KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Normalization Normalization—A process of analyzing a relation to ensure that it is well formed More specifically, if a relation is normalized (well formed), rows can be inserted, deleted, or modified without creating update anomalies KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Normalization Principles Relational design principles for normalized relations: –To be a well-formed relation, every determinant must be a candidate key. –Any relation that is not well formed should be broken into two or more well- formed relations KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Modification Problems Tables that are not normalized will experience issues known as modification problems. –Insertion problems Difficulties inserting data into a relation –Modification problems Difficulties modifying data into a relation –Deletion problems Difficulties deleting data from a relation 5-41 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall

Solving Modification Problems Most modification problems are solved by breaking an existing table into two or more tables through a process known as normalization KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall

Definition Review Functional dependency –The relationship (within the relation) that describes how the value of one attribute may be used to find the value of another attribute. Determinant –The attribute that can be used to find the value of another attribute in the relation –The right-hand side of a functional dependency 5-43 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall

Definition Review II Candidate key –The value of a candidate key can be used to find the value of every other attribute in the table. –A simple candidate key consists of only one attribute. –A composite candidate key consists of more than one attribute KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall

Normal Forms There are many defined normal forms: –First Normal Form (1NF) –Second Normal Form (2NF) –Third Normal Form (3NF) –Boyce-Codd Normal Form (BCNF) –Fourth Normal Form (4NF) –Fifth Normal Form (5NF) –Domain/Key Normal Form (DK/NF) 5-45 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall

Normalization to BCNF For our purposes, a relation is considered normalized when: Every determinant is a candidate key. This is Boyce-Codd Normal Form (BCNF) 5-46 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall

Normalization Example 2-47 (StudentID) (StudentName, DormName, DormCost) (DormName)(DormCost) However, if… (StudentID) (StudentName, DormName) (DormName)(DormCost) Then DormCost should be placed into its own relation, resulting in the relations: KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

Normalization Example (Cont’d) (AttorneyID, ClientID) (ClientName, MeetingDate, Duration) (ClientID)(ClientName) However, if… (ClientID) (ClientName) (AttorneyID, ClientID) (MeetingDate, Duration) Then ClientName should be placed into its own relation, resulting in the relations: 2-48 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition

The Relational Model End of Presentation on Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition