Data Analysis 1. SET08104 Database Systems. Copyright @ Napier University



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

Entity-Relationship Model

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

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

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

Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

7.1 The Information system

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

Modern Systems Analysis and Design

Foundations of Information Management

The Entity-Relationship Model

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

Lecture 12: Entity Relationship Modelling

2. Conceptual Modeling using the Entity-Relationship Model

1 Class Diagrams and Entity Relationship Diagrams (ERD)

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

XV. The Entity-Relationship Model

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

IV. The (Extended) Entity-Relationship Model

(Refer Slide Time 00:56)

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

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

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

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

CSC 742 Database Management Systems

Designing Databases. Introduction

Database Management Systems

Foundations of Information Management

We know how to query a database using SQL. A set of tables and their schemas are given Data are properly loaded

Database Design Methodology

Conceptual Design: Entity Relationship Models. Objectives. Overview

Database Design Methodology

Exercise 1: Relational Model


Chapter 2: Entity-Relationship Model

LOGICAL DATABASE DESIGN

DATABASE INTRODUCTION

2. Basic Relational Data Model

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

Database Design. Adrienne Watt. Port Moody

ER modelling, Weak Entities, Class Hierarchies, Aggregation

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

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

æ A collection of interrelated and persistent data èusually referred to as the database èdbèè.

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

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

Database Design Process

MODULE 8 LOGICAL DATABASE DESIGN. Contents. 2. LEARNING UNIT 1 Entity-relationship(E-R) modelling of data elements of an application.

Database Design Process

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

Lecture Notes INFORMATION RESOURCES

Data Modeling Basics

CSC 342 Semester I: H ( G)

AS LEVEL Computer Application Databases

Chapter 10. Practical Database Design Methodology. The Role of Information Systems in Organizations. Practical Database Design Methodology

IT2305 Database Systems I (Compulsory)

How To Write A Diagram

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

Functional Data Flow Diagrams. Outline

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

IT2304: Database Systems 1 (DBS 1)

RELATIONSHIP STRENGTH

SCHEMAS AND STATE OF THE DATABASE

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

Developing Entity Relationship Diagrams (ERDs)

COURSE NAME: Database Management. TOPIC: Database Design LECTURE 3. The Database System Life Cycle (DBLC) The database life cycle contains six phases;

EXTENDED LEARNING MODULE A

Requirement Analysis & Conceptual Database Design. Problem analysis Entity Relationship notation Integrity constraints Generalization

Using UML Part Two Behavioral Modeling Diagrams

Designing a Database Schema

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

DISCLAIMER OVERVIEW WHY DO WE MODEL WHAT IS QUALITY? Jeff Jacobs,

Database Fundamentals: 1

Database Systems. Session 3 Main Theme. Enterprise Data Modeling Using The Entity/Relationship (ER) Model. Dr. Jean-Claude Franchitti

Answers to Review Questions

How To Develop Software

Quick Guide Business Process Modeling Notation (BPMN)

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Chapter 10 Practical Database Design Methodology and Use of UML Diagrams

[1] [2]

Entity - Relationship Modelling

Software Development: An Introduction

11 November

Fundamentals of Database Design

Understanding Data Flow Diagrams Donald S. Le Vie, Jr.

ComponentNo. C_Description UnitOfMeasure. C_Quantity

n Assignment 4 n Due Thursday 2/19 n Business paper draft n Due Tuesday 2/24 n Database Assignment 2 posted n Due Thursday 2/26

Information Systems Modelling Information Systems I: Databases

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

Converting E-R Diagrams to Relational Model. Winter Lecture 17

The Entity-Relationship Model

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

Flowcharting, pseudocoding, and process design

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

Lecture 8. Systems engineering L E C T U R E. SIMILAR process. Zuzana Bělinová. Faculty of Transportation Sciences, CTU in Prague

Vector storage and access; algorithms in GIS. This is lecture 6

Human-Readable BPMN Diagrams

Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

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

Transcription:

Data Analysis 1 SET08104 Database Systems Copyright @ Napier University

Entity Relationship Modelling Overview Database Analysis Life Cycle Components of an Entity Relationship Diagram What is a relationship? Entities, attributes, and relationships in a system The degree of a relationship Construct an Entity Relationship Diagram

DB Analysis Life Cycle Database study Database design Implementation and loading Testing and evaluation Operation maintenance and evolution

Database Analysis Life Cycle Database Initial study Analyse the company situation, define problems and constrains, define objectives, define scope and boundaries Database Design Create the conceptual design Create the logical design Create the physical design Implementation and loading Install DBMS, create the database(s), load initial data

Analysis Life Cycle continued... Testing and evaluation Test the database Fine-tune the database Evaluate the database and its application programs Operation Produce the required information flow Maintenance and evolution Introduce changes Make enhancements

Database Design Mini-World View Requirements Collection and Analysis Conceptual Design Data Model Mapping Physical Design

Database Design Conceptual Design Entity Relationship modelling and normalisation Data model verification DBMS software selection Data Model Mapping Logical design Translate model into definitions for tables, views... Physical design Storage structures - optimize performance Distributed database design

Entity Relationship Modelling Entity Relationship (ER) modelling is a design tool is a graphical representation of the database system provides a high-level conceptual data model supports the user s perception of the data is DBMS and hardware independent had many variants is composed of entities, attributes, and relationships

Entities An entity is any object in the system that we want to model and store information about Individual objects are called entities Groups of same type objects are entity types or entity sets Entities are represented by rectangles (either with round or square corners) Lecturer Lecturer Chen's notation other notations There are two types of entities; weak and strong entity types.

Attributes All the data relating to an entity is held in its attributes. An attribute is a property of an entity. Each attribute can have any value from its domain. All entities within an entity type have the same number of attributes. Each entity can have different attribute values in different entity types. Each entity type may have any number of attributes.

Attribute cont... Attributes can be simple or composite single-valued or multi-valued Attributes can be shown on ER models They appear inside ovals and are attached to their entity. Note that entity types can have a large number of attributes... If all are shown then the diagrams would be confusing. Only show an attribute if it adds information to the ER diagram, or clarifies a point. Lecturer Name

Keys A key is a data item that allows to uniquely identify individual occurrences or an entity type. A candidate key is an attribute or set of attributes that uniquely identifies individual occurrences of an entity type. An entity type may have one or more possible candidate keys, the one which is selected is known as the primary key. A composite key is a candidate key that consists of two or more attributes The name of each primary key attribute is underlined.

Relationships A relationship type is a meaningful association between entity types A relationship is an association of entities where the association includes one entity from each participating entity type. Relationship types are represented on the ER diagram by a series of lines. As always, there are many notations in use today...

Relationships cont... In the original Chen notation, the relationship is placed inside a diamond, e.g. managers manage employees: Manager manages Employee For this module, we will use an alternative notation, where the relationship is a label on the line. The meaning is identical Manager manages Employee

Degree of a Relationship The number of participating entities in a relationship is known as the degree of the relationship. If there are two entity types involved it is a binary relationship type Manager manages Employee If there are three entity types involved it is a ternary relationship type Sales Assistant sells Customer Product

Degree of a Relationship cont... It is possible to have a n-ary relationship (e.g. quaternary). Recursive relationships are from an entity to itself. manages Employee It is a relationship where the same entity participates more than once in different roles. In the example above we are saying that employees are managed by employees. If we wanted more information about who manages whom, we could introduce a second entity type called manager.

Degree of a Relationship It is also possible to have entities associated through two or more distinct relationships. Department manages employs Employee In the representation we use it is not possible to have attributes as part of a relationship. To support this other entity types need to be developed.

Replacing ternary relationships When ternary relationships occur in an ER model they should always be removed before finishing the model. Sometimes the relationships can be replaced by a series of binary relationships that link pairs of the original ternary relationship. Sales Assistant assists sells Customer Product buys

Replacing ternary relationships This can result in the loss of some information - It is no longer clear which sales assistant sold a customer a particular product. Try replacing the ternary relationship with an entity type and a set of binary relationships.

Replacing Ternary relationships cont... Relationships are usually verbs, so name the new entity type by the relationship verb rewritten as a noun. The relationship sells can become the entity type sale. Sales Assistant makes Sale involves Product requests Customer So a sales assistant can be linked to a specific customer and both of them to the sale of a particular product. This process also works for higher order relationships.

Cardinality Most relationships are not one-to-one For example, a manager usually manages more than one employee This is described by the cardinality of the relationship, for which there are four possible categories. One to one (1:1) relationship One to many (1:m) relationship Many to one (m:1) relationship Many to many (m:n) relationship On an ER diagram, if the end of a relationship is straight, it represents 1, while a "crow s foot" end represents many.

Cardinality cont... A one to one relationship - a man can only marry one woman, and a woman can only marry one man, so it is a one to one (1:1) relationship Man 1 is married to 1 Woman A one to may relationship - one manager manages many employees, but each employee only has one manager, so it is a one to many (1:n) relationship Manager 1 manages m Employee

Cardinality cont... A many to one relationship - many students study one course. They do not study more than one course, so it is a many to one (m:1) relationship Student m studies 1 Course A many to many relationship - One lecturer teaches many students and a student is taught by many lecturers, so it is a many to many (m:n) relationship Lecturer m teaches n Student

Optionality A relationship can be optional or mandatory. If the relationship is mandatory an entity at one end of the relationship must be related to an entity at the other end. If the relationship is optional Entities at each end of the relationship may or may not have to relate to each other.

The optionality can be different at each end of the relationship For example, a student must be on a course. This is mandatory. Thus, the relationship student studies course is mandatory. But a course can exist before any students have enrolled. Thus the relationship course is_studied_by student is optional. To show optionality, put a circle or 0 at the optional end of the relationship.

Optionality cont... As the optional relationship is course is_studied_by student, and the optional part of this is the student, then the O goes at the student end of the relationship connection. Course is studied by 0 Student It is important to know the optionality because you must ensure that whenever you create a new entity it has the required mandatory links.

Entity Sets Sometimes it is useful to try out various examples of entities from an ER model. One reason for this is to confirm the correct cardinality and optionality of a relationship. We use an entity set diagram to show entity examples graphically. Consider the example of course is_studied_by student. BSc Comp MSc Biology BA Fine Art BSc Maths Examples of the "Course" entities the "is_studied_by" relationship Paul Jenny Sarah Andy Jim Anne Examples of the "Student" entities

Confirming Correctness BSc Comp MSc Biology BA Fine Art BSc Maths Examples of the "Course" entities the "is_studied_by" relationship Paul Jenny Sarah Andy Jim Anne Examples of the "Student" entities Use the diagram to show all possible relationship scenarios. Go back to the spec and check to see if they are allowed. If not, then put a cross through the forbidden relationships This allows you to show the cardinality and optionality of the relationship

Deriving the relationship parameters To check we have the correct parameters (sometimes also known as the degree) of a relationship, ask two questions: One course is studied by how many students? Answer => zero or more. This gives us the degree at the student end. The answer zero or more needs to be split. The more means that the cardinality is many. The zero means that the relationship is optional. If the answer was one or more, then the relationship would be mandatory.

Relationship parameters cont... One student studies how many courses? Answer => One This gives us the degree at the course end of the relationship. The answer one means that the cardinality of this relationship is 1, and is mandatory If the answer had been zero or one, then the cardinality of the relationship would have been 1, and be optional.

Redundant relationships Some ER diagrams end up with a relationship loop. Check to see if it is possible to break the loop without losing info. Given three entities A, B, C, where there are relations A-B, B-C, and C-A, check if it is possible to navigate between A and C via B. If it is possible, then A-C was a redundant relationship. Always check carefully for ways to simplify your ER diagram. It makes it easier to read the remaining information.

Redundant relationships example Consider entities customer (customer details), address (the address of a customer) and distance (distance from the company to the customer address). Customer far from work is living at Distance Address far from work

Splitting n:m Relationships A many to many relationship in an ER model is not necessarily incorrect. It can be replaced using an intermediate entity. This should only be done where: the m:n relationship hides an entity the resulting ER diagram is easier to understand.

Splitting n:m Relationships - example Consider the case of a car hire company. Customers hire cars, one customer hires many cars and a car is hired by many customers. Customer m hire n Car The many to many relationship can be broken down to reveal a hire entity, which contains an attribute date of hire. Customer m Hire n Car

Constructing an ER model - Entities Before beginning to draw the ER model, read the requirements specification carefully. Document any assumptions you need to make. 1.Identify entities - list all potential entity types. These are the objects of interest in the system. It is better to put too many entities in at this stage and then discard them later if necessary.

Constructing an ER model - Entities Before beginning to draw the ER model, read the requirements specification carefully. Document any assumptions you need to make. 2. Remove duplicate entities - Ensure that they really separate entity types or just are two names for the same thing. Also do not include the system as an entity type e.g. if modelling a library, the entity types might be books, borrowers, etc. The library is the system, thus should not be an entity type.

Constructing an ER model - Attributes 3. List the attributes of each entity (all properties to describe the entity which are relevant to the application). Ensure that the entity types are really needed. are any of them just attributes of another entity type? if so keep them as attributes and cross them off the entity list. Do not have attributes of one entity as attributes of another entity!

Constructing an ER model - Attributes 4. Mark the primary keys. Which attributes uniquely identify instances of that entity type? This may not be possible for some weak entities.

Constructing an ER model - Relationships 5. Define the relationships Examine each entity type to see its relationship to the others. 6. Describe the cardinality and optionality of the relationships Examine the constraints between participating entities. 7. Remove redundant relationships Examine the ER model for redundant relationships. ER modelling is iterative, so expect to draw several versions. Note that there is no one right answer to the problem, but some solutions are better than others!