MIS2502: Data Analytics Relational Data Modeling 3

Slides:



Advertisements
Similar presentations
Database Design DB Chapter 5 J.G. Zheng June 29th 2005.
Advertisements

Data Design The futureERD - CardinalityCODINGRelationshipsDefinition.
Database Fundamentals Lecture 5. The Design Process continued.
Terms - data,information, file record, table, row, column, transaction, concurrency Concepts - data integrity, data redundancy, Type of databases – single-user,
MIS2502: Data Analytics Relational Data Modeling
Review Session What is data, what is information, and give a real world example to differentiate these two concepts.
MIS2502: Data Analytics Coverting ERD into a DB Schema David Schuff
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
1 A Guide to MySQL 2 Database Design Fundamentals.
SQL 1: GETTING INFORMATION OUT OF A DATABASE MIS2502 Data Analytics.
Object Persistence Design Chapter 13. Key Definitions Object persistence involves the selection of a storage format and optimization for performance.
Customer Order Order Number Date Cust ID Last Name First Name State Amount Tax Rate Product 1 ID Product 1 Description Product 1 Quantity Product 2 ID.
MIS2502: Data Analytics SQL – Getting Information Out of a Database David Schuff
Btec National - Advanced Databases 1 Advanced Databases Entity Relationship Diagrams.
Lesson 2: Designing a Database and Creating Tables.
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Data Analytics SQL – Putting Information Into a Database David Schuff
RELATIONAL DATA MODELING MIS2502 Data Analytics. What is a model? Representation of something in the real world.
Btec National - IT SYSTEMS ANALYSIS AND DESIGN 1 IT Systems Analysis and Design Entity Relationship Diagrams.
MIS2502: Data Analytics SQL – Getting Information Out of a Database.
MIS2502: Data Analytics Relational Data Modeling David Schuff
Microsoft Access 2010 Chapter 11 Database Design.
Entity Modeling Pratt & Adamski, Ch 6. The Pratt and Adamski approach is not a standard MIS view. Design Methodology Data Modeling.
Exam 2 Review: SQL In, Dimensional Modeling, Pivot Tables, ETL Describe data cube elements Understand facts, dimensions, granularity Create/read a Star.
Hoi Le. Why database? Spreadsheet is not good to: Store very large information Efficiently update data Use in multi-user mode Hoi Le2.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Order Database – ER Diagram
Let try to identify the conectivity of these entity relationship
How to: SQL By: Sam Loch.
Intro to MIS – MGS351 Relational Database Design
A Guide to SQL, Eighth Edition
Revised: 2 April 2004 Fred Swartz
Order Database – ER Diagram
MIS2502: Data Analytics SQL – Putting Information Into a Database
Basic Database Design COSC 2328 – Web Programming.
MIS2502: Data Analytics Relational Data Modeling
Database Normalization
Order Database – ER Diagram
Order Database – ER Diagram
MIS5101: Business Intelligence Relational Data Modeling
MIS2502: Data Analytics SQL – Putting Information Into a Database
Order Database – ER Diagram
MIS2502: Data Analytics SQL – Getting Information Out of a Database
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Data Analytics SQL – Putting Information Into a Database
MIS2502: Review for Exam 1 JaeHwuen Jung
MIS2502: Data Analytics SQL – Getting Information Out of a Database
5.02 Understand database queries, forms, and reports used in business.
MIS2502: Data Analytics Converting ERDs to Schemas
MIS2502: Data Analytics SQL – Getting Information Out of a Database Part 2: Advanced Queries Aaron Zhi Cheng
MIS3500 * Asper School of Business * Travica
RELATIONAL DATABASES AND XML
MIS2502: Data Analytics Relational Data Modeling
Schema Template Employee Office EmployeeOffice EmployeeID OfficeID
Order Database – ER Diagram
MIS2502: Data Analytics SQL – Putting Information Into a Database
MIS2502: Data Analytics Relational Data Modeling
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
MIS2502: Review for Exam 1 Aaron Zhi Cheng
MIS2502: Data Analytics SQL – Putting Information Into a Database
Order Database – ER Diagram
MIS2502: Data Analytics SQL – Putting Information Into a Database
ER Diagram Master How to use this template
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Data Analytics SQL 4– Putting Information Into a Database
MIS2502: Data Analytics Relational Data Modeling 2
MIS2502: Data Analytics SQL – Getting Information Out of a Database Part 1: Basic Queries Aaron Zhi Cheng
MIS2502: Data Analytics SQL – Getting Information Out of a Database Part 2: Advanced Queries Zhe (Joe) Deng
Presentation transcript:

MIS2502: Data Analytics Relational Data Modeling 3 Zhe (Joe) Deng deng@temple.edu http://community.mis.temple.edu/zdeng

Recall Our Four Steps of Modeling ER Diagram (Entity Relationship Diagram) Problem Statement Transactional Database Database Schema Transactional Database

Implementing the ERD As a Database Schema A map of the tables and fields in the database This is what is implemented in the database management system Part of the “design” process A schema actually looks a lot like the ERD Entities become tables Attributes become fields Relationships can become additional tables

many:many relationships The Rules 1. Create a table for every entity 2. Create table fields for every entity’s attributes 3. Implement relationships between the tables 1:1 relationships Put primary key field of one table into other table as foreign key field 1:many relationships Primary key field of “1” table put into “many” table as foreign key field many:many relationships Create new table 1:many relationships with original tables

The ERD Based on the Problem Statement

Our Order Database schema Original 1:m relationship Customer CustomerID FirstName LastName City State Zip Order OrderNumber CustomerID OrderDate OrderProduct OrderProductID OrderNumber ProductID Quantity Product ProductID ProductName Price Original m:m relationship OrderProduct is a decomposed many-to-many relationship OrderProduct has a 1:m relationship with Order and Product Now an order can have multiple products, and a product can be associated with multiple orders

The Customer and Order Tables: The 1:m Relationship Customer Table CustomerID FirstName LastName City State Zip 1001 Greg House Princeton NJ 09120 1002 Lisa Cuddy Plainsboro 09123 1003 James Wilson Pittsgrove 09121 1004 Eric Foreman Warminster PA 19111 Customer ID is a foreign key in the Order table. We can associate multiple orders with a single customer! In the Order table, Order Number is unique; Customer ID is not! Order Table Order Number OrderDate Customer ID 101 3-2-2011 1001 102 3-3-2011 1002 103 3-4-2011 104 3-6-2011 1004

The Customer and Order Tables: Normalization Customer Table CustomerID FirstName LastName City State Zip 1001 Greg House Princeton NJ 09120 1002 Lisa Cuddy Plainsboro 09123 1003 James Wilson Pittsgrove 09121 1004 Eric Foreman Warminster PA 19111 No repeating orders or customers. Every customer is unique. Every order is unique. This is an example of normalization.. Order Table Order Number OrderDate Customer ID 101 3-2-2011 1001 102 3-3-2011 1002 103 3-4-2011 104 3-6-2011 1004

To figure out who ordered what Match the Customer IDs of the two tables, starting with the table with the foreign key (Order): We now know which order belonged to which customer This is called a join Order Table Customer Table Order Number OrderDate Customer ID FirstName LastName City State Zip 101 3-2-2011 1001 Greg House Princeton NJ 09120 102 3-3-2011 1002 Lisa Cuddy Plainsboro 09123 103 3-4-2011 104 3-6-2011 1004 Eric Foreman Warminster PA 19111

The Customer and Order Tables: The m:m Relationship OrderProduct Table Order Table Product Table

To figure out what each order contains Match the Product IDs and Order IDs of the tables, starting with the table with the foreign keys (Order-Product): OrderProduct Table Order Table Product Table Order ProductID Order Number Product ID Quantity Order Date Customer ID Product Name Price 1 101 2251 2 3-2-2011 1001 Cheerios 3.99 2282 3 Bananas 1.29 2505 Eggo Waffles 2.99 4 102 5 3-3-2011 1002 6 103 3-4-2011 7 104 8 3-6-2011 1004 So which customers ordered Eggo Waffles (by their Customer IDs)?

This is denormalized data Denormalization refers to reversing the effect of normalization by joining normalized relations The redundant data seems harmless, but: What if the price of “Eggo Waffles” changes? And what if Greg House changes his address? And if there are 1,000,000 records? necessary for querying but bad for storage…

Summary of Database Schema Draw the corresponding schema of an ERD Identify tables based on entities and relationships Implement primary key/foreign key relationships Decompose many-to-many relationships in an ERD into one-to-many relationships in the schema Best practices for normalization Be able to match up (join) multiple tables

Time for our 3rd ICA!