Data Modeling: Part 1. Entity Relationship (ER) Model



Similar documents
Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Database Management Systems

Unit 2.1. Data Analysis 1 - V Data Analysis 1. Dr Gordon Russell, Napier University

Data Analysis 1. SET08104 Database Systems. Napier University

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

Chapter 3. Data Modeling Using the Entity-Relationship (ER) Model

Foundations of Information Management

Database Design Process

Conceptual Design: Entity Relationship Models. Objectives. Overview

Database Design Process

Entity-Relationship Model

2. Conceptual Modeling using the Entity-Relationship Model

Entity - Relationship Modelling

The Entity-Relationship Model

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

Modern Systems Analysis and Design

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

A brief overview of developing a conceptual data model as the first step in creating a relational database.

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

Designing Databases. Introduction

How To Write A Diagram

TIM 50 - Business Information Systems

Database IST400/600. Jian Qin. A collection of data? A computer system? Everything you collected for your group project?

Chapter 2: Entity-Relationship Model. E-R R Diagrams

Lecture 12: Entity Relationship Modelling

Introduction to normalization. Introduction to normalization

Foundations of Information Management

ER modelling, Weak Entities, Class Hierarchies, Aggregation

Conceptual Design Using the Entity-Relationship (ER) Model


Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

1 Class Diagrams and Entity Relationship Diagrams (ERD)

Why & How: Business Data Modelling. It should be a requirement of the job that business analysts document process AND data requirements

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Lecture 6. SQL, Logical DB Design

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

Lesson 8: Introduction to Databases E-R Data Modeling

not necessarily strictly sequential feedback loops exist, i.e. may need to revisit earlier stages during a later stage

Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model

Developing Entity Relationship Diagrams (ERDs)

Ken Goldberg Database Lab Notes. There are three types of relationships: One-to-One (1:1) One-to-Many (1:N) Many-to-Many (M:N).

XV. The Entity-Relationship Model

IT2305 Database Systems I (Compulsory)

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

The Entity-Relationship Model

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

The E-R èentity-relationshipè data model views the real world as a set of basic objects èentitiesè and

Animated Courseware Support for Teaching Database Design

EXTENDED LEARNING MODULE A

Introduction to Computing. Lectured by: Dr. Pham Tran Vu

Fundamentals of Database System

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #5: En-ty/Rela-onal Models- - - Part 1

Topic: Relationships in ER Diagram and Relationships in MS Access

THE ENTITY- RELATIONSHIP (ER) MODEL CHAPTER 7 (6/E) CHAPTER 3 (5/E)

Chapter 2. Data Model. Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel

7.1 The Information system

Entity Relationship Diagram

Lecture Notes INFORMATION RESOURCES

Entity-Relationship Model. Purpose of E/R Model. Entity Sets

Database Design Methodology

IT2304: Database Systems 1 (DBS 1)

Database Fundamentals: 1

Chapter 2: Entity-Relationship Model

DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

Exercise 1: Relational Model

Once the schema has been designed, it can be implemented in the RDBMS.

There are five fields or columns, with names and types as shown above.

Using Entity-Relationship Diagrams To Count Data Functions Ian Brown, CFPS Booz Allen Hamilton 8283 Greensboro Dr. McLean, VA USA

Data Modeling Basics

Hands-on training in relational database concepts

DATABASE INTRODUCTION

Concepts of Database Management Seventh Edition. Chapter 6 Database Design 2: Design Method

- Eliminating redundant data - Ensuring data dependencies makes sense. ie:- data is stored logically

Database Design Process. Databases - Entity-Relationship Modelling. Requirements Analysis. Database Design

Access Tutorial 2: Tables

Doing database design with MySQL

Access Tutorial 3: Relationships

LOGICAL DATABASE DESIGN

Chapter 9: Normalization

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Preview DESIGNING DATABASES WITH VISIO PROFESSIONAL: A TUTORIAL

BİL 354 Veritabanı Sistemleri. Entity-Relationship Model

The Entity-Relationship Model

Data Modeling. Database Systems: The Complete Book Ch ,

Introduction This document s purpose is to define Microsoft SQL server database design standards.

5.5 Copyright 2011 Pearson Education, Inc. publishing as Prentice Hall. Figure 5-2

Databases and BigData

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

AS LEVEL Computer Application Databases

Databases What the Specification Says

- Suresh Khanal. Microsoft Excel Short Questions and Answers 1

A Short Tutorial on Using Visio 2010 for Entity-Relationship Diagrams

Filter by Selection button. Displays records by degree to which they match the selected record. Click to view advanced filtering options

12 File and Database Concepts 13 File and Database Concepts A many-to-many relationship means that one record in a particular record type can be relat

RELATIONSHIP STRENGTH

IV. The (Extended) Entity-Relationship Model

Transcription:

Data Modeling: Part 1 Entity Relationship (ER) Model MBA 8473 1 Cognitive Objectives (Module 2) 32. Explain the three-step process of data-driven information system (IS) development 33. Examine the purpose of data modeling in information management 34. Explain Data Model quality issues. 35. Provide examples of four common difficulties in a poorly designed data model: (1) redundancies, (2) update, (3) deletion anomalies, and (4) insertion anomalies. 36. Explain entity-relationship (ER) model and identify its building blocks: Entity, Identifier, Relationship, and Attribute. 37. Explain three properties of an entity-relationship: (1) Degree of a relationship, (2.1) Minimum and Maximum Cardinalities, and (2.2) Optional and Mandatory Associations 38. Do an ER Model or Diagram. 39. Explain relational model, and identify its building blocks, and underlying core principles: (1) Tables and attributes, (2) Primary keys, and entity integrity, (3) Foreign keys and referential Integrity. 40. Apply rules for mapping E-R models to the relational model 41. Apply normalization theory to assess the quality of a relational model 2

Organization of Concepts Data Modeling The Rationale E-R Model Relational Model Shared Understanding Uncover Relationships Prevent Anomalies Insert Update Delete Building Blocks Entity Attributes Relationships Identifiers Types of Relationships Degree of a Relationship Min. & Max. Cardinalities 1:1, 1:M, M:N Optional & Mandatory Recursive Supertype - Subtype Building Blocks Tables Attributes Primary Key Foreign key Integrity Primary Key Referential Domain Data Quality Normalization Theory 3 Data-Driven IS Development (C.O. 32) Problem Domain Conceptual Design Conceptual Schema, e.g., ER Model (c.o. 36-38) Logical Design Logical Schema, e.g., Relational Model (c.o. 39-41) Physical Design Physical Schema, e.g., Access implementation 4

Why is Data Modeling important for managing organizational information? (C.O. 33) The emphasis of data modeling is on representing reality, business complexity. A database must mirror the real world. Only then can it answer questions about the real world! Ideally it should be a graphical representation of both business reality and the actual database. The goal is to identify the facts to be stored in the database. 5 A high quality Data Model should offer (C.O. 34) A well-formed data model (completeness) A high fidelity (clarity plus reliability) image 6

Difficulty 1: Redundant Data (C.O. 35) Consider the following table that stores data about auto parts and suppliers. This seemingly harmless table contains many potential problems. Part# Description Supplier Address City State 100 Coil Dynar 45 Eastern Ave. Denver CO 101 Muffler GlassCo 1638 S. Front Seattle WA 102 Wheel Cover A1 Auto 7441 E. 4th Street Detroit MI 103 Battery Dynar 45 Estern Ave. Denver CO 104 Radiator United Parts 346 Taylor Drive Austin TX 105 Manifold GlassCo 1638 S. Front Seattle WA 106 Converter GlassCo 1638 S. Front Seattle WA Suppose you want to add another part? 107 Tail Pipe GlassCo 1638 S. Front Seattle WA Memory space is wasted by duplicating data about the supplier. Every time a new part is entered for a particular supplier, all of the supplier data is repeated. Imagine the problems if several suppliers supply hundreds of auto parts each. 7 Difficulty 2: Update Anomaly (C.O. 35) What if GlassCo moves to Olympia? How many rows have to change in order to ensure that the new address is recorded. Part# Description Supplier Address City State 100 Coil Dynar 45 Eastern Ave. Denver CO 101 Muffler GlassCo 1638 S. Front Seattle WA 102 Wheel Cover A1 Auto 7441 E. 4th Detroit MI Street 103 Battery Dynar 45 Estern Ave. Denver CO 104 Radiator United 346 Taylor Austin TX Parts Drive 105 Manifold GlassCo 1638 S. Front Seattle WA 106 Converter GlassCo 1638 S. Front Seattle WA 107 Tail Pipe GlassCo 1638 S. Front Seattle WA Again, imagine the issues surrounding modifications of hundreds of rows of data for one supplier. When changes are made, they must be made to all copies of the data. Think about the confusion that results from changing only a subset of the duplicate data. 8

Difficulty 3: Deletion Anomaly (C.O. 35) Suppose you no longer carried part number 102 and decided to delete that row from the table? Part# Description Supplier Address City State 100 Coil Dynar 45 Eastern Ave. Denver CO 101 Muffler GlassCo 1638 S. Front Seattle WA 102 Wheel Cover A1 Auto 7441 E. 4th Detroit MI Street 103 Battery Dynar 45 Estern Ave. Denver CO 104 Radiator United 346 Taylor Drive Austin TX Parts 105 Manifold GlassCo 1638 S. Front Seattle WA 106 Converter GlassCo 1638 S. Front Seattle WA 107 Tail Pipe GlassCo 1638 S. Front Seattle WA 9 Now, looking at the remaining data below, what is the address of A1 Auto? (C.O. 35) Part# Description Supplier Address City State 100 Coil Dynar 45 Eastern Ave. Denver CO 101 Muffler GlassCo 1638 S. Front Seattle WA 103 Battery Dynar 45 Estern Ave. Denver CO 104 Radiator United 346 Taylor Austin TX Parts Drive 105 Manifold GlassCo 1638 S. Front Seattle WA 106 Converter GlassCo 1638 S. Front Seattle WA 107 Tail Pipe GlassCo 1638 S. Front Seattle WA A deletion anomaly means that we lose more information than we want. We lose facts about more than one subject with one deletion. 10

Difficulty 4: Insertion Anomaly (C.O. 35) Next, you want to add a new supplier, CarParts, but you have not yet ordered parts from that supplier. What do you add? Part# Description Supplier Address City State 100 Coil Dynar 45 Eastern Ave. Denver CO 101 Muffler GlassCo 1638 S. Front Seattle WA 103 Battery Dynar 45 Estern Ave. Denver CO 104 Radiator United 346 Taylor Austin TX Parts Drive 105 Manifold GlassCo 1638 S. Front Seattle WA 106 Converter GlassCo 1638 S. Front Seattle WA 107 Tail Pipe GlassCo 1638 S. Front Seattle WA??????????? CarParts 101 Mariposa Orlando FL This situation is called an insertion anomaly. Stated reversely, we cannot add a fact about one subject until we have additional data about another subject. 11 Turning to The Building Blocks of an ER (Entity Relationship) Model (C.O. 36) Entity Attribute Identifier Relationship 12

Entities and Their Instances (C.O. 36) What is an Entity? Some thing or object in the environment that occurs more than once and we have a recognized business interest in capturing information about this thing Classes of real-world objects PERSON, STUDENT, EMPLOYEE Typically represented by a rectangle An instance is a particular occurrence of an entity Entity Instances STUDENT AL BILLY CHARLES 13 Attributes (C.O. 36) Attributes describe an entity Attributes such as Student_name, Student_social_sec#, so on, describe an entity called Student for a given purpose) Some recommendations: Attribute names must be unique within a data model Not recommended: Student (, soc_sec#, ); Professor (, soc_sec#, ) Recommended:Student (, stud_soc_sec#, ); Professor (, prof_soc_sec#, ) Attribute names must be meaningful Not recommended: ss# Recommended: soc_sec# or social_security_number Differentiate between attribute name and attribute value Attribute name: social_security_number Attribute value: 234-56-7890, 234567890 14

Identifiers (C.O. 36) (Why?) Every instance of an entity must be uniquely identified Entity: Student Instances (Name attribute only): John Smith, Jane Doe, John Smith, We need some attribute other than the Name to differentiate the first John Smith from the second John Smith (What?) An identifier can be one attribute or a collection of attributes One attribute as an identifier of the entity called STUDENT: social_security_number A collection of attributes as an identifier of the entity called REGISTRATION: soc_sec_number+course_number (How to denote an identifier) An underlined attribute (or a leading asterisk) denotes an identifier: social_security_number or *social_security_number and NOT social_security_number Discuss how to recognize poor identifiers. 15 Entity Relationship Properties (C.O. 37) In the real world, entities are related to other entities. Relationships are most often depicted using a diamond shaped rectangle or simply by a straight line. An appropriate label describes the relationship between entities 16

Example of an entity relationship (37) DEPARTMENT Has EMPLOYEES Belongs to This relationship captures a business fact: A department has employee(s) or stated otherwise, an employee belongs to a department. What it does not tell us yet: how many of one entity relates to how many of the other. For example, how many employee belongs to a department? Such information is called Cardinality of the relationship. 17 Cardinality of Relationships [C.O. 37(2)] Minimum Cardinality The minimum number of instances of one entity that must participate in a relationship What are the minimum number of employees that must be in a department? Example: 0, 1, 5, N? Maximum Cardinality The maximum number of instances of one entity that can participate in a relationship What are the maximum number of employees that can be in a department? Example: 1, 10, 40, M? 18

Examples of minimum and maximum cardinalities for each entity (37.2) DEPARTMENT *deptname deptfloor deptphone Has EMPLOYEE *empno empfname empsalary In this scheme: A DEPARTMENT is allowed to have 1 or Many EMPLOYEES, so in this example minimum cardinality of EMPLOYEE is 1 and maximum cardinality of EMPLOYEE is M (or Many). (Note: A department of 0 employee is not allowed and will not exist in the database) DEPARTMENT *deptname deptfloor deptphone EMPLOYEE *empno empfname empsalary Belongs to In this scheme: An EMPLOYEE is allowed to belong to one and only one DEPARTMENT, i.e., only one department can participate in this relationship. So, minimum cardinality of DEPARTMENT is 1 and maximum cardinality of DEPARTMENT is also 1. (Note: (1) An employee without a department is not allowed and will not exist in the database. (2) No two departments can have the same employee in the database!) 19 Examples of minimum and maximum cardinality (37.2) DEPARTMENT *deptname deptfloor deptphone Has EMPLOYEE *empno empfname empsalary As a practice we show both entity (or side) cardinalities in one diagram 20

ER Model Draws upon Cardinality-Based Classification of Relationships (C.O. 37.2.1 and 37.2.2) Broadly classified in terms of maximum cardinality A 1:1 [one-to-one] relationship A 1:M [one-to-many] relationship A M:N [many-to-many] relationship [Illustration follows] 21 One-to-one (1:1) Relationship (C.O.37.2.1 contd.) OfficeSpace *spacename OSIDNumber Assigned to EMP *empno empfname empsalary One and only one employee is assigned one office space only. A particular office space is assigned to one and only one employee only. 22

One-to-Many (1:M) Relationship (C.O.37.2.1 contd.) (Example 1) DEPT *deptname deptfloor deptphone has EMP *empno empfname empsalary A department can have many employees, but an employee can be a member of only one department. 23 One-to-Many (1:M) Relationship (C.O.37.2.1 contd.) (Example 1) CUSTOMER *Number Name Address places ORDER *Order Number Order Date Promised Date A customer can place many orders, but has at least one order. An order can be placed by one and only one customer. This is a one-to-many with minimum cardinalities of one (as stated) What implications does this have for collection of customer data? 24 24

Optional and Mandatory Association [c.o. 37.2.2] CUSTOMER *Number Name Address ORDER *Order Number Order Date Promised Date Becomes zero An instance of an entity can exist without being related to an instance of the other entity. Then the minimum cardinality is 0. Then the relationship becomes an optional association. A particular customer may not have placed an order and can still be tracked for different purposes. 25 25 Many-to-Many (M:M) Relationships (C.O.38 contd.) Student *SSNO Registers for Classes *CNO A student can take many classes. Each class can have many students. 26 26

Doing an Entity- Relationship Model or Diagram (C.O. 38) Recap that: Each entity represented by a rectangle. Each relationship represented by a diamond or a straight line. Attributes shown in ovals or as a list. ER Model draws upon Cardinality-Based Classification of Relationships 27 In-class exercise 1(c.o. 38) A customer can place an order for one or more products. Customers that have not placed any orders can be included in the customer database for purposes of marketing research. Products that have not been ordered can be part of the product database. An order has to be associated with at least one product but can be associated with many products. Develop an E-R model for the described scenario. Where necessary, please make any assumptions. It is normally okay to do this, as complex scenarios are unlikely to be described completely. However, it is very important to explicitly state these assumptions. 28

In-class exercise 2 (c.o. 38) In a city called ecity there are various types of licenses that are given out to different businesses. A business can ask for more than one license type. The city mayor wants to keep track of licenses given out to each business. Develop an ER model for the situation. List your assumptions. 29 Appendix Degree of a relationship between entities Some popular notations for cardinality Some shots from an Access implementation. Examples of small ER models. 30

Degree of a relationship between entities Degree of a relationship is determined by the number of participating entities unary [one entity - also called recursive relationships] binary [two participating entities, most frequently found] ternary [three participating entities] 31 Two Examples of Unary (or Recursive) of Relationship (37.1) (A recursive relationship relates an entity to itself.) Example 1 STUDENT Rooms-with Example 2 EMPLOYEE Boss of employee Employees Employees of of the the boss boss 32

Example of Binary Relationship (37.1) DEPARTMENT *deptname deptfloor deptphone has belongs to EMPLOYEE *empno empfname empsalary Two entities are involved DEPARTMENT EMPLOYEE 33 Example of Ternary Relationship (37.1) MOTHER FATHER CHILD Three entities are are involved MOTHER FATHER CHILD 34

Cardinality Interpretation Cardinality Notations (c.o. 38) Minimum Instances Maximum Instances Graphic Notation Exactly one 1 1 Zero or one 0 1 One or more 1 Many (>1) Zero,one or more More than one 0 >1 Many (>1) >1 35 MS Access will let you represent an Entity as a Table. You can create a table in three ways as shown above. Create Table Using Wizard comes with some already designed tables for some everyday entities. For example, I wanted to create one Table for DEPARTMENT and one for EMPLOYEE. The wizard already has a ready to use version of EMPLOYEE table. You should check to see whether it is good for your purpose. 36

Note: A table called EMPLOYEE has been created. I have entered one instance of the entity as data. This is A Data Sheet view. One should go to Design view (just click on View and choose Design) to change data specifications. 37 38 This is a Design view of the table called EMPLOYEE. Note the choices under Data Type for EmployeeID.

Example 1: Student-Course Design a database to keep track of what courses a student takes, the grade he or she receives and information on what professors teach the courses. Entities: Student, Course, Professor Relationships: Student takes Course N : M Professor teaches Course N : M 39 E-R Model (Diagram) name address Course-Id description SSN Student N takes M Course M teaches N SSN Professor name specialty 40

Example 2: Supplier-Part ERD (c.o. 38 continues) sname quality city S# N Supplier sends Part M Supplier sends Part: Relationship P# pname weight 41