Data Modelling and E-R Diagrams



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

SCHEMAS AND STATE OF THE DATABASE

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

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

DATABASE INTRODUCTION

Relational Database Concepts

Entity-Relationship Model

Database Design Methodology

Lesson 8: Introduction to Databases E-R Data Modeling

Database Management Systems

Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

Designing a Database Schema

Database Design Process

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

Entity Relationship Diagram

Overview. Physical Database Design. Modern Database Management McFadden/Hoffer Chapter 7. Database Management Systems Ramakrishnan Chapter 16

Database Management. Technology Briefing. Modern organizations are said to be drowning in data but starving for information p.

Database Design Process

An Example: Video Rental System

Lecture Notes INFORMATION RESOURCES

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

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

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

LOGICAL DATABASE DESIGN

Information Management

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

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

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

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

SAMPLE FINAL EXAMINATION SPRING SESSION 2015

The Entity-Relationship Model

Doing database design with MySQL

2. Conceptual Modeling using the Entity-Relationship Model

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

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

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

Data Modeling Basics

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

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

CIS 631 Database Management Systems Sample Final Exam

Databases What the Specification Says

Relational Database Basics Review

ComponentNo. C_Description UnitOfMeasure. C_Quantity

Databases in Engineering / Lab-1 (MS-Access/SQL)

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

How To Write A Diagram

Database Concepts. Database & Database Management System. Application examples. Application examples

Fundamentals of Database Design

TIM 50 - Business Information Systems

Database Setup. Coding, Understanding, & Executing the SQL Database Creation Script

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

AS LEVEL Computer Application Databases

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

Foundations of Information Management

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

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

Intro to Databases. ACM Webmonkeys 2011

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

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

Database Administrator [DBA]

Network Model APPENDIXD. D.1 Basic Concepts

Answers to Review Questions

SQA Higher Information Systems Unit 2: Relational Database Systems

THE OPEN UNIVERSITY OF TANZANIA FACULTY OF SCIENCE TECHNOLOGY AND ENVIRONMENTAL STUDIES BACHELOR OF SIENCE IN DATA MANAGEMENT

Foundations of Information Management

COMHAIRLE NÁISIÚNTA NA NATIONAL COUNCIL FOR VOCATIONAL AWARDS PILOT. Consultative Draft Module Descriptor. Relational Database

DATABASE MANAGEMENT SYSTEMS. Question Bank:

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).

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

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

Introduction to Databases

The Entity-Relationship Model

Conceptual Design: Entity Relationship Models. Objectives. Overview

Designing Databases. Introduction

DATABASE DESIGN AND IMPLEMENTATION USING VISUAL BASIC

Database System Concepts

9. Master Data Management (MDM)

University Data Warehouse Design Issues: A Case Study

Unit 5.1 The Database Concept

Databases and DBMS. What is a Database?

Database Design. Adrienne Watt. Port Moody

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

Module Contact: Dr. Beatriz de la Iglesia, CMP Copyright of the University of East Anglia Version 1

7.1 The Information system

Entity - Relationship Modelling

Information Systems Analysis and Design CSC John Mylopoulos Database Design Information Systems Analysis and Design CSC340

Chapter 1: Introduction. Database Management System (DBMS)

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

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

XV. The Entity-Relationship Model

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

CPS352 Database Systems: Design Project

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

Chapter 1: Introduction

Transcription:

Data Modelling and E-R Diagrams So far we have considered some of the basic ideas behind relational theory, and we will continue with this in subsequent sections. In this section we look at the processes involved in capturing the information required to design and create a database. Data Analysis and Database Design We can subdivide the process of designing a database into three separate phases: Data Analysis, System Design, and Technical Design. User Environment Data Analysis System Design Technical Design Data Model and Functional Model Database Specification Database User Environment: The real world environment about which the organisation wishes to store data for the purposes of some application (the application might be, for example, a computerised stock control and accounting system). Data Analysis: In this phase the real world environment, in the context of the required application, is modelled to produce (i) an abstract data model which focuses on the data that needs to be stored and the relationships between the data entities and (ii) the functional model which deals with how the data will be processed (e.g. the design of queries to the database). The abstract data and functional models produced are independent of the specific DBMS that will eventually be used to implement the database. Note that this phase is also sometimes called conceptual design. Database Systems (EE22) - Page 7

System Design: The data and functional models feed into the system design phase which produces the database specification. The database specification details how the abstract data model from the previous design phase will map onto the specific data model of the chosen DBMS (this activity is sometimes called logical design). The database specification also describes information such as statistics on how frequently data will be accessed and access patterns across the datasets etc. The aim of these specifications is to ensure that the implementation will be efficient and that sufficient capacity (storage, memory, processing) is provisioned. Technical Design: Taking the database specification as input, the technical design phase specifies exactly how the database will be physically implemented using a DMBS, so that a certain set of criteria are met. This phase is sometimes called physical design. Examples of the criteria are: Data availability: ensure that the data and relationships required by the application are stored in the database Data reliability: the data will not be lost or corrupted Data currency: the data value in the database is the latest available Data consistency: the same data values will be obtained from different queries that are executed at the same time Data efficiency: the data are stored and retrieved at minimum cost (in terms of storage, memory or processing power required) Database: Finally the database is implemented according to the technical design requirements using a chosen DBMS. In this course, we are most interested in the high level design process of Conceptual Design (Data Analysis) and the relational theories on which it builds. Database Systems (EE22) - Page 8

Data Models As mentioned above, the data model is an abstraction of the data structures required by a database. By abstraction, we mean that data model represents the data as a user would observe it in the real world rather than how it is stored on disk or how software manipulates it. This means that the data model is independent of the particular DBMS that will eventually be used to implement the database, a useful property. The data model is composed of data entities, relationships between different data entities and also rules which govern operations on the data. Note that the data model does not specify the operations themselves that will be performed on the data (these are specified in the functional model), but rather just the restrictions that apply when any operation is performed on the data structures. Entity-Relationship (E-R) Models An E-R model is a particular type of data model suited to designing relational databases. The main component of the model is the Entity-Relationship Diagram. The E-R diagram is a simple way of representing the data entities being modelled and the relationships between these data entities. It is easy to transform E-R diagrams to the Relational Model (data entities correspond to relations and relationships correspond to the implied associations created by keys and foreign keys of relations). Entities Entities are analogous to relations in the relational model. They represent the principle data objects about which information is to be collected. Entities represent concepts or concrete or abstract objects this such as person, place, physical things, events, for example,, INVOICE, PURCHASE. In an E-R diagram, an entity is represented as a named rectangular shape, which may include a list of attributes. For clarity, normally only attributes that are involved in relationships between entities are included, i.e. primary key (PK) and foreign keys (FK). This maintains an uncluttered diagram. Recall our student relation from earlier: (ID, Surname, Forename, Programme, Date_of_Birth) We can denote our entity in an E-R diagram as shown below: Database Systems (EE22) - Page 9

Relationships A relationship represents some association between two or more entities. In an E-R diagram, a relationship is represented as a diamond shape, containing the name of the relationship between the entities. Returning to our final year project database relations from earlier, (ID, Surname, Forename, Programme, Date_of_Birth) (Proj-ID, Project-Title, Student-ID, Year) we can represent the relationship between these relations as follows: ASSIGNED Student_ID (FK) Note that we can show the connectivity of the relationship, which in this case is a one-to-one (:) relationship. The one-to-one relationship shown reflects the fact that each student is assigned (at most) one project and that each project is assigned to (at most) one student. One-to-many (:N) Relationships Introducing a new relation SUPERVISOR to our schema, an example of an E-R diagram of a one-to-many relationship is shown below. This relationship models the fact that every final year project supervisor supervises a number of projects but that each project has only one supervisor. (Note that we have added the Supervisor_ID attribute to the relation to form a foreign key, reflecting the primary key of SUPERVISOR). SUPERVISOR N SUPERVISES Supervisor_ID (FK) Database Systems (EE22) - Page 20

Many-to-many (N:M) Relationships Introducing another relation PROGRAMME to our schema, an example of a manyto-many relationship is shown below. This relationship models the fact that a project could suit students on different programmes (e.g. a project involving database systems would suit either DME or ICE) and also that a given programme will have multiple projects that suit it. (Note that we have added the foreign key Program_ID to relation to form the relationship). PROGRAMME Program_ID (FK) N SUITS M Resolving many-to-many relationships Many-to-many relationships in E-R diagrams (as above) cannot be expressed directly in the relational model and must be resolved at the modelling stage. To illustrate the problem, as an exercise complete a table showing an instance of which shows project number 4 in 2006 being suitable for both the ICE and DME programmes: RELATION: Proj_ID Project_Title Student_ID Year Supervisor_ID Program_ID To resolve this conflict, a many-to-many relationship must be replaced with an association entity which relates the entities by two one-to-many relationships: PROGRAMME RELEVANCE N {Proj_ID, Year, Program_ID} (PK) {Proj_ID, Year} (FK) Program_ID (FK) M Database Systems (EE22) - Page 2

The general pattern to forming the association entity is to migrate the primary keys of the two entities to the association entity. The combination of these two foreign keys becomes the primary key of the association entity. This new structure allows us to express a many-to-many relationship between the original two entities whilst obeying the rules of relations. Try the above exercise again on the new schema: show project number 4 in 2006 being suitable for both the ICE and DME programmes. The complete schema for the final year project database (neglecting attributes other than PKs and FKs) is shown below. SUPERVISOR ASSIGNED N Student_ID (FK) Supervisor_ID (FK) SUPERVISE PROGRAMME N RELEVANCE {Proj_ID, Year, Program_ID} (PK) {Proj_ID, Year} (FK) Program_ID (FK) M Database Systems (EE22) - Page 22

We have shown (some) of the notation of E-R diagrams and how data objects and the relationships between them may be captured using data modelling. As mentioned previously, the other aspect of conceptual design is functional modelling, which entails specify the operations that will be performed on the database. In the next section we look at an abstract language (independent of the particular DBMS that will be used) that allows us to specify these operations. Exercise 3 Consider the group of four relations listed below: (Student_ID, First_Name, Last_Name) REGISTER (Student_ID, Module_ID, Semester-Start-Date) LECTURER (Lecturer_ID, First_Name, Last_Name) MODULE (Module_ID, Module_Name, Lecturer_ID) The following additional information has been determined by the database designer: The primary key of is {Student_ID} A student may register for a module more than once (e.g. to repeat it), but only once in any given semester. That is, the primary key of REGISTER is {Student_ID, Module_ID, Semester-Start-Date} The primary key of LECTURER is {Lecturer_ID} The primary key of MODULE is {Module_ID} Draw an E-R diagram showing the entities and relationships in this database schema. Show the primary and foreign keys and the connectivity (i.e. one-to-one, many-toone, etc.) between entities. Database Systems (EE22) - Page 23