The Relational Model Chapter Two. 2 Chapter Objectives Learn the conceptual foundation of the relational model Learn the conceptual foundation of the.

Slides:



Advertisements
Similar presentations
The Relational Model DB Chapter 2 (and some from chapter 4, 5) J.G. Zheng June 27 th 2005.
Advertisements

The Relational Model J.G. Zheng May 15 th Introduction Edgar F. Codd, 1970 One sentence to explain relational database model: Data are organized.
BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
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.
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.
Fundamentals, Design, and Implementation, 9/e Chapter 4 The Relational Model and Normalization.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 9.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke Database Processing Chapter 6 Transforming Data.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
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 6-1 COS 346 Day 8.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 COS 346 Day 7.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke Database Processing Chapter 3 Normalization.
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.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 COS 346 Day4.
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.
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.
Data Modeling and Entity- Relationship Model I IST2101.
Database Architecture The Relational Database Model.
N. J. Taylor Database Management Systems (DBMS) 1.
Chapter 3 The Relational Model and Normalization
Chapter 4 The Relational Model.
XP Class Objectives – 9/10 and 9/12 Learn how to design a small database Understand the goals of a database Understand the terminology of database design.
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
Fundamentals, Design, and Implementation, 9/e. Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 4/2 Copyright.
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.
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.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T5: Designing Database Applications Business Driven Technology.
Chapter 2. The Relational Model IST2101. Chapter 1 Review Potential problems with Lists – Deletion – Update – Insertion Avoid these problems using a relational.
The Relational Model J.G. Zheng Jan 2010 CIS 8040 Database Management Systems.
Chapter 2. The Relational Model (cont.)
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
3. Relational Model Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets 1.
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.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 What Makes Determinant Values Unique? A determinant is unique in.
THE RELATIONAL MODEL I IST 210: Organization of Data IST210 1.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
© 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.
Concepts of Database Management, Fifth Edition Chapter 6: Database Design 2: Design Methodology.
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.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Logical Database Design and Relation Data Model Muhammad Nasir
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
Chapter 9 Part-1: Concepts & Foreign Keys
Databases Chapter 16.
The Relational Model and Database Normalization
The Relational Model Chapter Two DATABASE CONCEPTS, 3rd Edition
Database Management Systems (DBMS)
Database Processing: David M. Kroenke’s Chapter Six:
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.
Database Processing: David M. Kroenke’s Chapter Six:
Chapter 4 The Relational Model and Normalization
Database Processing: David M. Kroenke’s Chapter Six:
Presentation transcript:

The Relational Model Chapter Two

2 Chapter Objectives Learn the conceptual foundation of the relational model Learn the conceptual foundation of the relational model Understand how relations differ from nonrelational tables Understand how relations differ from nonrelational tables Learn basic relational terminology Learn basic relational terminology Learn the meaning and importance of keys, foreign keys, and related terminology Learn the meaning and importance of keys, foreign keys, and related terminology Understand how foreign keys represent relationships Understand how foreign keys represent relationships

3 Chapter Objectives (continued) Learn the purpose and use of surrogate keys Learn the purpose and use of surrogate keys Learn the meaning of functional dependencies Learn the meaning of functional dependencies Learn to apply a process for normalizing relations Learn to apply a process for normalizing relations

4 Entity An entity is something of importance to a user that needs to be represented in a database An entity is something of importance to a user that needs to be represented in a database An entity represents one theme or topic 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 In an entity-relationship model (discussed in Chapter 4), entities are restricted to things that can be represented by a single table

5 Relation A relation is a two-dimensional table that has specific characteristics A relation is a two-dimensional table that has specific characteristics The table dimensions, like a matrix, consist of rows and columns The table dimensions, like a matrix, consist of rows and columns

6 Characteristics of a Relation Rows contain data about an entity Rows contain data about an entity Columns contain data about attributes of the entity Columns contain data about attributes of the entity Cells of the table hold a single value Cells of the table hold a single value All entries in a column are of the same kind All entries in a column are of the same kind Each column has a unique name Each column has a unique name The order of the columns is unimportant The order of the columns is unimportant The order of the rows is unimportant The order of the rows is unimportant No two rows may be identical No two rows may be identical

7 A Sample Relation EmployeeNumberFirstNameLastName 100MaryAbermany 101JerryCaldera 104AleaCopley 107MuruganJacksoni

8 A Nonrelation Example EmployeeNumberPhoneLastName , Abermany Caldera Copley Jacksoni Cells of the table hold multiple values

9 EmployeeNumberPhoneLastName Abermany Caldera Copley Abermany Jacksoni No two rows may be identical A Nonrelation Example

10 A Sample Relation

11 A Nonrelation Example

12 A Nonrelation Example

13 A Sample Relation

14 Terminology TableRowColumn File or Datafile RecordField RelationTupleAttribute Synonyms…

15 A Key A key is one (or more) columns of a relation that is (are) used to identify a row A key is one (or more) columns of a relation that is (are) used to identify a row

16 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.

17 A Composite Key A composite key is a key that contains two or more attributes 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 For a key to be unique, often it must become a composite key

18 Composite Key Example To identify a family member, you need to know a FamilyID, a FirstName, and a Suffix (e.g., Jr.) To identify a family member, you need to know a FamilyID, a FirstName, and a Suffix (e.g., Jr.) The composite key is: The composite key is: (FamilyID, FirstName, Suffix) (FamilyID, FirstName, Suffix) One needs to know the value of all three columns to uniquely identify an individual One needs to know the value of all three columns to uniquely identify an individual

19 A Candidate Key A candidate key is called “candidate” because it is a candidate to become the primary key A candidate key is called “candidate” because it is a candidate to become the primary key A candidate key is a unique key A candidate key is a unique key

20 A Primary Key A primary key is a candidate key chosen to be the main key for the relation 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 If you know the value of the primary key, you will be able to uniquely identify a single row

21 Relationship Notation EMPLOYEE (EmployeeNumber, FirstName, LastName, Department, , Phone) DEPARTMENT (DeptName, BudgetCode, OfficeNumber)

22 Specifying Primary Keys EMPLOYEE (EmployeeNumber, FirstName, LastName, Department, , Phone) DEPARTMENT (DeptName, BudgetCode, OfficeNumber)

23 Relationships Between Tables A table may be related to other tables A table may be related to other tables For example For example An Employee works in a Department An Employee works in a Department A Manager controls a Project A Manager controls a Project

24 A Foreign Key To preserve relationships, you may need to create 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 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 The key is called a foreign key in the table that received the key

25 Foreign Key Example PROJECT ProjID ProjName MgrIDMANAGERMgrID MgrName Foreign Key Primary Key PROJECT (ProjID, ProjName, MgrID)MANAGER (MgrID, MgrName)

26 DEPARTMENT DeptID DeptName LocationEMPLOYEEEmpID DeptID EmpName Foreign Key Primary Key Foreign Key Example DEPARTMENT (DeptID, DeptName, Location) EMPLOYEE (EmpID, DeptID, EmpName)

27 Referential Integrity Referential integrity states that every value of a foreign key must match a value of an existing primary key Referential integrity states that every value of a foreign key must match a value of an existing primary key For example (see previous slide) 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 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 The primary key value must exist before the foreign key value is entered

28 Referential Integrity EQUIPMENT (SerialNumber, Type, AcquisitionCost)

29 EQUIPMENT (SerialNumber, Type, AcquisitionCost, EmployeeNumber) Suppose Equipment can be assigned to Employees. Primary key of EMPLOYEE is EmployeeNumber. Constraint: EmployeeNumber in EQUIPMENT must exist in EmployeeNumber in EMPLOYEE

30 A Surrogate Key A Surrogate Key is a unique, numeric value that is added to a relation to serve as the Primary 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 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 A Surrogate Key is often used in place of a composite primary key

31 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 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 FamilyID, FirstName and Suffix remain in the relation Referential Integrity: Referential Integrity:Use… (FamMemberID) in School must exist in (FamMemberID) in School must exist in (FamMemberID) in FamilyMember Instead of: (FamilyID, FirstName, Suffix) in School must exist in (FamilyID, FirstName, Suffix) in FamilyMember

32 Surrogate Key Example Landscaping company – has tables: PROPERTY (Street, City, State, Zip) PLANT (ItemNumber, VarietyName, Price) SERVICE (InvoiceNumber, Date, TotalHours)

33

34

35 The Relationships A plant is sold for a particular property. A plant is sold for a particular property. A service is rendered for a particular property. A service is rendered for a particular property. PROPERTY (Street, City, State, Zip) PLANT (ItemNumber, VarietyName, Price, Street, City, State, Zip) SERVICE (InvoiceNumber, Date, TotalHours, Street, City, State, Zip)

36 The Constraints (Street, City, State, Zip) in PLANT must exist in (Street, City, State, Zip) in PROPERTY (Street, City, State, Zip) in SERVICE must exist in (Street, City, State, Zip) in PROPERTY

37 Fixing the Mess That’s a lot of duplication in each table. Let’s add surrogate keys to the tables. PROPERTY (PropertyID, Street, City, State, Zip) PLANT (ItemNumber, VarietyName, Price, PropertyID) SERVICE (InvoiceNumber, Date, TotalHours, PropertyID)

38 The New Constraints PropertyID in PLANT must exist in PropertyID in PROPERTY PropertyID in SERVICE must exist in PropertyID in PROPERTY

39

40