data modelling i. plan introduction structured methods –data flow modelling –data modelling...

57
Data Modelling I

Post on 19-Dec-2015

236 views

Category:

Documents


3 download

TRANSCRIPT

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

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)

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

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

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)

Data Dictionary Entry

(Mason and Wilcocks, 1994)

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

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

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)

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)

• 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

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

Example

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

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

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

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

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

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

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

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

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

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

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

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.

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.

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.

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.

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

Identifying Entities

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

• Identify the Key Attribute for each entity

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

ERD Elements

• E.G. In a student enrolment system

Student

Student NumberNameAddressPhone NumberCourse

Entity Name

Key Attribute

Non-Key Attributes

ERD Elements

• Entities - in Big John’s store system

Customer

Customer NumberNameAddressPhone Number

Product

Product IDDescriptionColourWeight

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

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

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

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

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

Degree/Multiplicity

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

– Many-to-Many (M:N)

– One-to-One (1:1)

One-to-Many

• Mulchester University

Student

Student Number

Course

Course Code

Enrolled on

Enrols

Parent/Master

Child/Detail

Many-to-Many

• Dulchester College

– Note the different configuration

Student

Student Number

Course

Course CodeEnrolled on

Enrols

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

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

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

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

Solution (2)

• Each Customer MAY book rooms

• Each Room MAY be booked by Customers

Customer

Customer NumberNameAddressPhone Number

Room

Room NumberBook

Booked by

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)

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.

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.

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

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?

Solution

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

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

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.

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

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