MIS2502: Data Analytics Relational Data Modeling

Slides:



Advertisements
Similar presentations
More Diagramming & Practice with Relationship Modeling
Advertisements

Information System Analysis Lab 7. ERD entity-relationship diagram is a data modeling technique that creates a graphical representation of the entities,
ENTITY RELATIONSHIP MODELLING
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Concepts of Database Management Seventh Edition Chapter 6 Database Design : ERD Model.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
System Analysis - Data Modeling
Agenda for Week 1/31 & 2/2 Learn about database design
Systems Analysis and Design in a Changing World, 6th Edition
MIS2502: Data Analytics Relational Data Modeling
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
File and Database Design SYS364. Today’s Agenda WHTSA DBMS, RDBMS, SQL A place for everything and everything in its place. Entity Relationship Diagrams.
Business Process Modeling
MIS2502: Data Analytics Coverting ERD into a DB Schema David Schuff
1.  An introduction to data modelling  The purpose of data modelling  Modelling data relationships 2.
Systems Analysis and Design in a Changing World, 6th Edition 1 Chapter 4 Domain Classes.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
MIS2502: Data Analytics Relational Data Modeling
RELATIONAL DATA MODELING MIS2502 Data Analytics. What is a model? Representation of something in the real world.
MIS2502: Data Analytics Relational Data Modeling David Schuff
1 Information System Analysis Topic-3. 2 Entity Relationship Diagram \ Definition An entity-relationship (ER) diagram is a specialized graphic that illustrates.
Data Modeling and Entity-Relationship Model I
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
ENTITY RELATIONSHIP DIAGRAM. Objectives Define terms related to entity relationship modeling, including entity, entity instances, attribute, relationship.
1 Entity Relationship Approach u Top-down approach to data modeling u Uses diagrams u Normalization - confirms technical soundness u Entity Relationship.
Entity Relationship (E-R) Model
COP Introduction to Database Structures
Database Design Chapters 17 and 18.
Entity Relationship Modeling
Entity/Relationship Modelling
Data Modeling Using the ERD
Let try to identify the conectivity of these entity relationship
Business System Development
Database Development Lifecycle
Entity-Relationship Model
TMC2034 Database Concept and Design
Entity Relationship Model
MIS2502: Data Analytics Relational Data Modeling
Entity-Relationship Model
Tables and Their Characteristics
Entity-Relationship Modelling
Outline of the ER Model By S.Saha
MIS5101: Business Intelligence Relational Data Modeling
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Entity Relationship Diagram
Entity-Relationship Model and Diagrams (continued)
Entity Relationship Diagrams
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Review for Exam 1 JaeHwuen Jung
MIS2502: Data Analytics Converting ERDs to Schemas
Database Systems: Design, Implementation, and Management Tenth Edition
Entity-Relationship Modelling
Database Design Chapters 17 and 18.
MIS2502: Data Analytics Relational Data Modeling
MIS2502: Review for Exam 1 Aaron Zhi Cheng
MIS2502: Data Analytics Relational Data Modeling
CHAPTER 2 - Database Requirements and ER Modeling
Chapter 4 Entity Relationship (ER) Modeling
Entity-Relationship Diagram (ERD)
MIS2502: Data Analytics Relational Data Modeling 2
Database Management system
Database Management system
Information Systems in Organizations 2. 1
Some examples of simple business rules:
Presentation transcript:

MIS2502: Data Analytics Relational Data Modeling Aaron Zhi Cheng http://community.mis.temple.edu/zcheng/ acheng@temple.edu Acknowledgement: David Schuff

Where we are… Now we’re here… Data entry Transactional Database Data extraction Analytical Data Store Data analysis Stores real-time transactional data Stores historical transactional and summary data

Objectives Discuss the general process and goals of modeling a database Entity Relationship Diagram (ERD) Identify and define entities, relationships, and attributes Identify the different symbols used in ERD Identify cardinality symbols to used for different entity relationship types Create an ERD based on a scenario description

A Typical Database Design Process Requirement Analysis Modeling Database Creating Database Schema After this, we can then start the implementation of the database

What is a model? Representation of something in the real world

Modeling a database A representation of the information to be captured Describes the data contained in the database Explains how the data interrelates

Why bother modeling? Creates a blueprint before you start building the database Gets the story straight: easy for non-technical people to understand Minimize having to go back and make changes in the implementation stage

The Entity Relationship Diagram (ERD) The primary way of graphically modeling a relational database Three main diagrammatic elements: entities, relationships, and attributes Entity Relationship Attribute

Three Main Elements of ERD English Grammar Equivalent Entity A uniquely identifiable thing Proper Noun (e.g., person, product, student) Relationship Describes how two entities relate to one another Verb (i.e., makes, has, teaches) Attribute A descriptive characteristic of an entity or relationship Descriptive noun/Adjective (i.e., first name, age, price) And relationship has cardinality (as we will see more in a moment)

A Simple ERD Relationship Attribute Entity Attribute

How to Draw an ERD? Start with a problem statement Design a database to track orders for a store. A customer places an order for a product. People can place an order for multiple products. Record first name, last name, city, state, and zip code for customers. We also want to know the date an order was placed. Finally, we want to track the name and price of products and the quantity of each product for each order.

Begin with Identifying the Entities This is what your database is about. What’s left are your entities! List the nouns in the problem statement. Step 1 When nouns are synonyms for other nouns, choose the best one. Step 2 Make a note of nouns that describe other nouns. These will be your entities’ attributes. Step 3 Rule out the nouns that don’t relate to the process to be captured. Step 4

So here are the nouns… Which nouns are entities Design a database to track orders for a store. A customer places an order for a product. People can place an order for multiple products. Record first name, last name, city, state, and zip code for customers. We also want to know the date an order was placed. Finally, we want to track the name and price of products and the quantity of each product for each order. Which nouns are entities Which nouns are attributes? Which nouns are irrelevant?

Here’s where it gets tricky… store is not an entity because we are not tracking specific information about the store (i.e., store location) BUT…if there were many stores and we wanted to track sales by store, then store would be an entity! In this case, “store” is the context But that isn’t part of the problem statement….

The ERD Based on the Problem Statement

The primary key Entities need to be uniquely identifiable So you can tell them apart Identify a primary key One or more attributes that uniquely identifies an entity May not be explicitly part of the problem statement, but you still need to make up one! How about these as primary keys for Customer: First name and/or last name? Social security number? Customer ID Uniquely identifies a customer Uniquely identifies an order Order number

Last component: Cardinality Defines the rules of the association between entities Maximum cardinality: at most - one at most - many makes Customer Order Minimum cardinality: at least – one (mandatory) at least – zero (optional) This is a one-to-many (1:m) relationship: One customer can have many orders. One order can only belong to one customer. Additionally A customer could have no orders. An order has to belong to at least one customer.

Maximum Cardinality Maximum cardinality Describes the maximum number of entity instances that participate in a relationship Can be one or many The symbol is placed on the outside ends of the relationship line, closest to the entity

Crows Feet Notation So called because this… …looks something like this For a maximum cardinality of “one” a straight line is drawn. For a maximum cardinality of “many” a foot with three toes is drawn. There are other ways of denoting cardinality, but this one is pretty standard. So called because this… …looks something like this

Types of Relationship Determined based on the maximum cardinality at both ends of the relationship line Can be one-to-one (1:1) one-to-many (1:n or 1:m) or many-to-many (n:n or m:m)

One-to-One Relationship A single instance of one entity is related to a single instance of another entity A state has (at most) one governor A governor governs (at most) one state

One-to-Many Relationship One-to-Many (1:n or 1:m) A single instance of one entity is related to multiple instances of another entity A publisher can publish many books A book is published by (at most) one publisher (Note that the ERD is not complete yet… we will talk about other elements later on)

Many-to-Many Relationship Many-to-Many (n:n or m:m) Each instance of one entity is related to multiple instances of another entity, and vice versa A book can be written by many authors An author can write many books

Minimum Cardinality Minimums are generally stated as either zero or one: 0 (optional): participation in the relationship by the entity is optional. 1 (mandatory): participation in the relationship by the entity is mandatory. The symbols are placed on the inside, next to the diamond shape. A programmer is mandatory for a certificate); or a certificate has to be issued to (at least) one programmer. A certificate is optional for a programmer; or a programmer may not have any certificates 1:m maximum cardinality: a programmer can have many certificates; a certificate is issued to (at most) one programmer

Cardinality is defined by business rules What would the cardinality be in these situations? contains Order ? ? Product has Course ? ? Section has Employee ? ? Office

Relationship Attributes TUID Name The grade and semester describes the combination of student and course (i.e., Bob takes MIS2502 in Fall 2011 and receives a B; Sue takes MIS2502 in Fall 2012 and receives an A) Student Grade contains Semester Course Course number Course Title

Drawing ERD: A Checklist Entities Entity attributes Primary key Non-key attributes Relationships Minimum cardinality Maximum cardinality Relationship attributes

A scenario: The auto repair shop A car is described by a VIN, make, and model. A mechanic is described by a name and SSN. A repair is described by a price. A transaction occurs on a particular date. An invoice has an invoice number and a billing name, city, state, and zip code. Each transaction is associated with a car, a mechanic, and a repair. Cars, mechanics, and repairs can all be part of multiple transactions. Many transactions can make up an invoice. A transaction can only belong to one invoice.

Solution

Normalization Organizing data to minimize redundancy (repeated data) This is good for several reasons The database takes up less space Fewer inconsistencies in your data Fewer data modification problems Easier to search and navigate the data It’s easier to make changes to the data The relationships take care of the rest

Normalizing your ER Model If an entity has multiple sets of related attributes, split them up into separate entities Don’t do this… Vendor Name Vendor Phone Vendor Address Vendor Name Vendor Phone Vendor Address Vendor Vendor ID Product ID Product Product name sells Price …do this  Then you won’t have to repeat vendor information for each product. Product Product name Product ID Price

Normalizing your ER Model Each attribute should be atomic – you can’t (logically) break it up any further. Don’t do this… …do this Phone Address Phone First Name Customer ID Customer First/Last Name Customer ID Customer Last Name Street City State Zip This way you can search or sort by last name OR first name, and by city, state, or zip code.

Summary Key concepts Entity Relationship Cardinality Attributes Minimum cardinality: 0 (optional) or 1 (mandatory) Maximum cardinality: One-to-one, One-to-many, Many-to-many Attributes Entity attributes: primary key vs. non-key Relationship attributes Key skills Interpret simple ERDs Draw an ERD based on a scenario description Normalize your ERD whenever possible