44
5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

  • View
    234

  • Download
    1

Embed Size (px)

Citation preview

Page 1: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.1

Topic 5DATA MODELLING:

ENTITY RELATIONSHIP MODELLING

IMS9001 - Systems Analysis and Design

Page 2: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.2

Data modelling

Focus on the information aspects of the organisation

In a database environment many applications share the same data

The database is a common asset and corporate resource

Corporate and application level data modelling

Page 3: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.3

Conceptual data modelling

A conceptual data model is a representation of organisational data

Captures the structure, meaning and interrelationships amongst the data

Independent of any data storage and access method

occurs in parallel with systems analysis activities

Page 4: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.4

Identification of information requirements

Allows integration of data across the organisation and across applications

Helps eliminate problems of data inconsistency and duplication across the organisation

Conceptual data modelling

Page 5: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.5

Techniques; Entity relationship modelling Normalisation Data structure diagrams

Good modelling techniques are supported by rigorous standards and conventions to remove ambiguity and aid understanding

Conceptual data modelling

Page 6: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.6

Entity relationship modelling

Used for conceptual data modelling Diagrammatic technique used to

represent: things of importance in an organisation -

entities the properties of those things -

attributes how they are related to each other -

relationships

Page 7: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.7

Entity relationship (ER) models can be readily transformed into a variety of technical architectures

All information about the system’s data identified during conceptual data modelling must be entered into the data dictionary or repository

This assists in checking the consistency of data and process models

Entity relationship modelling

Page 8: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.8

data “objects” are things about which we wish to store information

ER models show the major data objects and the associations between them

ER models are useful in the initiation, analysis and design phases

Entity relationship modelling

Page 9: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.9

Entity

something of interest about which we store information

eg. EMPLOYEESALES ORDERSUPPLIER

often identified from nouns used within the business application

should be LOGICAL (not physical)

Page 10: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.10

Identifying entities

entities are subjective (i.e. they reflect the viewpoint of the system) and can be:

Real eg VEHICLE

Abstract eg QUOTA

Event remembered eg LOAN

Role played eg CUSTOMER

Organisation eg DEPARTMENT

Geographical eg LOCATION

Page 11: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.11

Representing entities

we represent an entity by a named rectangle

use a singular noun, or adjective + noun

refer to one instance in naming

PART-TIMEEMPLOYEE

CUSTOMER

Page 12: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.12

Entity types and instances

an entity type is a classification of entity instances

eg. BN Holdings ABC Engineering Acme Corp. Ltd.

SUPPLIER

Page 13: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.13

Entity types are logical

E.g. in a sales and inventory system there might be 3 physical forms of data: a stock file product brochures sent customers enquiring

about products a product range book used by salespeople

when calling on customers to take orders

which could be represented by one logical entity

PRODUCT

Page 14: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.14

Entity types are logical

E.g. in a Student Records System there might be an entity type STUDENT which represents some of the data used in several physical forms of data: Student re-enrolment forms Subject class lists Student results file

The ER model identifies the minimum set of data objects necessary to construct the data used within the system in its various physical forms.

Page 15: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.15

Relationship

is an association between two entities

we may wish to store information about the association

often recognised by a verb or "entity + verb + entity"

eg CUSTOMER places ORDER

relationships capture the "business rules" of the system

Page 16: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.16

Representing relationships we represent a relationship as a line between two

entities

the relationship is named by a meaningful verb phrase which should indicate the meaning of the association

relationships are bi directional so naming each end of the relationship conveys more meaning

SUPPLIER ITEMsupplies

Supplied by

Page 17: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.17

Relationship types and instances

a relationship type is a classification of relationship instances

MIS FinanceMarketing

John SmithBill BrownSue Blackemploys

employsemploys

DEPT EMPLOYEEemploys

Page 18: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.18

Cardinalities in relationships

The cardinality of a relationship is the number of instances of one entity type that may be associated with each instance of the other entity type.

Page 19: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.19

Examples of cardinalities

EMPLOYEE CUSTOMER SUPPLIER

PROJECTSALES

ORDERITEM

leads places supplies

One to One One to Many Many to Many

led by placed by

supplied by

Page 20: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.20

Nature of relationships

We can indicate whether relationships are optional or mandatory:

A customer MAY place many sales orders

Each sales order MUST be placed by one customer

CUSTOMER SALESORDER

places

placed by

Page 21: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.21

Notations

EMPLOYEE

COURSE

attends

EMPLOYEE

COURSE

attends

Is attended by

Notation used in Hoffer et al (1999) Notation we are using

Page 22: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.22

Relationship degree

The degree of a relationship is the number of entity types that participate in the relationship.

The most common relationships in ER modelling in practice are:

unary (degree one) binary (degree two) ternary (degree three)

Page 23: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.23

Unary relationships

A unary relationship is a relationship between instances of one entity type (also called a recursive relationship)

EMPLOYEEITEM

Has component manages

Reports to

Is a componentof

Page 24: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.24

Binary relationships

A binary relationship is a relationship between instances of two entity types and is the most common type of relationship encountered in practice.

MOVIE VIDEO TAPE

has copy

Is a copy of

Page 25: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.25

Ternary relationships

A ternary relationship is a simultaneous relationship between instances of three entity types.

A ternary relationship is NOT the same as three binary relationships between the same three entity types.

Page 26: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.26

Examples

PROGRAMMER

PROJECT

LANGUAGE

PROGRAMMER

PROJECT

LANGUAGE

Triplets e.g.

Mary uses COBOL on HR Project

3 independent sets of pairs e.g.

Mary uses COBOL Mary works on HR ProjectCOBOL is used in the HR Project

Page 27: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.27

Example ER model

CUSTOMER

ITEM

SALESORDER

EMPLOYEE

employs

made by

places

is on

employed

makes

placed by

is for

DEPARTMENT

Page 28: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.28

Associative Entities (Gerunds)

An associative entity (or gerund) is a relationship that a data modeller decides to model as an entity type

As both entities and relationships can have attributes, this is possible

PRODUCT

CUSTOMER

Is ordered by

orders

PRODUCT

CUSTOMER

SALES ORDER

makes

Is made by

has

Is on

Page 29: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.29

Multiple relationships

It is common to have two or more relationships between the same entities.

They represent different business rules.

EMPLOYEE PROJECT

Is working on

Is eligible for

Has working

Has eligible

Page 30: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.30

Modelling Time-dependent Data

Some data values vary over time and it may be important to store a history of data values to understand trends and for forecasting.E.g. for accounting purposes we are likely to need a history of costs of material and labour costs and the time period over which each cost was in effect.

Modelling time-dependent data can result in changes to entities, attributes and relationships.

Page 31: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.31

One technique is to store a series of time stamped data values. These values can either be represented as repeating data or as an additional entity called PRICE HISTORY.

Modelling Time-dependent Data

PRODUCTPRICE

HISTORY

has

belongsto

PRODUCT

PriceEffective date

Page 32: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.32

Modelling Time-dependent Data

Relationship cardinality can change.

DEPT EMPLOYEE

Works for

DEPT EMPLOYEE

Has worked for

Has working

Had working

Page 33: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.33

Entity subtypes and supertypes

some entities can be generalised (or specialised) to form other entities

an entity subtype is made up from some of the instances of the entity

E.g. the entity types motor car truck train

Can be grouped together to form the entity supertype

transport vehicle

Page 34: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.34

Entity subtypes and supertypes

Example entity subtype:

the entity type EMPLOYEE includes the subtype SALESPERSON

SALESPERSON

EMPLOYEE

Page 35: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.35

Entity subtypes

entity subtypes are included in the ER model only when they are of use - they may participate in relationships and have additional attributes

SALESPERSON

EMPLOYEE

DEPARTMENT

CUSTOMER

employs

services

employed

served by

Page 36: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.36

Multiple entity subtypes

Entity types may have multiple subtypes Entity subtypes may be nested

EMPLOYEE

PART-TIME

FULL-TIME

PROPERTY

RESIDENTIAL

METROPOLITAN

COUNTRY

COMMERCIAL

Page 37: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.37

Entity subtypesMultiple entity subtypes should be Non-overlapping (disjoint) Collectively exhaustive

This enables easier translation to a relational design

EMPLOYEE

PART-TIME

SALARIED

RESIDENTIAL

METROPOLITAN

COMMERCIAL

PROPERTY

? ?

Page 38: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.38

Building a basic ER model

1. identify and list the major entities in the system

2. represent the entities by named rectangles

3. identify, draw, name, and quantify relationships

4. indicate mandatory/optional nature of

relationships

5. revise for entity subtypes where appropriate

Page 39: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.39

Eliciting information for an ER model

fact-finding and information gathering techniques are used to determine the entities and relationships

identify both existing and new information existing documents are particularly useful e.g. forms, paper-based and computer files, reports,

listings, data manuals, data dictionary

existing and new business rules for information are often difficult to elicit from documents ... it is essential to speak directly to the client

Page 40: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.40

ER modelling difficulties

is a given object an entity or relationship ?

are two similar objects one entity or two ?

is a given object an entity or an attribute of (data item about) an entity?e.g. EMPLOYEE and EMPLOYEE SPOUSEdo we need to store data about the object?

what is the 'best' data model ?

Page 41: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.41

Quality dimensions

Correctness Completeness Understandability Simplicity flexibility

Page 42: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.42

ER models and DFDs

Do not to confuse entities with sources/sinks and relationships with data flows

TREASURER is the person entering data; there is only one person and hence it is not an entity typeACCOUNT has many account balance instancesEXPENSE has many expense transactionsEXPENSE REPORT contents are already in ACCOUNT and EXPENSE; it is not an entity type

EXPENSEREPORT

ACCOUNTTREASURER EXPENSE

Page 43: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.43

Integration of ER Models with DFDs

All data elements represented in data flow diagrams for a system (data flows and data stores) MUST correspond to entities and their attributes in the ER model

ORDER CUSTOMERplaced by

ORDERLINE

PRODUCTfor

made up of

2

checksalesorder

Sales orders

3produceweekly

sales totals

Page 44: 5.1 Topic 5 DATA MODELLING: ENTITY RELATIONSHIP MODELLING IMS9001 - Systems Analysis and Design

5.44

References

HOFFER, J.A., GEORGE, J.F. and VALACICH (2005) Modern Systems Analysis and Design, (4th edition), Pearson Education Inc., Upper Saddle River, New Jersey, USA. Chapter 9

WHITTEN, J.L., BENTLEY, L.D. and DITTMAN, K.C. (2001) 5th ed., Systems Analysis and Design Methods, Irwin/McGraw-HilI, New York, NY. Chapter 7

BARKER, R. (1989) CASE*METHOD Entity Relationship Modelling, Addison-Wesley, Wokingham

Chapters 4,5