Lecture 9 Handling Many to Many Relationships INFO 1408 Database Design Concepts.

Slides:



Advertisements
Similar presentations
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Advertisements

Data Modeling. What are you keeping track of? You begin to develop a database by deciding what you are going to keep track of. Each thing that you are.
HNDComputing – DeMontfort University  DeMontfort University 2011 Handling Many to Many relationships wk5 Database Design ConceptsDatabase Design Concepts.
Transformation of an ER Model into a Relational Database Schema Translating to Software.
Section 09ER Decomposition Of Many To Many1 HSQ - DATABASES & SQL And Franchise Colleges 09 ER Decomposition of Many-to-Many.
ENTITY RELATIONSHIP MODELLING
Database design concepts info1408 Lecture 8 Worked example of E:R Modelling.
Entity-Relationship Model and Diagrams (continued)
Database design concepts info1408 Lecture 8 Worked example of E:R Modelling.
Lecture 10 Conversion to tables Database Design Concepts INFO1408.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Chapter 5 Normalization of Database Tables
Concepts of Database Management Seventh Edition
Chapter 4 Entity Relationship (ER) Modeling
Lecture 9 Handling Many to Many Relationships INFO 1408 Database Design Concepts.
Keys Chapter 8 Database Design for Mere Mortals. Why Keys Are Important They ensure that each record in a table can be properly identified. They help.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Entity Relationships. Relationships Relationships exist between entities The type of relationship is entirely dependent on the business rules The business.
MIS2502: Data Analytics Relational Data Modeling
Mapping ERM to relational database
Introduction to Databases
Chapter 5 UNDERSTANDING AND DESIGNING ACCOUNTING DATA.
Entity Relationship Diagram Farrokh Alemi Ph.D. Francesco Loaiza, Ph.D. J.D. Vikas Arya.
Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised.
CREATE THE DIFFERENCE Normalisation (special thanks to Janet Francis for this presentation)
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
MIS2502: Data Analytics Coverting ERD into a DB Schema David Schuff
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Chapter 5 Entity Relationship (ER) Modelling
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Introduction to Database Systems Mapping ER Models to Relational Schemas Irvanizam Zamanhuri, M.Sc Informatics (Computer Science) Study Program Syiah Kuala.
G057 - Lecture 02 Introduction To Database System Concepts Mr C Johnston ICT Teacher
HNDComputing – DeMontfort University  DeMontfort University 2011 Database Fundamentals wk2 Database Design ConceptsDatabase Design Concepts Database Design.
Artificial, Composite and Secondary UIDs
Database Systems: Design, Implementation, and Management Tenth Edition
Copyright Ó Oracle Corporation, All rights reserved. Normalization Use the student note section below for further explanation of the slide content.Use.
1 Information Retrieval and Use Data Analysis & Data Modeling, Relational Data Analysis and Logical Data Modeling Geoff Leese September 2009.
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
Section 08 (a)ER Modelling In Practice1 HSQ - DATABASES & SQL And Franchise Colleges 08 (a) ER Modelling In Practice QUICKHIRE Car Company.
Next Back A-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights.
Handling Many to Many Relationships. 2 Handling Many:Many Relationships Aims: To explain why M:M relationships cannot be implemented in relational database.
Btec National - Advanced Databases 1 Advanced Databases Entity Relationship Diagrams.
Database Design – Lecture 6 Moving to a Logical Model.
1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006.
Copyright Ó Oracle Corporation, All rights reserved. Assign Unique Identifiers A Unique Identifier (UID) is any combination of attributes and/or.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
44220: Database Design & Implementation Conceptual Data Modelling Ian Perry Room: C49 Tel Ext.: 7287
Database Design – Lecture 7
Link tables and keys Access/IPS Walsall College of Arts & Technology.
Conceptual Design to Logical Design Lecture 4. Aims  To introduce Business Rules  To identify what a Business Rule is  To Introduce Business Operations.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Tutorial 2 Data Modelling. 3 Terminology & Notation(1) An entity is an object about which the system needs to hold information –Customer, Student, Course.
Btec National - IT SYSTEMS ANALYSIS AND DESIGN 1 IT Systems Analysis and Design Entity Relationship Diagrams.
MIS2502: Data Analytics Relational Data Modeling David Schuff
Howard Paul. Sequential Access Index Files and Data File Random Access.
1 CS 430 Database Theory Winter 2005 Lecture 3: A Fifty Minute Introduction to Data Modeling.
1 Microsoft Access 2002 Tutorial 2 – Creating And Maintaining A Database.
Department of Mathematics Computer and Information Science1 CS 351: Database Management Systems Christopher I. G. Lanclos Chapter 4.
Let try to identify the conectivity of these entity relationship
Chapter 5 UNDERSTANDING AND DESIGNING ACCOUNTING DATA
Attributes and Domains
Mr C Johnston ICT Teacher
Entity-Relationship Model and Diagrams (continued)
Data Modelling Introduction
The 1:M Relationship (continued)
Database Modeling using Entity Relationship Model (E-R Model)
Database Management system
Database Management system
Presentation transcript:

Lecture 9 Handling Many to Many Relationships INFO 1408 Database Design Concepts

2 Handling Many:Many Relationships Aims: To demonstrate how to decompose many:many (M:M) relationships To explain why M:M relationships need to be decomposed. Introduce other types of relationships

3 M:M Relationships A M:M relationship between 2 entity types must be decomposed into two 1:M relationships.

4 StudentModule chooses MM Becomes ModuleStudent Module Choice makes is for M M 1 1

5 The Decomposition Rule AB r MM Becomes AB M M 1 1

6 Or - AB r MM Becomes AB M M 1 1

7 Naming Naming the new entity type and the new relationships is sometimes not easy Consider what it is representing If all else fails, concatenate/ join the names of the 2 original entity types (e.g. Student Module).

8 Exercise Decompose this M:M relationship to form two 1:M relationships: Assign the new entity and relationship types suitable names. Doctor Patient examines M M

9 Solution

10 Identifiers We have seen that an entity must have an Identifier The new entity type created by decomposition needs an identifier Start with a composite of the Identifiers of the 2 original entity types Need to consider carefully whether this will uniquely identify every occurrence of the new entity type.

11 Identifiers cont. For the second example: Doctor(doctor#,.... ) Patient(patient#,... ) Examination (Doctor#patient#,..) Is this a suitable identifier?.

12 Identifiers cont. To decide if an identifier is suitable: Think of some other attributes for the entity: Is one pair of doctor#, patient# values associated with just one value of each of these attributes?.

13 To decide if an identifier is suitable: Think of some other attributes for the entity: Is one pair of doctor#, patient# values associated with just one value of each of these attributes?. No

14 Could a patient see the same doctor more than once?

15 Could a patient see the same doctor more than once? Yes – So add date Examination (doctor#,patient#date, … )

16 Could a patient see the doctor more than once in a day?

17 Could a patient see the doctor more than once in a day? Yes ( not common) so add time Examination (doctor#,patient#date,time..)

18 This is getting a little complicated maybe we should add a new key field examination number Examination (Examination# doctor#, patient#, date, time,..) Note patient# and doctor# now foreign keys

19 Why Decompose? Student(student#, name,...) Module(module#, description,...) How do we know which students are taking which modules?. We don ’ t StudentModule chooses MM Back to the first example Look at the original M:M relationship:

20 Why Decompose? cont. Decomposing gives us a new table: Student Module (student#, module#, ) Is this a suitable identifier ? Now we can list which student has chosen which module.

21 Exercise Actor (actor#, name,...) Play (play#, title,...) Decompose this M:M relationship Assign the new entity type an appropriate name and think of some additional attributes for it Assign the new entity type a suitable identifier. Actor Play appears _in MM

22 Solution Actor (actor#, name … ) Play ( play#, name, writer, length … ) Production (actor#, play#, first_performance_date, director, venue/theatre_name... etc!)

23 Common Decomposition problem Many decomposition entities represent business transactions ( or pieces of paper) E.G booking, order, They may be very difficult to name-

24 Common decomposition problem- example Orderline (product#,order#, …) The orderline represents each line of the order

25 Other types of relationships Recursive relationships An individual entity can have a relationship with an entity of the same type

26 Another example- Estate agents It is possible to have more than one relationship between two entities

27 Summary We have looked at decomposition of m:m relationships. Discussed how to identify a unique identifier Introduced recursive relationships Introduced multiple relationships between entities

28 References Data Analysis for database Design By D R Howe