Data Models and Relational Databases Chapter 2. Learning Objectives Identify primary and foreign keys for each entity and relevant relationships in the.

Slides:



Advertisements
Similar presentations
BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Advertisements

Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Accounting System Design
1 Logical Database Design and the Relational Model Modern Database Management.
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.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Entity-Relationship Model and Diagrams (continued)
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Accounting Databases Chapter 2 The Crossroads of Accounting & IT
Modern Systems Analysis and Design Third Edition
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 3: Data Modeling
Implementing an REA Model in a Relational Database
Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 18-1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Chapter 4 Relational Databases.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Introduction to Databases
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
PHASE 3: SYSTEMS DESIGN Chapter 7 Data Design.
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
1 DATABASE TECHNOLOGIES BUS Abdou Illia, Fall 2007 (Week 3, Tuesday 9/4/2007)
Chapter 4: Logical Database Design and the Relational Model (Part II)
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Introduction to Accounting Information Systems
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.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Concepts and Terminology Introduction to Database.
FILE VS. DATABASES Let’s examine some basic principles about how data are stored in computer systems. – An entity is anything about which the organization.
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
Avoiding Database Anomalies
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
A Normalisation Example Mark Kelly McKinnon Secondary College Vceit.com Based on work by Robert Timmer-Arends.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
Implementing an REA Model in a Relational Database
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
System Design System Design - Mr. Ahmad Al-Ghoul System Analysis and Design.
Implementing an REA Model in a Relational Database
Unit 4 Object Relational Modeling. Key Concepts Object-Relational Modeling outcomes and process Relational data model Normalization Anomalies Functional.
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
© 2005 by Prentice Hall 1 The Database Development Process Dr. Emad M. Alsukhni The Database Development Process Dr. Emad M. Alsukhni Modern Database Management.
Chapter 13 Designing Databases Systems Analysis and Design Kendall & Kendall Sixth Edition.
Relational Theory and Design
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
CHAPTER 4 Relational Databases. Learning Objectives Explain the importance and advantages of databases Describe the difference between database systems.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
IS 320 Notes for April 15, Learning Objectives Understand database concepts. Use normalization to efficiently store data in a database. Use.
Logical Database Design and the Relational Model.
1 DATABASE TECHNOLOGIES (Part 2) BUS Abdou Illia, Fall 2015 (September 9, 2015)
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.
6-1 © Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 18-1.
8-1 © Prentice Hall, 2007 Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Microsoft Access 2010 Chapter 11 Database Design.
Lecture 4: Logical Database Design and the Relational Model 1.
Database Planning Database Design Normalization.
Implementing an REA Model in a Relational Database
Chapter 4 Relational Databases
Chapter 9 Designing Databases
Relational Database.
Presentation transcript:

Data Models and Relational Databases Chapter 2

Learning Objectives Identify primary and foreign keys for each entity and relevant relationships in the data model, Create tables that are properly linked with foreign keys or through relationship table(s), Examine a table design for any anomalies, and Normalize a table to the third normal form.

The Database Development Process Begins with enterprise modeling  Setting the range and general contents of organizational databases Follows with conceptual data modeling  Analyzing overall entities’ requirements based on transaction cycles Involves with logical database design  Transforming the conceptual data model into a logical data model using relational data models

Enterprise Modeling

Conceptual Data Modeling

Complete REA Diagram for Cherokee’s Revenue Cycle Resource EventsAgents

Structure of a Relational Database The primary construct is called a relation or a table.  Constructed with rows and columns much like a spreadsheet.  Each table represents either an entity or a relationship between entities.  Tables must be properly linked to make a relational database. The columns in a table are called fields.  Fields represent the attributes or characteristics of the entity or relationship. The rows in a table are called records or tuples.  Records represent all the specific data values that are associated with one instance.

Primary and Foreign Keys Primary key The attributes (column) or combination of attributes (multiple columns) that uniquely identifies a specific row in a table. Foreign key An attribute appearing in one table that is a primary key in another table. Foreign key is used to link tables

Basic Requirements of Tables The Entity Integrity Rule The Referential Integrity Rule Each attribute must be uniquely named. Values of a specific attribute must be of the same type. Each attribute (column) of a record (row) must be single- valued.

Steps of Implementing an REA Diagram in a Relational Database Step 1: Create a table for each entity Step 2: Create a table for each many-to-many relationship Step 3: Examine tables with a one-to-one relationship Step 4: Identify the attributes and assign the primary key for each table (note that a relationship table uses two columns as the primary key – concatenated key) Step 5: Assign non-key attributes to tables Step 6: Implement relationships using foreign keys

Implementing an REA Diagram in a Relational Database Implement relationships using foreign keys One-to-One (1:1): Include the primary key of the first entity as the foreign key in the second entity (Note: it does not matter which primary key becomes the foreign key). One-to-Many (1:N or N:1): Place the primary key of the entity with the maximum cardinality of N as a foreign key in the entity that has a maximum cardinality of 1

Revised REA Data Model

Database Anomalies and Normalization If a table is not well-designed, problems (anomalies) arise. Three types of anomalies:  Update anomaly causes problems when every occurrence of a data item is not updated.  Insert anomaly causes difficulties (sometimes impossibility) to insert new data into a table without violating the basic integrity rules.  Delete anomaly involves unintended loss of data that occurs when deleting a record in a table.

Customer IDLast Name First NamePhone No. Product IDQuantityUnit Selling Price 10001BlairDiane(408) P-33011$ BlairDiane(408) P-54903$ BlairDiane(408) P $ SandersonTed(510) P-54902$ SandersonTed(510) P-54985$ RyanBird(562) P-33017$ RyanBird(562) P-54982$ RyanBird(562) P $15.99 Suppose Ted Sanderson changes his phone number. You need to make the change two times. If you fail to change it in both places or change it incorrectly in one place, then the records for Ted will be inconsistent. This problem is referred to as an update anomaly.

What if there is a new product to add but no customers have purchased it yet? Can we add the new product? Why or why not? This problem is referred to as an insert anomaly. What is the primary key for this table? Customer IDLast Name First NamePhone No. Product IDQuantity Unit Selling Price 10001BlairDiane(408) P-33011$ BlairDiane(408) P-54903$ BlairDiane(408) P $ SandersonTed(510) P-54902$ SandersonTed(510) P-54985$ RyanBird(562) P-33017$ RyanBird(562) P-54982$ RyanBird(562) P $15.99

Assume that Bird has filed bankruptcy and you decide to delete her record from the table. If Bird is the only customer that purchased item P-7119, deleting Bird’s record will also delete any information pertaining to P If there are any other requests for this product in the future, the product info will not be available. This problem is referred to as a delete anomaly. Customer IDLast Name First NamePhone No. Product IDQuantity Unit Selling Price 10001BlairDiane(408) P-33011$ BlairDiane(408) P-54903$ BlairDiane(408) P $ SandersonTed(510) P-54902$ SandersonTed(510) P-54985$ RyanBird(562) P-33017$ RyanBird(562) P-54982$ RyanBird(562) P $15.99

Normalization One solution to avoid anomalies is to normalize the table by separating the table into a set of smaller tables. Normalization is a formal process to determine which attributes should be grouped together in a table. It validates the logical design to avoid any violation of database requirements. Each entity is stored in a table and we use foreign keys or relationship tables to link the entities together.

Steps in Normalization Step 1: Remove any repeating groups (First Normal Form) Step 2: Remove any partial dependencies (Second Normal Form) Step 3: Remove any transitive dependencies (Third Normal Form)

Example: Partial Data in a Vendor Table Vendor#Vendor Name Vendor AddressContact Name Phone#Item#DescriptionUnit Price 2010AXA, Inc.22 Heaven Wood Drive Annie White M-45Blender$15.99 K-4iPod$ Sys Co.2273 Morgan Street John Doe D-12LCD projector$ MFS46 Kings Square, #5 Rachelle Brown M-45Blender$18.00 K-4iPod$ Lazard8 Santa AnaEd King K-8DVD player$ XYZ Co.19 ColumbusLan Lee K-8DVD player$129.99

Remove repeating groups (1 st NF) Vendor#Vendor Name Vendor AddressContact Name Phone#Item#DescriptionUnit Price 2010AXA, Inc.22 Heaven Wood Drive Annie White M-45Blender$15.99 K-4iPod$ Sys Co.2273 Morgan Street John Doe D-12LCD projector$ MFS46 Kings Square, #5 Rachelle Brown M-45Blender$18.00 K-4iPod$ Lazard8 Santa AnaEd King K-8DVD player$ XYZ Co.19 ColumbusLan Lee K-8DVD player$ Vendor TableInventory Table

The data exists in separate tables Vendor#Vendor Name Vendor AddressContact Name Phone#Item#DescriptionUnit Price 2010AXA, Inc.22 Heaven Wood Drive Annie White M-45Blender$15.99 K-4iPod$ Sys Co.2273 Morgan Street John Doe D-12LCD projector$ MFS46 Kings Square, #5 Rachelle Brown M-45Blender$18.00 K-4iPod$ Lazard8 Santa AnaEd King K-8DVD player$ XYZ Co.19 ColumbusLan Lee K-8DVD player$ Vendor TableInventory Table

We must link the separate tables Using foreign keys, or Using a relationship table if it is M:N relationship using a concatenated key (two columns together as the primary key) Vendor#Item# 2010M K D M K-4 Vendor-Item Table

End of Chapter 2