Entity Relationships and Databases

Similar documents
Instructor: Craig Duckett. Lecture 04: Thursday, April 5, Relationships

MIS2502: Data Analytics Relational Data Modeling - 1. JaeHwuen Jung

Normalization. Normal Forms. Normal Forms

Data Analysis 1. Chapter 2.1 V3.1. Napier University Dr Gordon Russell

Software Engineering Prof.N.L.Sarda IIT Bombay. Lecture-11 Data Modelling- ER diagrams, Mapping to relational model (Part -II)

Entity Relationship Diagram (ERD) Dr. Moustafa Elazhary

Entity Relationship Modelling

This is an almost-two week homework; it is almost twice as long as usual. You should complete the first half of it by October 2.

FAQ: Relational Databases in Accounting Systems

SOFTWARE ENGINEERING Prof.N.L.Sarda Computer Science & Engineering IIT Bombay. Lecture #10 Process Modelling DFD, Function Decomp (Part 2)

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

Part 5: Introduction to Logical Design

Database Design and Administration for OnBase WorkView Solutions. Mike Martel Senior Project Manager

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

Setting up an Invoice System

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

A good example of entities and relationships can be seen below.

System Analysis & design

Data Modeling During System Analysis. Logical Data Model Stages. What is Conceptual Database Design? Gathering Information for Conceptual

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

Issue dated 25 th July Create Credit Notes

Detailed Data Modelling: Attribute Collection and Normalisation of Data

We move from a general information system to a Computer Based Information System

The entity is an object of interest to the end user. entity correspond to the table not to a row- in the relational environment.

Furniture Wizard Security Introduction

33:010:458 Accounting Information Systems

Full file at

ERD Getting Started Guide

University of Virginia Department of Computer Science. CS 4501: Information Retrieval Fall 2015

Designing a Database -- Understanding Relational Design

Detailed Data Modelling. Detailed Data Modelling. Detailed Data Modelling. Identifying Attributes. Attributes

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<<

Audience Profile This course is intended for novice users of Microsoft Dynamics AX. Students must have basic Microsoft Windows navigation skills.

Lecture 5 STRUCTURED ANALYSIS. PB007 So(ware Engineering I Faculty of Informa:cs, Masaryk University Fall Bühnová, Sochor, Ráček

Microsoft Access Relationship Total Queries - Reports

Relational Database Components

Discussion Focus. Figure 1

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

Academic Skills Quick Guide

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Database Design Process

IS 263 Database Concepts

Entity-Relationship Model &

Information Technology Audit & Cyber Security

Logical E/R Modeling: the Definition of Truth for Data

MS Access Let s begin by looking at the toolbar and menu of Access.

Introduction to Databases Exam

CA 2E. Defining a Data Model. r8.5

First Grade Mathematics 2016

FROM A RELATIONAL TO A MULTI-DIMENSIONAL DATA BASE

Chapter 4. In this chapter, you will learn:

Relational Model (cont d) & Entity Relational Model. Lecture 2

Multiple-Choice. 3. When you want to see all of the awards, even those not yet granted to a student, replace JOIN in the following

Emma for Students Lesson 2: Peer Review and Graded Documents

Non-overlappingoverlapping. Final outcome of the worked example On pages R&C pages R&C page 157 Fig 3.52

CS 4400 Introduction to Database Systems 2002 Spring Term Project (Section A)

Lecture Notes. Structured Systems Analysis

Content-Based Assessments

Test bank for accounting information systems 1st edition by richardson chang and smith

Database Systems. Overview - important points. Lecture 5. Some introductory information ERD diagrams Normalization Other stuff 08/03/2015

Proofwriting Checklist

Supplier Enablement Quick Reference Guide (QRG) October 2017

SOME TYPES AND USES OF DATA MODELS

Unit Assessment Guide

For comprehensive certification training, students should complete Excel 2007: Basic, Intermediate, and Advanced. Course Introduction

Bachelor in Information Technology (BIT) O Term-End Examination

DEA Licensing WDNSW DC P21 DEA LICENSING

Database Applications (15-415)

GRASP Design Patterns A.A. 2018/2019

COPYRIGHTED MATERIAL. Chapter. Database Logical Modeling MICROSOFT EXAM OBJECTIVES COVERED IN THIS CHAPTER:

Information Systems (Informationssysteme)

Pegasus Opera II. Hints and Tips (2) From AMA Business Systems Ltd Tech Support Team

Attributes. Entity-Relationship Model (ERM) IV. Entity Relationship Modeling. Entities and Attributes: Chen and Crow s Foot

First Grade - Math. Trimester 1: Trimester 2: Trimester 3:

Taking Apart Numbers and Shapes

Modeling Relationships

Conceptual Database Design. COSC 304 Introduction to Database Systems. Entity-Relationship Modeling. Entity-Relationship Modeling

FINITE PRODUCTS ADMINISTRATION WITH MS ACCESS

MET CS 669 Database Design and Implementation for Business Term Project: Online DVD Rental Business

Database Systems. A Practical Approach to Design, Implementation, and Management. Database Systems. Thomas Connolly Carolyn Begg

Extra Fee for Magento 2

Database Design Process. Requirements Collection & Analysis

Data and Process Modeling

Trimester Counting and Cardinality

Course on Database Design Carlo Batini University of Milano Bicocca

Microsoft. Student Edition. The Richard Stockton College of New Jersey. Computer Courseware

CS Database Design - Assignments #3 Due on 30 March 2015 (Monday)

Week Two Entity Relationship Diagram. Marlon R. Evans DBM/502 3/27/17. Mark Paxton

ER DIAGRAM ER) diagram, a graphical representation of entities and their relationships to each other, typically used in computing in regard to the

MIS Digital Design & Innovation Studio. 6: Understanding The Data Your Client Needs. Amy Lavin/Steve Sclarow

CIS 330: Web-driven Web Applications. Lecture 2: Introduction to ER Modeling

The great primary-key debate

New Features in Sage BusinessVision 2019 ( )

hamster.ca Web Site User Guide 2018 See who we are

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

SUMMER EXAMINATIONS 2014

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 6 Normalization of Database Tables

Analytics: Server Architect (Siebel 7.7)

Course on Database Design Carlo Batini University of Milano Bicocca Part 5 Logical Design

Transcription:

Entity Relationships and Databases The following is excerpted from Chapter 6, Data Modeling, in Business Systems Analysis and Design by William S. Davis (1994, Belmont, CA: Wadsworth Publishing Company), a text used at one time in INLS 162, Systems Analysis. Ronald E. Bergquist Page 1 2015-06-27

Entities and Relationships Entity-relationship diagrams were first proposed as a means of quickly obtaining, with minimum effort, a good sense of the structure of a database. Consequently, several key terms are taken from database theory. An entity is an object (a person, group, place, thing, or an activity) about which data is stored. An occurrence is a single instance of an entity; for example, a particular 19-inch color TV set is a single occurrence of the entity called. An attribute is a property of an entity; for example, such attributes as stock number, description, and stock on hand might be associated with. Generally, the same set of attributes is associated with each occurrence of an entity, so every part in can be expected to have a stock number, a description, and a stock on hand. The set of attributes associated with an entity can be visualized as a table or a record. A data element is an attribute that cannot be logically decomposed. A set of related data elements forms a data structure or a data composite; for example, the set of attributes associated with each occurrence of an entity is a data structure. The key to an entity is the attribute or group of attributes that uniquely distinguishes one occurrence from all other occurrences. A foreign key is a key to some other entity; for example, a Supplier code might be associated with the data. A relationship links two entities and is shown by drawing a line between them as shown in figure 1. figure 1 Sales transactions are composed of Products Products make up Sales transactions Customers purchase Products Products are purchased by Customers Products are supplied by Suppliers Suppliers supply Products Logically, the relationship can be stated in the form of a sentence with a verb linking the two entities; for example, Sales transactions are composed of Products or Products make up Sales transactions. Ronald E. Bergquist Page 2 2015-06-27

The act of creating such sentences is a good test of the relationship s validity; if you can t express the link, it might not exist. In most cases where the relationship is unclear, the sentence might be written alongside the relationship line as shown in figure 1. Ronald E. Bergquist Page 3 2015-06-27

Cardinality For a variety of reasons, some relationships are more stable and easier to maintain than others. Cardinality, a measure of the related entity s relative number of occurrences, is an important predictor of the strength of the relationship. In a one-to-one relationship (figure 2), each occurrence of entity A is associated figure 2 with one and only one occurrence of entity B, and each occurrence of entity B is associated with one and only one occurrence of entity A. For example, imagine an instructor who maintaining examination data on each student. A Student B Exam There are two entities: Students and Exams. For each Student, there is one and only one Exam, and for each Exam, there is one and only one Student. Graphically, a one-to-one relationship is described by drawing short crossing lines at both ends of the line that links the two entities. In a one-to-many relationship (figure 3), each occurrence of entity A is associated with one or more occurrences of entity B, but each occurrence of entity B is associate with figure 3 only one occurrence of entity A. For example, your grade in most courses is based on numerous grade factors (exams, papers, projects). A given Student has several Grade factors, but a A Student B Grade factors given Grade factor is associated with one and only one Student. Graphically, a one-to-many relationship is shown by drawing a short crossing line at the one-end and a small triangle (sometimes called a crow s foot) at the many-end of the line that links the entities. In a many-to-many relationship (figure 4), each occurrence of entity A is figure 4 associated with one or more occurrences of entity B, and each occurrence of entity B is associated with one or more occurrences of entity A. For example, your end-of-term Grade report can list several Courses, and a A Grade report B Course given Course can appear on many students Grade reports. Graphically, a many-to-many relationship is shown by drawing a crow s foot at both ends of the line that links the entities. Other types of relationships are possible, but we will concentrate on one-to-one, one-to-many, and many-to-many relationships. Ronald E. Bergquist Page 4 2015-06-27

Analyzing Relationships One-to-many relationships tend to be the most stable. Consequently, a primary objective of entity-relationship modeling is to convert one-to-one and many-to-many relationships into oneto-many relationships. Ronald E. Bergquist Page 5 2015-06-27

One-to-one Relationships One-to-one relationships can often be collapsed by merging them. For example, figure 5 shows a one-to-one figure 5 relationship linking a set of employee data with that employee s address. You might be able to imagine an application in which it makes sense to keep the home address separate from the other employee data, but it seems reasonable to treat Address as an attribute of Employee Employee Employee address Employee. Generally, entities that share a one-to-one relationship should be merged unless there is a good reason to keep them separate. Note that not all one-to-one relationships can be collapses. For example, imagine a relationship between Athletes and Drug tests. There is one Drug test per Athlete and one Athlete per Drug test, so the relationship is clearly one-to-one. You might argue that Drug test is an attribute of Athlete, but what if the law requires that Drug test data be kept confidential? Because merging the data would make it relatively easy to link a specific person to a specific test result, merging them would probably violate the law, so there is a good logical reason to maintain separate entities. Ronald E. Bergquist Page 6 2015-06-27

Many-to Many Relationships Many-to many relationships can cause maintenance problems. For example, figure 6 shows a many-to-many relationship between and Supplier. Each product in can have more than one Supplier, and each Supplier can carry more than one product. If you were to store a list of Suppliers in, adding figure 6 Item ordered Supplier Supplier or deleting a Supplier might mean updating several occurrences. Likewise, listing products in Supplier could mean changing several Supplier occurrences if a single product were added or deleted. One solution is to create a new entity that has a one-to-many relation ship with both original entities. For example, imagine a new entity called Item ordered (figure 6). If you need 100 television sets, you might order 50 from Supplier A, 25 from Supplier B, and 25 from Supplier C, so a given product in can appear on several active Item ordered. However, each Item ordered is for one and only one product. Likewise, a given Supplier can appear on several active Item ordered, but each Item ordered lists one and only one Supplier. Note that a give Item ordered links a specific product in with a specific occurrence of Supplier. The many-tomany relationship has been converted to two one-to-many relationships. How does that affect data maintenance? Imagine that, Item ordered, and Supplier are three files. The file called Item ordered holds product codes and Supplier codes, and it is indexed on both fields. Detailed information on products and/or Suppliers can be obtained by accessing the file or the Supplier file, as appropriate. Dropping a product affects and Item ordered, but not Supplier. Adding a Supplier affects Supplier and Item ordered, but not. Because Item ordered is indexed on both keys, it is easy to maintain. Ronald E. Bergquist Page 7 2015-06-27

Creating an Entity-Relationship Diagram Sales Data Assuming we are analyzing a system, we have some things that we can see exist. If the system is a business of some sort, one can assume that we have three entities: Sales,, and Supplier. First, why are they entities? Start with the definition of an entity: an object (a person, group, place, thing, or activity) about which data are stored. Since any business must involve a figure 7 Customer, a Customer is an object and Customer is probably an purchases Customer entity. Other data elements (Stock number, Description, and Unit price) describe a product in initiates Customer Sales, so must be another entity and Customer purchase defines their Sales consists of relationship (figure 7). Since one Customer can purchase many products and a given product can be purchased by many Customers, the relationship is many-to-many. Other data elements we might encounter could include Invoice number, Date of sale, Quantity, Item total, Subtotal, Sales tax, and Total due are clearly not attributes of Customer or. Instead, they describe the sale itself, so Sales must be another entity. The Sales entity is related to both Customer and. A quick review of the other sale-related documents should convince you that most of their fields either describe a product in, are derived from Sales, or are computed upon demand, so the existing data suggests no additional entities. As figure 7 shows, the Sales entity is related to the other two as follows: Customer initiates Sales; Sales consist of The first relationship is one-tomany (figure 8). A given Customer can have many Sales transactions, but a given Sale is associated with one and only one Customer. The second relationship is many-to-many because a given sale can include several products from and a given product in can appear in many Sales. Customer Sales figure 8 Ronald E. Bergquist Page 8 2015-06-27

To resolve that many-to-many relationship, create a new entity, Item sold, that has a one-tomany relationship with both Sales and (figure 8). A given Sales transaction can list many Item sold, but a given Item sold is associated with one and only one Sales Customer Sales figure 8 Item sold transaction. A given product in can appear in many Item sold, but a given Item sold lists one and only one product. (Think of an Item sold as one line in a list of products purchased on a Sales invoice.) Note that the set of relationships described in figure 8 also resolves the many-to-many relationship between Customer and. Those two entities are related through Sales and Item sold, and each of the intermediate relationships is one-to-many. There is one possible source of confusion about the entity that might need clarification. A specific 19-inch color TV set is an example of a single occurrence of that entity, but might hold 100 or more virtually identical TV sets. For control purposes, tracking TV sets (a class of occurrences) is probably good enough. However, a Customer purchases a specific TV set (identified, perhaps, by concatenating the serial number to the stock number). Thus a given Item sold lists one and only one occurrence of. Ronald E. Bergquist Page 9 2015-06-27

Supplier and Data But there seems to also be a many-tomany relationship between and Supplier (figure 9). It is many-tomany because a given product can have many Suppliers and a given Supplier can supply many products. figure 9 Supplier Many-to-many relationships must be resolved, so add a new entity called Item ordered to the model (figure 10). You now have two one-to-many relationships. Check the relationships in figure 10 and convince yourself figure 10 that they really are one-to-many. Item ordered Supplier The entity called Item ordered will hold foreign keys that link a product to a Supplier and a Supplier to a product. Ronald E. Bergquist Page 10 2015-06-27

Completing the Model The entity is related to both Item sold and Item ordered, so you can combine the two partial diagrams to form a single entity-relationship model (figure 11). Customer figure 11 Sales Item sold Item ordered Supplier Ronald E. Bergquist Page 11 2015-06-27

Translated into Access terms, the relationship could look like the following, which was entirely created using the Table Wizard. Note that in the creation of the Customer/Sales relationship, the Wizard placed the Primary Key from Customers into Sales as a Foreign Key. However, in the construction of the Item_sold and Item_ordered tables, the Primary Keys from the related tables had to be placed by the Wizard as foreign keys into the connecting tables during the definition of the fields in these two tables. Ronald E. Bergquist Page 12 2015-06-27