Top Banner
Data Modelling I
57

Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Data Modelling I

Page 2: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Plan

• Introduction

• Structured Methods– Data Flow Modelling– Data Modelling– Relational Data Analysis

• Feasibility

• Maintenance

Page 3: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Plan

• Introduction

• Structured Methods– Data Flow Modelling– Data Modelling– Relational Data Analysis

• Feasibility

• Maintenance

Page 4: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Data Model Requirements

• Designers, end-users and programmers tend to view data in different ways

• We need a communications tool that will enable models to be understood by all– Non-technical– Un-ambiguous

(Connolly & Begg, 2000)

Page 5: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Entity Relationship Diagrams

• Entity Relationship Diagrams are used to represent the data model graphically

• They show entities in the system and the relationships between them

• They may also show more advanced concepts

• Also called the Logical Data Structure• There are (again) different notations

Page 6: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

What will we know?

• How to identify Entities and Attributes

• Why we need a Key Attribute

• How to describe the Relationships between Entities

• How to draw an Entity Relationship Diagram

Page 7: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Business Data

• We already know a lot about a business’ data from our Data Flow Diagrams

• We find this from our clearly documented descriptions of:– Data Flows (the arrows in DFDs)– Data Stores (again from our DFDs)

Page 8: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Data Dictionary Entry

(Mason and Wilcocks, 1994)

Page 9: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Structured Analysis + Design

Existing System ERD

Repository

Existing Physical

System DFD

New System ERD

Repository

New Logical System DFD

Convert to Logical View

User Requirements

Technical Options +

Constraints

New Physical System

Page 10: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Structured Analysis + Design

Existing System ERD

Repository

Existing Physical

System DFD

New System ERD

Repository

New Logical System DFD

Convert to Logical View

User Requirements

Technical Options +

Constraints

New Physical System

Page 11: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Data Modelling

• There are various things that an organisation needs to store information about

• In data modelling these things are called Entities

(These are NOT the same as external entities in DFDS)

Page 12: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Entity

• A thing that occurs more than once in the system about which we need to store information

• …occurs more than once…• …about which we need to store information…

(These are NOT the same as external entities in DFDS)

Page 13: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

• If an Entity = – Student

• Occurrence = – Wesley Snoopes– Carmen Dizi– Bard Pith

Instance

• If an Entity =– Course

• Occurrence = – BSc Info Systems– BA Basket Weaving– PhD Surfing Studies

• Each occurrence of an entity is called an instance or Entity Occurrence

Page 14: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Attribute

• We need to store information about each entity

• Example: What information does a University need to store about a student?– Name– Address– Phone Number– Course

Page 15: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Example

• Entity - Student– Name– Address– Phone Number– Course

• Occurrence– Wesley Snoops– 13 Manchester Blvd– 0161 111 112– BA Basket Weaving

Page 16: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

So…

• Entity– A thing that occurs more than once in the

system about which we need to store information

• Attribute– Information we need to store about each

entity

Page 17: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Identifying Entities

• One way of identifying possible entities is to find all the nouns in a description of a system

• But…– Some of these might be attributes– Some of these might be neither entities or

attributes

Page 18: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise

• Of the following, which are Entities?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

• Of the following, which are Entities?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

Page 19: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise

• Of the following, which are Entities?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

Page 20: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise

• Some of the following are Attributes?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

Page 21: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise

• Some of the following are Neither?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

Page 22: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Entities and Attributes

• Often an entity in one system will be an attribute in another system and might be neither in another system

• This depends on the context of the system we are studying

• We need to be clear about the system and its data and processing requirements

Page 23: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise

• Of the following, which are Entities?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

• Of the following, which are Entities?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

Page 24: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise

• Of the following, which are Entities?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

• Of the following, which are Entities?– A member of staff in a personnel system– A book in a library system– A customer in a sales system– A customer’s address in a sales system– A store in the UHS system– The shop in a greengrocer’s shop system– The author of a book in a library system

Page 25: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Big Jim’s Bikes

• Big Jim sells Bikes on the Internet. Customers email Big Jim with their details and those of the bike that they want to buy

• Bike details are taken from the bike list posted on Big Jim’s Website, where every bike is listed with a unique stock number

• On receipt of an email Big Jim checks the bike details and then requests payment in full

• On receipt of payment Big Jim wraps the bike in brown paper and posts it to the customer using Royal Mail

• Big Jim stores customer details in case they buy another bike. No details of payments are stored.

Page 26: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Identify Noun Phrases

• Big Jim sells Bikes on the Internet. Customers email Big Jim with their details and those of the bike that they want to buy

• Bike details are taken from the bike list posted on Big Jim’s Website, where every bike is listed with a unique stock number

• On receipt of an email Big Jim checks the bike details and then requests payment in full

• On receipt of payment Big Jim wraps the bike in brown paper and posts it to the customer using Royal Mail

• Big Jim stores customer details in case they buy another bike. No details of payments are stored.

Page 27: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Identify Noun Phrases

• Big Jim sells Bikes on the Internet. Customers email Big Jim with their details and those of the bike that they want to buy

• Bike details are taken from the bike list posted on Big Jim’s Website, where every bike is listed with a unique stock number

• On receipt of an email Big Jim checks the bike details and then requests payment in full

• On receipt of payment Big Jim wraps the bike in brown paper and posts it to the customer using Royal Mail

• Big Jim stores customer details in case they buy another bike. No details of payments are stored.

Page 28: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Identify Entities

• Big Jim sells Bikes on the Internet. Customers email Big Jim with their details and those of the bike that they want to buy

• Bike details are taken from the bike list posted on Big Jim’s Website, where every bike is listed with a unique stock number

• On receipt of an email Big Jim checks the bike details and then requests payment in full

• On receipt of payment Big Jim wraps the bike in brown paper and posts it to the customer using Royal Mail

• Big Jim stores customer details in case they buy another bike. No details of payments are stored.

Page 29: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Key Attributes

• How do we identify an individual occurrence?– E.g. we might be searching for a student’s

address

• By adding a Key Attribute– E.g. we add a student number to uniquely

identify each student

Page 30: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Identifying Entities

• List some attributes for each entity in Big Jim’s Bikes

• Identify the Key Attribute for each entity

Page 31: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Entity Relationship Diagrams

• Entity Relationship Diagrams are used to represent the data model graphically

• They show entities in the system and the relationships between them

Page 32: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

ERD Elements

• E.G. In a student enrolment system

Student

Student NumberNameAddressPhone NumberCourse

Entity Name

Key Attribute

Non-Key Attributes

Page 33: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

ERD Elements

• Entities - in Big John’s store system

Customer

Customer NumberNameAddressPhone Number

Product

Product IDDescriptionColourWeight

Page 34: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Relationships

• Entities in a system will be related to one another

• For example– A student is related to a course because a

student is enrolled on a course– A supplier is related to a product because

they may supply that product

Page 35: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

The Matrix

• Sometimes the relationships are marked on a matrix• This is especially useful for large systems

Entity A B C D E F G H

A - X - - X - - -

B - X - - - - -

C - - - X 2 -

D X - - - X

E - - - -

F - - -

G - X

H

Page 36: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Degree/Multiplicity

• Relationships are always two way• Example System Description – Mulchester

University– Each student may only enrol on one course– Each course typically has 150 students although this

could be higher or lower

• These describe the same SINGLE relationship

Page 37: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Degree/Multiplicity

• Example System Description – Dulchester College– A student may enrol on any number of

courses– Each course typically has 30 students

although this could be higher or lower

– Here the relationship between course and student is different

Page 38: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Degree/Multiplicity

• Mulchester University– Each student may only enrol on one course– Each course has many students enrolled on it

• Dulchester College– Each student may enrol on many courses– Each course has many students enrolled on it

• They have a different degree/multiplicity

Page 39: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Degree/Multiplicity

• Three alternatives– One-to-Many (1:M)

– Many-to-Many (M:N)

– One-to-One (1:1)

Page 40: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

One-to-Many

• Mulchester University

Student

Student Number

Course

Course Code

Enrolled on

Enrols

Parent/Master

Child/Detail

Page 41: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Many-to-Many

• Dulchester College

– Note the different configuration

Student

Student Number

Course

Course CodeEnrolled on

Enrols

Page 42: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

One-to-One

• Each course has one course leader and each course leader leads only one course

Course Leader

Staff Number

Course

Course CodeResponsible for

Responsibility of

Page 43: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Problem (1)

• Mulchester University creates a new Course (Origami) during the summer vacation

• The course details need to be put it on the system before any students can enrol– This means a course may exist with no

students– We must be able to show this situation on our

ERD

Page 44: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Solution (1)

• Optionality– Each course MAY be enrols

students(A course enrols 0, 1 or many students)

– Each student MUST be enrolled on a course

Student

Student Number

Course

Course Code

Enrolled on

Enrols

Dotted line indicates optional

relationship

Page 45: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Problem (2)

• CD Hotels may have Customers who have not yet booked a room

• They may have Rooms that have not yet been booked by anyone

Customer

Customer NumberNameAddressPhone Number

Room

Room NumberBooks

Booked by

Page 46: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Solution (2)

• Each Customer MAY book rooms

• Each Room MAY be booked by Customers

Customer

Customer NumberNameAddressPhone Number

Room

Room NumberBook

Booked by

Page 47: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Examples

• 1 to many (1 or more)

• 1 to 1 (or 0)

• 1 to many (0, 1 or more)

• Many (1 or more) to Many (1 or more)

• Many (0, 1 or more) to 1 (or 0)

Page 48: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise 1

• Big Jim sells Bikes on the Internet. Customers email Big Jim with their details and those of the bike that they want to buy

• Bike details are taken from the bike list posted on Big Jim’s Website, where every bike is listed with a unique stock number

• On receipt of an email Big Jim checks the bike details and then requests payment in full

• On receipt of payment Big Jim wraps the bike in brown paper and posts it to the customer using Royal Mail

• Big Jim stores customer details in case they buy another bike. No details of payments are stored.

Page 49: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Identify Entities

• Big Jim sells Bikes on the Internet. Customers email Big Jim with their details and those of the bike that they want to buy

• Bike details are taken from the bike list posted on Big Jim’s Website, where every bike is listed with a unique stock number

• On receipt of an email Big Jim checks the bike details and then requests payment in full

• On receipt of payment Big Jim wraps the bike in brown paper and posts it to the customer using Royal Mail

• Big Jim stores customer details in case they buy another bike. No details of payments are stored.

Page 50: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Draw ERD

• Each Customer can buy many bikes

• Each bike is bought by one customer

• Big Jim holds customer details before they buy a bike

• Bike details are held before they are bought

Bike

Stock Number

Customer

Customer Number

Buys

Bought by

Page 51: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Exercise 2

• Big Jim has decided that it is too much work to list every bike. He now lists bikes by model and customers buy one of that model rather than a specific bike. Each bike still has a unique stock number.

• Example models in Big Jim’s system are:– Raleigh Chopper– Penny Farthing– Dahon Espresso– Shogun XC200

• How does this effect the data model?

Page 52: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

Solution

Page 53: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

What do we know?

• How to identify Entities and Attributes

• Why we need a Key Attribute

• How to describe the Relationships between Entities

• How to draw an Entity Relationship Diagram

Page 54: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

What problems still exist?

• There are some problems associated with M:N relationships that need to be resolved

• We need to examine attributes in more detail

• We need to check our model against the required transactions

• There are additional relationships we could describe

Page 55: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

References

• Whiteley, D. (2004) Introduction to Information Systems, Palgrave, 2004.

• Lejk, M. and D. Deeks (2002) Systems Analysis Techniques, Addison Wesley 2002

• Mason, D. and L. Willcocks (1994), Systems Analysis, Systems Design, Alfred Waller, 1994.

Page 56: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

References

• Yeates, D. and T. Wakefield (2004) Systems Analysis and Design, FT/Prentice Hall 2004

• Gane, C. and T. Sarson (1979) Structured Systems Analysis, Prentice Hall, 1979

• Eva, M (1994) SSADM Version 4: A users guide, McGraw hill, 1994

Page 57: Data Modelling I. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.

References

• DeMarco, T. (1979) Structured Analysis and System Specification, Yourdon, 1979

• Royce, W. (1970) Managing the development of large software systems, In: Proceedings of IEEE WESCON, 1970 pp1-9.

• Connolly, T. and C. Begg (2000) Database Solutions, Addison-Wesley, 2000