Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina



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

Data Analysis 1. SET08104 Database Systems. Napier University

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

In This Lecture. Security and Integrity. Database Security. DBMS Security Support. Privileges in SQL. Permissions and Privilege.

SQL Data Definition. Database Systems Lecture 5 Natasha Alechina

SCHEMAS AND STATE OF THE DATABASE

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

EXTENDED LEARNING MODULE A

In This Lecture. Physical Design. RAID Arrays. RAID Level 0. RAID Level 1. Physical DB Issues, Indexes, Query Optimisation. Physical DB Issues

1 Class Diagrams and Entity Relationship Diagrams (ERD)

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

In this Lecture SQL SELECT. Example Tables. SQL SELECT Overview. WHERE Clauses. DISTINCT and ALL SQL SELECT. For more information

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

LOGICAL DATABASE DESIGN

DATABASE INTRODUCTION

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

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

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

Database Design Methodology

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

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

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

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

The Entity-Relationship Model

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

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

Data Modelling and E-R Diagrams

IT2305 Database Systems I (Compulsory)

Data Modeling and Databases I - Introduction. Gustavo Alonso Systems Group Department of Computer Science ETH Zürich

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

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

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

Lecture 12: Entity Relationship Modelling

TIM 50 - Business Information Systems

Entity - Relationship Modelling

Database Design and Database Programming with SQL - 5 Day In Class Event Day 1 Activity Start Time Length

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


Entity-Relationship Model

SAMPLE FINAL EXAMINATION SPRING SESSION 2015

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

Relational Database Concepts

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

Modern Databases. Database Systems Lecture 18 Natasha Alechina

2. Conceptual Modeling using the Entity-Relationship Model

Developing Entity Relationship Diagrams (ERDs)

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

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

2.5.3 Use basic database skills to enter information in a database

Designing Databases. Introduction

The Entity-Relationship Model

Introduction to Databases

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

Introduction to Databases

Databases and BigData

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

Graduate School of Informatics

Database Design Process

Foundations of Business Intelligence: Databases and Information Management

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

Lesson 8: Introduction to Databases E-R Data Modeling

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

Lecture Notes INFORMATION RESOURCES

Database Design Process

IT2304: Database Systems 1 (DBS 1)

Release: 1. ICADBS502A Design a database

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

Chapter 6 FOUNDATIONS OF BUSINESS INTELLIGENCE: DATABASES AND INFORMATION MANAGEMENT Learning Objectives

Information Management

Course MIS. Foundations of Business Intelligence

Databases What the Specification Says

Transactions and Recovery. Database Systems Lecture 15 Natasha Alechina

Modern Systems Analysis and Design

Foundations of Information Management

Exercise 1: Relational Model

IV. The (Extended) Entity-Relationship Model

Database Design Methodology

Database Management Systems

In This Lecture. More Concurrency. Deadlocks. Precedence/Wait-For Graphs. Example. Example

Foundations of Business Intelligence: Databases and Information Management

The process of database development. Logical model: relational DBMS. Relation

Welcome to the Data Analytics Toolkit PowerPoint presentation on EHR architecture and meaningful use.

7.1 The Information system

Physical Database Design Process. Physical Database Design Process. Major Inputs to Physical Database. Components of Physical Database Design

SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

Answers to Review Questions

Designing a Database Schema

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

Database Design and the E-R Model

Higher National Unit specification: general information. Relational Database Management Systems

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

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

Database Systems Introduction Dr P Sreenivasa Kumar

Databases and DBMS. What is a Database?

How To Write A Diagram

Course: CSC 222 Database Design and Management I (3 credits Compulsory)

The Relational Data Model: Structure

Transcription:

Entity/Relationship Modelling Database Systems Lecture 4 Natasha Alechina

In This Lecture Entity/Relationship models Entities and Attributes Relationships Attributes E/R Diagrams For more information Connolly and Begg chapter 11 Ullman and Widom chapter 2

Database Design Before we look at how to create and use a database we ll look at how to design one Need to consider What tables, keys, and constraints are needed? What is the database going to be used for? Conceptual design Build a model independent of the choice of DBMS Logical design Create the database in a given DBMS Physical design How the database is stored in hardware

Entity/Relationship Modelling E/R Modelling is used for conceptual design Entities - objects or items of interest Attributes - facts about, or properties of, an entity Relationships - links between entities Example In a University database we might have entities for Students, Modules and Lecturers. Students might have attributes such as their ID, Name, and Course, and could have relationships with Modules (enrolment) and Lecturers (tutor/tutee)

Entity/Relationship Diagrams E/R Models are often represented as E/R diagrams that Give a conceptual view of the database Are independent of the choice of DBMS Can identify some problems in a design Lecturer Tutors Module ID Name Course Student Studies

Entities Entities represent objects or things of interest Physical things like students, lecturers, employees, products More abstract things like modules, orders, courses, projects Entities have A general type or class, such as Lecturer or Module Instances of that particular type, such as Steve Mills, Natasha Alechina are instances of Lecturer Attributes (such as name, email address)

Diagramming Entities In an E/R Diagram, an entity is usually drawn as a box with rounded corners The box is labelled with the name of the class of objects represented by that entity Lecturer Tutors Module ID Name Course Student Studies

Attributes Attributes are facts, aspects, properties, or details about an entity Students have IDs, names, courses, addresses, Modules have codes, titles, credit weights, levels, Attributes have A name An associated entity Domains of possible values Values from the domain for each instance of the entity they are belong to

Diagramming Attributes In an E/R Diagram attributes may be drawn as ovals Each attribute is linked to its entity by a line The name of the attribute is written in the oval Lecturer Tutors Module ID Name Course Student Studies

Relationships Relationships are an association between two or more entities Each Student takes several Modules Each Module is taught by a Lecturer Each Employee works for a single Department Relationships have A name A set of entities that participate in them A degree - the number of entities that participate (most have degree 2) A cardinality ratio

Cardinality Ratios Each entity in a relationship can participate in zero, one, or more than one instances of that relationship This leads to 3 types of relationship One to one (1:1) Each lecturer has a unique office One to many (1:M) A lecturer may tutor many students, but each student has just one tutor Many to many (M:M) Each student takes several modules, and each module is taken by several students

Diagramming Relationships Relationships are links between two entities The name is given in a diamond box The ends of the link show cardinality Lecturer Tutors Module ID Name Course Student Studies One Many

Removing M:M Relationships Many to many relationships are difficult to represent We can split a many to many relationship into two one to many relationships An entity represents the M:M relationship Student Studies Module Student Has Enrolment In Module

Making E/R Models To make an E/R model you need to identify Enitities Attributes Relationships Cardinality ratios from a description General guidelines Since entities are things or objects they are often nouns in the description Attributes are facts or properties, and so are often nouns also Verbs often describe relationships between entities

Example A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students

Example - Entities A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students

Example - Relationships A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students

Example - E/R Diagram Entities: Department, Course, Module, Lecturer, Student Department Course Module Lecturer Student

Example - E/R Diagram Each department offers several courses Offers Department Course Module Lecturer Student

Example - E/R Diagram A number of modules make up each courses Offers Department Course Includes Module Lecturer Student

Example - E/R Diagram Students enrol in a particular course Offers Department Course Includes Module Lecturer Enrols In Student

Example - E/R Diagram Students take modules Offers Department Course Includes Module Lecturer Takes Enrols In Student

Example - E/R Diagram Each module is taught by a lecturer Offers Department Course Includes Module Teaches Lecturer Takes Enrols In Student

Example - E/R Diagram a lecturer from the appropriate department Offers Department Employs Course Includes Module Teaches Lecturer Takes Enrols In Student

Example - E/R Diagram each lecturer tutors a group of students Offers Department Employs Course Includes Module Teaches Lecturer Takes Enrols In Student Tutors

Example - E/R Diagram Offers Department Employs Course Includes Module Teaches Lecturer Takes Enrols In Student Tutors

Entities and Attributes Sometimes it is hard to tell if something should be an entity or an attribute They both represent objects or facts about the world They are both often represented by nouns in descriptions General guidelines Entities can have attributes but attributes have no smaller parts Entities can have relationships between them, but an attribute belongs to a single entity

Example We want to represent information about products in a database. Each product has a description, a price and a supplier. Suppliers have addresses, phone numbers, and names. Each address is made up of a street address, a city, and a postcode.

Example - Entities/Attributes Entities or attributes: product description price supplier address phone number name street address city postcode Products, suppliers, and addresses all have smaller parts so we can make them entities The others have no smaller parts and belong to a single entity

Example - E/R Diagram Price Description Product Street address Name Supplier Address City Phone number Postcode

Example - Relationships Each product has a supplier Each product has a single supplier but there is nothing to stop a supplier supplying many products A many to one relationship Each supplier has an address A supplier has a single address It does not seem sensible for two different suppliers to have the same address A one to one relationship

Example - E/R Diagram Price Description Product Has A Street address Name Supplier Has A Address City Phone number Postcode

One to One Relationships Some relationships between entities, A and B, might be redundant if It is a 1:1 relationship between A and B Every A is related to a B and every B is related to an A Example - the supplier-address relationship Is one to one Every supplier has an address We don t need addresses that are not related to a supplier

Redundant Relationships We can merge the two entities that take part in a redundant relationship together b a A c x B z y They become a single entity a x The new entity has all the attributes of the old one b AB y c z

Example - E/R Diagram Price Description Product Has A Name Supplier City Phone number Postcode Street address

Making E/R Diagrams From a description of the requirements identify the Entities Attributes Relationships Cardinality ratios of the relationships Draw the E/R diagram and then Look at one to one relationships as they might be redundant Look at many to many relationships as they might need to be split into two one to many links

Debugging Designs With a bit of practice E/R diagrams can be used to plan queries You can look at the diagram and figure out how to find useful information If you can t find the information you need, you may need to change the design Student Has Enrolment In Module How can you find a list of students who are enrolled in Database systems?

Debugging Designs ID Name ID Code Student Has Enrolment In (3) For each instance of Enrolment in the result of (2) find the corresponding Student (2) Find instances of the Enrolment entity with the same Code as the result of (1) Code Title Module (1) Find the instance of the Module entity with title Database Systems

This Lecture in Exams (and coursework 2007/8) A database will be made to store information about patients in a hospital. On arrival, each patient s personal details (name, address, and telephone number) are recorded where possible, and they are given an admission number. They are then assigned to a particular ward (Accident and Emergency, Cardiology, Oncology, etc.). In each ward there are a number of doctors and nurses. A patient will be treated by one doctor and several nurses over the course of their stay, and each doctor and nurse may be involved with several patients at any given time.

This Lecture in Exams Identify the entities, attributes, relationships, and cardinality ratios from the description. (4 marks) Draw an entity-relationship diagram showing the items you identified. (4 marks) Many-to-many relationships are hard to represent in SQL tables. Explain why many-to-many relationships cause problems in SQL tables, and show how these problems may be overcome. (4 marks)

Next Lecture SQL The SQL language SQL, the relational model, and E/R diagrams CREATE TABLE Columns Primary Keys Foreign Keys For more information Connolly and Begg chapter 6 Ullman and Widom chapter 6.5, 6.6