The Relational Model Chapter Two DATABASE CONCEPTS, 3rd Edition

Slides:



Advertisements
Similar presentations
The Relational Model J.G. Zheng May 15 th Introduction Edgar F. Codd, 1970 One sentence to explain relational database model: Data are organized.
Advertisements

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.
The Relational Model Chapter Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 7 th Edition.
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.
Structured Query Language Chapter Three Part 3 – Inserts, Updates, Deletes.
The Relational Model Chapter Two Functional Dependency.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke Database Processing Chapter 6 Transforming Data.
The Relational Model CIS 218. Entity A Person, Place, Thing or Transaction Something the user wants to track.
Getting Started (Excerpts) Chapter One DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
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.
Structured Query Language Chapter Three (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’S DATABASE CONCEPTS, 2 nd Edition.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Getting Started Chapter One DATABASE CONCEPTS, 7th Edition
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
Thomas Connolly and Carolyn Begg’s
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
N. J. Taylor Database Management Systems (DBMS) 1.
Chapter 3 The Relational Model and Normalization
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Working with Queries in Microsoft Access The Access Workbench: Section Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
Database Design Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd 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.
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.
Chapter 2. The Relational Model IST2101. Chapter 1 Review Potential problems with Lists – Deletion – Update – Insertion Avoid these problems using a relational.
Getting Started Chapter One DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
The Relational Model J.G. Zheng Jan 2010 CIS 8040 Database Management Systems.
Chapter 2. The Relational Model (cont.)
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
+ 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.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
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: F undamentals, Design, and Implementation Chapter Three: The Relational Model and Normalization.
CSIS 115 Database Design and Applications for Business
CSIS 115 Database Design and Applications for Business
Chapter 9 Part-1: Concepts & Foreign Keys
The Relational Model and Database Normalization
ISQS 6339, Business Intelligence Database vs. Data Warehouse
Chapter 5: Logical Database Design and the Relational Model
CSIS 115 Database Design and Applications for Business
Database Management Systems (DBMS)
Chapter 4 Relational Databases
Databases and Information Management
Chapter 9 Designing Databases
part 1 with pages 1-32 and part 2 with pages 33-69
Chapter 9 Part-1: Concepts & Foreign Keys
Database Processing: David M. Kroenke’s Chapter Six:
Database Processing: David M. Kroenke’s Chapter Three:
Databases and Information Management
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
Database Processing: David M. Kroenke’s Chapter Six:
Chapter 4 The Relational Model and Normalization
Database Processing: David M. Kroenke’s Chapter Six:
Getting Started Chapter One DATABASE CONCEPTS, 4th Edition
Presentation transcript:

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

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 KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Chapter Objectives (continued) Learn the purpose and use of surrogate keys Learn the meaning of functional dependencies Learn to apply a process for normalizing relations KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson 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 KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson 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 KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Characteristics of a Relation Rows contain data about an entity Columns contain data about attributes of the entity Cells of the table hold a single value All entries in a column are of the same kind Each column has a unique name The order of the columns is unimportant The order of the rows is unimportant No two rows may be identical KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

A Sample Relation EmployeeNumber FirstName LastName 100 Mary Abernathy 101 Jerry Cadley 104 Alex Copley 107 Megan Jackson KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

A Nonrelation Example Cells of the table hold multiple values EmployeeNumber Phone LastName 100 335-6421, 454-9744 Abernathy 101 215-7789 Cadley 104 610-9850 Copley 107 299-9090 Jackson KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

A Nonrelation Example No two rows may be identical EmployeeNumber Phone LastName 100 335-6421 Abernathy 101 215-7789 Cadley 104 610-9850 Copley 107 299-9090 Jackson KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Terminology Synonyms… Table Row Column File Record Field Relation Tuple Attribute KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

A Key A key is one (or more) columns of a relation that is (are) used to identify a row KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Uniqueness of Keys Unique Key Nonunique 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 (3rd Edition) © 2008 Pearson Prentice Hall

A Composite Key A composite key is a key that contains two or more attributes For a key to be unique, often it must become a composite key KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Composite Key Example 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 (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson Prentice Hall

Defining the Primary Key in Microsoft Access KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Defining the Primary Key in Microsoft SQL Server 2005 KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Defining the Primary Key in MySQL KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson 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 of forms, queries and reports A Surrogate Key is often used in place of a composite primary key KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson 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 KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson Prentice Hall

Foreign Key Example Project ProjID ProjName MgrID Manager MgrID MgrName Primary Key Foreign Key KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Foreign Key Example Department DeptID DeptName Location Employee EmpID EmpName Primary Key Foreign Key KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Referential Integrity Referential integrity states that every value of a foreign key must match a value of an existing primary key For 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 (3rd Edition) © 2008 Pearson Prentice Hall

Referential Integrity Another perspective… The value of the Foreign Key EmployeeID in EQUIPMENT must exist in The values of the Primary Key EmployeeID in EMPLOYEE KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Foreign Keys in Microsoft Access KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Foreign Keys in Microsoft SQL Server 2005 KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Foreign Keys in MySQL KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson Prentice Hall

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 (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson Prentice Hall

Primary Key and Functional Dependency Example (EmployeeID) (EmpLastName, EmpPhone) (ProjectID) (ProjectName, StartDate) KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Normalization Normalization is 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 (3rd Edition) © 2008 Pearson 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 (3rd Edition) © 2008 Pearson Prentice Hall

Normalization Example (StudentID) (StudentName, DormName, DormCost) However, if… (DormName) (DormCost) Then DormCost should be placed into its own relation, resulting in the relations: (StudentName, DormName) (StudentID) (DormName) (DormCost) KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

Normalization Example (AttorneyID,ClientID) (ClientName, MeetingDate, Duration) However, if… (ClientID) (ClientName) Then ClientName should be placed into its own relation, resulting in the relations: (AttorneyID,ClientID) (MeetingDate, Duration) (ClientName) (ClientID) KROENKE and AUER - DATABASE CONCEPTS (3rd Edition) © 2008 Pearson Prentice Hall

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