Entity Relationship Modelling. A short guide to designing Entity Relationship Models using Barker s notation. By Frankie Inguanez

Similar documents
The Entity-Relationship Model

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

True. All that perfect systems need are correct programs.

Data Analysis 1. SET08104 Database Systems. Napier University

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

Designing Databases. Introduction

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

Preview DESIGNING DATABASES WITH VISIO PROFESSIONAL: A TUTORIAL

Entity - Relationship Modelling

Chapter 3. Data Analysis and Diagramming

DATABASE INTRODUCTION

Entity-Relationship Model

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

Developing Entity Relationship Diagrams (ERDs)

Fundamentals of Database Design

Select the Crow s Foot entity relationship diagram (ERD) option. Create the entities and define their components.

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

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

Foundations of Information Management

RELATIONSHIP STRENGTH

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

Database Management Systems

Exercise 1: Relational Model

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

Conceptual Design: Entity Relationship Models. Objectives. Overview

XV. The Entity-Relationship Model

TIM 50 - Business Information Systems

Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

ER modelling, Weak Entities, Class Hierarchies, Aggregation

Lecture 12: Entity Relationship Modelling

DATABASE MANAGEMENT SYSTEMS. Question Bank:

1 Class Diagrams and Entity Relationship Diagrams (ERD)

2. Conceptual Modeling using the Entity-Relationship Model

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

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

Relational Database Basics Review

Data Modelling And Normalisation

EXTENDED LEARNING MODULE A

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

7.1 The Information system

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

SQL AND DATA. What is SQL? SQL (pronounced sequel) is an acronym for Structured Query Language, CHAPTER OBJECTIVES

A Tutorial on Quality Assurance of Data Models 1. QA of Data Models. Barry Williams. tutorial_qa_of_models.doc Page 1 of 17 31/12/ :18:36

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

Course Title: Database Design I

Modern Systems Analysis and Design

Data Modelling and E-R Diagrams

Data Modeling Basics

Database Design Process

Lecture Notes INFORMATION RESOURCES

Relational Database Concepts

ComponentNo. C_Description UnitOfMeasure. C_Quantity


Toad Data Modeler - Features Matrix

- Eliminating redundant data - Ensuring data dependencies makes sense. ie:- data is stored logically

Database Design and Implementation

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

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

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

Collated Food Requirements. Received orders. Resolved orders. 4 Check for discrepancies * Unmatched orders

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

2 SYSTEM DESCRIPTION TECHNIQUES

USING UML FOR OBJECT-RELATIONAL DATABASE SYSTEMS DEVELOPMENT: A FRAMEWORK

SpatiaLite Using SQL Views is really simple and easy a very short introduction

Database Design Process

Relational Databases. Christopher Simpkins

Designing a Database Schema

Introduction This document s purpose is to define Microsoft SQL server database design standards.

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

IT2305 Database Systems I (Compulsory)

- Suresh Khanal. Microsoft Excel Short Questions and Answers 1

A technical discussion on modeling with UML 06/11/03 Entity Relationship Modeling with UML

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

IV. The (Extended) Entity-Relationship Model

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

DbSchema Tutorial with Introduction in SQL Databases

Tutorial on Relational Database Design

IT3 Database Questions

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

AS LEVEL Computer Application Databases

Animated Courseware Support for Teaching Database Design

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

Lesson 8: Introduction to Databases E-R Data Modeling

The Relational Data Model: Structure

Access Tutorial 3: Relationships

Foundations of Information Management

Using UML Part One Structural Modeling Diagrams

DATABASE DESIGN & PROGRAMMING WITH SQL COURSE CODE: 5324

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

Databases and DBMS. What is a Database?

601/8498/X IAO Level 3 Certificate in Web Design and Development (RQF)

Introduction. UML = Unified Modeling Language It is a standardized visual modeling language.

The Relational Data Model and Relational Database Constraints

IT2304: Database Systems 1 (DBS 1)

Final Exam Microeconomics Fall 2009 Key

Transcription:

Entity Relationship Modelling short guide to designing Entity Relationship Models using arker s notation. y Frankie Inguanez

Entity Relationship Modelling Table of Contents Part 01 - Introduction!... 4 Disclaimer... 4 Scope of this document... 4 Purpose of this document... 4 Part 02 - Modelling!... 5 Data Modelling... 5 Entity Relationship Diagrams... 5 General Rules of ERDs... 5 ERD Concepts... 6 Drawing an Entity... 7 Drawing attributes... 7 Drawing Relationships... 8 Optionality of a Relationship!... 8 Relationship Perspectives!... 9 Labeling of relationships!... 10 Degree of a Relationship!... 11 UID ar... 16 Recursive Relationships... 17 Redundant Relationships... 18 UID ttributes... 19 Entity Subtypes... 22 Entity Subtypes Rules!... 22 Drawing subtypes!... 22 Implementing a subtype!... 24 Exclusive Relationship rc!... 25 Rules of the exclusive relationship arc!... 27 Drawing an exclusive relationship arc!... 27 Implementing an exclusive relationship arc!... 27 Non-Transferability of Relationships... 28 Drawing of Non-Transferability!... 28 Implementation of Non-Transferability!... 28 Frankie Inguanez - 2012 Page 2 of 31

Entity Relationship Modelling Part 04 - Notes... 29 Part 04 Feedback and Queries... 31 Contact Details... 31 Frankie Inguanez - 2012 Page 3 of 31

Entity Relationship Modelling - Introduction Part 01 - Introduction Disclaimer The contents of this document is completely my work and no profit has been generated during the making or through this document. The arker s notation is not my work but rather the work of Richard arker. This document has been created for research and educational purposes and in no way is it intended for commercial use. Use of this document in commercial projects is at your own risk. The colours used in this document are purely for educational purposes and should not be considered as part of the notation being documented. The name of items, products and persons listed in examples are purely fictional and intended for educational purposes and no advertisement or reference to actual persons is intended! Scope of this document This document is intended for database designers, educators and learners, This document is intended as supporting documentation to the topic of Entity Relationship Modelling in particular, using the arker Notation. Purpose of this document My intention for this document is to portray my method and approach of explaining topics and to partially showcase my understanding of such topics. Frankie Inguanez - 2012 Page 4 of 31

Entity Relationship Modelling - ERD Notes Part 02 - Modelling Data Modelling Definition: N..! data model is a graphical representation of the solution to a problem as adopted by a particular community. Different communities trying to resolve the same problem will produce different yet valid solutions. Entity Relationship Diagrams Definition: N..! n Entity Relationship Diagram is a logical diagram representing the database structure using the relational model. There are different notations or ERDs, for the following notes we shall be adopting arker s notation. General Rules of ERDs 1. Capture all required information 2. Information appears only once 3. Model no information that is derivable from other information already modelled 4. Information is in a predictable, logical place Frankie Inguanez - 2012 Page 5 of 31

Entity Relationship Modelling - ERD Concepts ERD Concepts ERDs make use of three concepts: 1. Entity n entity is an object which the community trying to solve a problem, feel that it is important to include. Other communities trying to resolve the same problem might depreciate the entity to an attribute or else might completely omit it from their solution. E.g.: In a database collecting information of CDs one would expect to find entities such as CD N.. When implementing a database an entity would transmit to a table. N.. n entity instance is a record within a table. ENTITY 2. ttribute n attribute is a property of an entity which describes the characteristics of a particular entity instance. n attribute can be of three types: a. Unique Identifier: UID is an attribute whose value uniquely identifies an entity instance. UID is implemented as a Primary Key. b. Mandatory ttribute: mandatory attribute is one whose value cannot be null. c. Optional ttribute: n optional attribute is one whose value can be null. ENTITY # UID * Mandatory O Optional 3. Relationship relationship links two or more entity instances together. N.. relationship is implemented as a Foreign Key and therefore the FK attribute is not listed as an attribute in the target entity. EMPLOYEE * Surname work in have DEPRTMENT Frankie Inguanez - 2012 Page 6 of 31

Entity Relationship Modelling - Drawing Concepts Drawing an Entity When drawing an Entity using arker s notation the following rules need to be respected: 1. n entity is a rounded corner rectangle. 2. n entity must be named and the name must be placed inside of the entity, upper most part. 3. The entity name should be in upper case form. 4. The entity name should be in singular form. E.g.: CD CR PERSON SCHOOL TOWN Drawing attributes When drawing an ttribute using arker s notation the following rules need to be respected: 1. The attributes must be written such that all persons can understand and not just developers (meaningful terms) 2. ttributes must be written with the first letter of each word in upper case and the rest in lower case. 3. Next to each attribute a symbol should be placed representing the type of attribute. E.g.: EMPLOYEE * First Name * Last Name * Date of irth * Telephone Number o Mobile Number DEPRTMENT JO * Title N.. The colours used in this document are solely to assist in the explanation of the topics. Frankie Inguanez - 2012 Page 7 of 31

Entity Relationship Modelling - Drawing Concepts Drawing Relationships When drawing a Relationship using the arker s notation the following rules need to be respected: 1. relationship can exist between a maximum of two entities. 2. relationship can exist on the same entity. 3. relationship has two perspectives. 4. oth perspectives of a relationship must be labelled. When drawing a Relationship using the arker s notation the following steps need to be taken: 1. Determine the entities affected by the relationship. 2. Determine the optionality of the relationship. 3. Determine the degree of the relationship. 4. Label the perspectives of the relationship. Optionality of a Relationship 1. Mandatory Relationship: mandatory relationship specifies that each instance from an entity must be related to another instance. This is represented by a straight line. 2. Optional Relationship: n optional relationship specifies that each instance from an entity may be related to another instance. This is represented by a dashed line. Frankie Inguanez - 2012 Page 8 of 31

Entity Relationship Modelling - Drawing Concepts Relationship Perspectives relationship is always made up of two perspectives using the following notation: label a First Perspective / Perspective: Each must label a one or more s label b Second Perspective / Perspective: Each may label b exactly one. label a label b E.g.: PERSON own CR owned by First Perspective / PERSON Perspective: Each PERSON may own one or more CRs. Second Perspective / CR Perspective:! Each CR must be owned by exactly one PERSON. IRLINE have belong to IRPLNE First Perspective / IRLINE Perspective: Each IRLINE must have one or more IRPLNEs. Second Perspective / IRPLNE Perspective:! Each IRPLNE must belong to exactly one IRLINE. Frankie Inguanez - 2012 Page 9 of 31

Entity Relationship Modelling - Drawing Concepts Labeling of relationships When labelling relationships the following notations need to be followed: label 4 label 3 label 1 label 2 E.g.: 1. label should be applied for each perspective. 2. label should be a verb. 3. label should be written in lower case form. 4. label should be positioned according to the diagram shown above. 5. label should be relevant to the scenario. LEGUE TEM * Year be won by be the winner of be organized by be made up of organize be a member of CONFEDERTION PLYER * Surname Frankie Inguanez - 2012 Page 10 of 31

Entity Relationship Modelling - Drawing Concepts Degree of a Relationship relationship can be one of three types: 1. One-to-One Relationship (1:1) Each entity instance is related to just one entity instance. In the following table we shall see the four possible combinations of a one-to-one relationship and the various optionality. In the last two columns we have an indication of the minimum and maximum number of entity instances that can be related according to perspective. # Scenario Minimum Maximum 1 -> 0 -> 1 -> 0 -> 1 2 -> 1 -> 0 -> 1 -> 1 3 -> 0 -> 1 4 -> 1 -> 1 -> 1 -> 1 -> 1 -> 1 N.. Labels and attributes have been removed from the above scenario since they are not the focus of the topic. Frankie Inguanez - 2012 Page 11 of 31

Entity Relationship Modelling - Drawing Concepts The following table indicates where the foreign keys should be implemented: # Scenario Foreign Key 1 FK should be placed in the entity with the least number of rows/nulls or where it is the most relevant. 2 FK should be placed in entity since there will never be any NULL values in the FK. 3 FK should be placed in entity since there will never be any NULL values in the FK. 4 FK should be placed where it is the most relevant according to the scenario since it will never be a NULL value in the FK. N.. Labels and attributes have been removed from the above scenario since they are not the focus of the topic. N.. The FK attribute would never be listed in the ERD, the above explanation is referring to the database implementation phase. Frankie Inguanez - 2012 Page 12 of 31

Entity Relationship Modelling - Drawing Concepts 2. One-to-Many Relationship (1:M) Each entity instance is related to multiple entity instances. In the following table we shall see the four possible combinations of a one-to-one relationship and the various optionality. In the last two columns we have an indication of the minimum and maximum number of entity instances that can be related according to perspective. # Scenario Minimum Maximum 1 -> 0 -> 0 -> n -> 1 2 -> 1 -> 0 3 -> 0 -> 1 4 -> 1 -> 1 -> n -> 1 -> n -> 1 -> n -> 1 N.. Labels and attributes have been removed from the above scenario since they are not the focus of the topic. N.. When implementing this type of relationship a foreign key should be placed in entity, meaning the entity touched with the crow s foot, many symbol, since many rows in will be related to only one row in. Frankie Inguanez - 2012 Page 13 of 31

Entity Relationship Modelling - Drawing Concepts 3. Many-to-Many Relationship (M:M) This type of relationship is never required and needs to be resolved. # Scenario 1 Problem: Solution: 2 Problem: Solution: 3 Problem: Solution: 4 Problem: Solution: N.. Labels and attributes have been removed from the above scenario since they are not the focus of the topic. Frankie Inguanez - 2012 Page 14 of 31

Entity Relationship Modelling - Drawing Concepts The following steps need to be followed when resolving a many-to-many relationship: 1. Create a third/intermediary/transactional entity. 2. dd two one-to-many relationships from the original entities to the new entity. 3. The optionality from the perspective should always be mandatory. 4. The optionality of the remaining perspectives is derived from the original many-to-many relationship. 5. UID ars are added to the perspectives (These indicate that the foreign keys are also primary keys refer to next chapter UID ar). E.g.: ORDER have listed in ITEM ORDER listed in refers to ORDER ITEM refers to listed in ITEM Frankie Inguanez - 2012 Page 15 of 31

Entity Relationship Modelling - UID ar UID ar It could be the case that sometimes a foreign key is also part of a primary key, generally a composite key. Consider the following scenario: database stores a list of daily orders. table is needed for the daily orders and another for the various items available. third table (resolving a manyto-many relationship) lists the items sold in each order Implementation: Table: Orders Table: Order Items Table: Items Order ID Order Date Order ID Item ID Quantity Item ID Item Name Item Price 1 22/11/10 1 10 3 10 Coca 50 2 23/11/10 1 20 1 20 Fanta 40 1 30 2 30 Sprite 30 2 10 2 2 20 1 N.. Primary Keys are underlined and foreign keys are in italics. ERD: ORDER # Order Id * Order Date listed in listed in ORDER ITEM * Quantity listed in listed in ITEM # Item Id * Item Name * Item Price Problem: The problem with the above ERD is that we cannot indicate that the same foreign keys found in ORDER ITEM, represented by the relationships, are also the primary keys of the same entity. We cannot list the attributes and add a UID symbol (#) since arker s notation requires that no data is represented twice. Solution: ORDER # Order Id * Order Date listed in listed in ORDER ITEM * Quantity listed in listed in ITEM # Item Id * Item Name * Item Price The solution is to add the UID ar to the ORDER ITEM perspectives. Each individual UID ar represents the fact that the foreign key represented by the relationship is also a primary key of the entity to which the perspective belongs to. Frankie Inguanez - 2012 Page 16 of 31

Entity Relationship Modelling - Recursive Relationships Recursive Relationships There are situations where a relationship acts upon the same entity. This type of relationship is called a recursive relationship and is generally implemented by having a foreign key referring to the primary key of the same entity. Consider the following scenario: company is made up of a number of employees. Joe is the chairman and has no manager. Joe is the manager of Tony and Lisa. Tony is the manager of lex and Sarah. Lisa is the manager of Ian and Joanne. Organisational Structure Chart: Joe Tony Lisa lex Sarah Ian Joanne ERD: EMPLOYEE manage managed by Perspectives:! Each EMPLOYEE may manage one or more EMPLOYEEs. Each EMPLOYEE may be managed by exactly one EMPLOYEE. Implementation: Table: Employees Employee Id Name Manager ID 1 Joe 2 Tony 1 3 Lisa 1 4 lex 2 5 Sarah 2 6 Ian 3 7 Joanne 3 N.. Primary keys are underlined and foreign keys are in italics. Frankie Inguanez - 2012 Page 17 of 31

Entity Relationship Modelling - Redundant Relationships Redundant Relationships It could be the case that the information represented by a relationship can be derived from other information already being represented in an ERD. This relationship is called a redundant relationship and needs to be removed. E.g.: COUNTRY have located in TOWN host live in PERSON * Surname host live in Problem: The relationship between COUNTRY and PERSON is redundant since the same information can be deduced from the other two relationships. Solution ERD: COUNTRY have located in TOWN host live in PERSON * Surname N.. There can be other relationships between COUNTRY and PERSON as long as it represents different information. Frankie Inguanez - 2012 Page 18 of 31

Entity Relationship Modelling - UID ttributes UID ttributes There are four types of Unique Identifier attributes which are implemented as primary keys: 1. Single UID ttribute: single UID attribute is when an entity is made up of only one UID attribute which is not a foreign key. ERD: Implementation: EMPLOYEE * First Name * Surname Table: Employees Id First Name Surname 1 Joe org 2 Tony Galea 3 Lisa bela N.. Primary keys are underlined. ERD: 2. Multiple UID ttribute: multiple UID attribute is when a primary key is made up of multiple attributes (composite primary key) all of which are nonforeign keys. SOFTWRE # Name # Version Implementation: Table: Software Name Version Oracle DMS 11g MySQL 5.1 SQL Server 2008 N.. Primary keys are underlined. Frankie Inguanez - 2012 Page 19 of 31

Entity Relationship Modelling - UID ttributes 3. Composed UID ttribute: composed UID attribute is when an entity has a primary key which is also a foreign key. These are marked with a UID ar. ERD: PERSON * Surname have refers to VISITED COUNTRY refers to listed in COUNTRY! Implementation: Table: Persons Table: Visited Countries Table: Countries Id Name Surname Person ID Country ID Id Name 1 Joe org 1 1 1 Italy 2 Tony Galea 1 2 2 England 3 Lisa bela 1 3 3 France 2 4 4 Switzerland 3 4 N.. The attributes Person Id and Country Id in the relation Visited Countries are the composed UID attributes since they are both foreign keys as well as primary keys in the VISITED COUNTRY entity. This is represented by the UID ars on both relationships. Frankie Inguanez - 2012 Page 20 of 31

Entity Relationship Modelling - UID ttributes ERD: 4. Composed Cascade UID ttribute: composed cascade UID attribute is when an entity uses its foreign keys as primary keys from an entity with composed UID attributes. HOTEL have belong to FLOOR # Number have located on ROOM # Number Implementation: Table: Hotels Table: Floors Table: Rooms Id Name Hotel ID Floor Hotel Id Floor Room Number Number Number 1 Hilton 1 1 1 1 1 2 Westin 2 1 1 1 2 2 2 2 1 1 2 1 2 2 2 1 N.. Primary keys are underlined and foreign keys are written in italics. N.. Hotel Id and Floor Number in ROOM are composed cascade attribute UIDs. Frankie Inguanez - 2012 Page 21 of 31

Entity Relationship Modelling - Entity Subtypes Entity Subtypes There are situations where different entities can be grouped together under one common entity called a super type entity whilst the nested entities would be the subtype entities. E.g.: CR STFF VENUE SEDN HTCHCK CDEMIC DMINISTRTIVE PRIVTE VENUE OTHER CR OTHER STFF PULIC VENUE Entity Subtypes Rules 1. Exhaustive Rule: This rule states that every entity instance of the super type must be an instance of one of the subtypes. 2. Mutually Exclusive Rule: This rule states that every entity instance of the super type can be an instance of only one entity subtype and not the other. Drawing subtypes When drawing entity subtypes the following notes need to be kept in mind: 1. Each subtype is a specialisation of a super type and therefore must be enclosed within an entity. 2. The common attributes and relationships for all subtypes must be listed in the super type only but are inherited in every subtype. 3. subtype can and would generally have attributes and relationships of its own. 4. There can never be just one subtype; another subtype should be created to cater for the rest. SUPERTYPE SUTYPE OTHER Frankie Inguanez - 2012 Page 22 of 31

Entity Relationship Modelling - Entity Subtypes N.. If none of the subtypes have any unique attributes or relationships then it is not recommended to make use of subtypes but rather create a separate entity containing a list of the various types required. E.g.: ENGINE TYPE VEHICLE * Power * Capacity used in use * Number of passengers CR * Number of doors * Has Roof-Rack TRNSMISSION TYPE used in OTHER VEHICLE use MOTORCYCLE In this ERD note that: The relationships acting on VEHICLE are also acting on its subtypes. Each subtype has attributes ID and Number of passengers. The CR subtype has two extra attributes. The MOTORCYCLE subtype has an extra relationship. The OTHER VEHICLE subtype is catering for those VEHICLE instances that are neither cars nor motorcycles. associated with have CUSTOM HELMET * Model Name Frankie Inguanez - 2012 Page 23 of 31

Entity Relationship Modelling - Entity Subtypes Implementing a subtype There are various methods of implementing a subtype but the preferred method is as follows: 1. Create a table for the super type with all common attributes and relationships. 2. Create a separate table for each subtype. 3. In the subtypes include the specific attributes and relationships. 4. Create a foreign key in the super type for each subtype. 5. Impose a constraint that only one foreign key may not be null. 6. Impose a constraint that at least one foreign key must not be null. ERD: VENUE PULIC PRIVTE * Fee Implementation: Table: Venues Table: Public Venues Table: Private Venues Vid Name Pub_id Prv_id Pub_id Prv_id Fee 1 Floriana Granaries 1 1 1 500 2 Villa rrigo 1 2 600 3 MFCC 2 Frankie Inguanez - 2012 Page 24 of 31

Entity Relationship Modelling - Exclusive Relationship rc Exclusive Relationship rc There can be situations where an entity is either related to one entity or to another but not both. Whenever a selection needs to be done between relationships, an exclusive relationship arc is created. Recall the subtypes scenario: VENUE PULIC VENUE PRIVTE VENUE * Fee The above entity with respective subtypes can, in principal, be represented as follows: VENUE is is PULIC VENUE is is PRIVTE VENUE * Fee Each VENUE must either be exactly one PULIC VENUE or PRIVTE VENUE.! Each PULIC VENUE must be exactly one VENUE.! Each PRIVTE VENUE must be exactly one VENUE. N.. Even though both rules of subtypes can be modelled as shown above they should always be represented as subtypes rather than using the arc. N.. If other relationships cross the exclusive relationship arc but are not affected by the exclusivity then they will not be circled. Frankie Inguanez - 2012 Page 25 of 31

Entity Relationship Modelling - Exclusive Relationship rc Consider: database is required to store a list of runways. runway might be owned by an airport, such as Malta International irport. n airport would own at least one runway but may own more. runway may instead be owned by a club, such as a Motor Racing Club that owns the runway in Ħal-Far, or the Remote Control Club that owns the runway in Ta Qali. Lets say that a law in our country imposes that a club is allowed to own only one runway. Lets also say that no runway may be abandoned. N.. We cannot use subtypes since a RUNWY is not an IRPORT, nor is it a CLU. lso an airport may have more than one runway whilst a club may have only one runway. Therefore the following is wrong. RUNWY IRPORT This scenario therefore cannot be resolved by using subtypes. ut we need the mutually exclusive rule. Therefore we use the exclusive relationship arc. CLU Solution: RUNWY IRPORT CLU Frankie Inguanez - 2012 Page 26 of 31

Entity Relationship Modelling - Exclusive Relationship rc TRGET SOURCE SOURCE Rules of the exclusive relationship arc The following rules need to be applied when drawing an exclusive relationship arc: 1. relationship arc may be applied to only one entity, called the target entity. 2. The relationship arc must be applied to a minimum number of two relationships. 3. The target entity will contain the foreign keys of the relationships affected by the arc. 4. The optionality of the relationships affected by the arc must be the same from the perspective of the target entity. 5. The optionality of the relationships affected by the arc may be different from the perspectives of the source entities. 6. The relationships affect by the arc may be have a different cardinality (oneto-one, one-to-many). Drawing an exclusive relationship arc To design an exclusive relationship arc the following steps need to be taken: 1. Determine the owner of the relationship arc. 2. Draw an arc across the relationships to be affect and around the entity that owns the arc. 3. Circle the crossed relationships that are to be affected. Implementing an exclusive relationship arc To implement an exclusive relationship arc the following steps need to be done: 1. Create a foreign key for each relationship affected by the arc. The foreign keys must be placed in the entity to which the arc belongs to. 2. Implement a constraint that allows only one foreign key value not to be null. Frankie Inguanez - 2012 Page 27 of 31

Entity Relationship Modelling - Non-Transferability of Relationships Non-Transferability of Relationships In certain situations once a relationship is set it can never change. We call this the non-transferability of a relationship. E.g.: ERD: OOK PERSON written by the author of * Surname Perspectives: Each OOK must be written by exactly one PERSON. Each PERSON may be the author of one or more OOKs. Drawing of Non-Transferability When drawing the non-transferability of a relationship the following rules need to be respected: 1. The diamond symbol should be on the perspective where the foreign key will be implemented. 2. The non-transferability symbol should be displayed only once per relationship provided that any many-to-many relationships have been resolved. Implementation of Non-Transferability When implementing the non-transferability of a relationship a constraint is applied to the foreign key which does not allow the values to be updated. Frankie Inguanez - 2012 Page 28 of 31

Entity Relationship Modelling - Notes Part 04 - Notes Frankie Inguanez - 2012 Page 29 of 31

Entity Relationship Modelling - Notes Frankie Inguanez - 2012 Page 30 of 31

Entity Relationship Modelling - Feedback and Queries Part 04 Feedback and Queries Contact Details In case you need to query about this report or would like to provide feedback you can use the following contact details: Name:! E-Mail:! LinkedIn:! Frankie Inguanez frankie.inguanez@gmail.com http://mt.linkedin.com/in/frankieinguanez Frankie Inguanez - 2012 Page 31 of 31