further data modelling …and the effect of time. plan introduction structured methods –data flow...

37
Further Data Modelling …and the effect of time

Post on 22-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Further Data Modelling

…and the effect of time

Page 2: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Plan

• Introduction

• Structured Methods– Data Flow Modelling– Data Modelling– Relational Data Analysis– Further Systems Analysis Topics

Page 3: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Relationships

• Remember…

• During Normalisation it is important to maintain the relationship between tables

• These relationships are maintained by Compound Keys (1NF) and foreign keys (3NF)

Page 4: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Example 1 – 3NF

• Student ID• Module Code• Grade

• Module Code• Module Name

Foreign Key

• Student ID• Student Name• Course ID

• Course ID • Course

Compound Key

*

Page 5: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Relationships

• Relationships can now be drawn

• They will be 1:M relationships

• In general the many end “grabs” the foreign key

• Compound Keys are also treated as foreign keys

Page 6: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Example 1 – 3NF

• Student ID• Module Code• Grade

• Module Code• Module Name

• Student ID• Student Name• Course ID

• Course ID • Course

*

Page 7: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Student

Course

Student/Module

Module

Page 8: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Bottom Up Data Model

• A normalised set of data can now be represented as an ERD

• This will improve the communication aspect of Normalisation

• It also helps to check the sanity of your normalisation

Page 9: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Example 2 - 3NF

• Student ID• Name• Faculty

• Student ID • Book ID• Return Date

• Book ID• Title• Author

Compound Key

Page 10: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Student

Loan

Book

Page 11: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Example 3 - 3NF

• Customer ID• Customer Name• Address• Branch No*

• Branch No • Branch Manager

• Customer ID• Stock ID

• Stock ID • Title• Format

Foreign Key

Compound Key

Page 12: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Customer

Branch

Customer/Item

Item

Page 13: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Data Modelling

• Entity Relationship Diagrams– Top down view of data modelling– Gives a good overview of system– Good communication tool– May lack accuracy

• Normalisation– Bottom up view of data modelling– Difficult with large systems– Poor communication tool– Very accurate

Page 14: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Data Modelling

• A hybrid approach gives the benefits of– good communication – more formal approach

• This is done as follows:– Develop an ERD of the system– Check each entity is in 3NF

Page 15: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Data Modelling

• Another approach to data modelling– Divides the system into user views– Develop an ERD for each

• Each view is then combined into one whole system ERD

• TopDog is a Good Example

• Similar to a Use Case based approach

• See also (Conolly and Begg, 2000)

Page 16: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Further Data Modelling

…and the effect of time

Page 17: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Entity Life Histories

• Remember that an entity occurrence is a instance of an entity– E.g. Each student is an occurrence of the

entity student

• Every Occurrence shares the same attributes

• Every Occurrence is also effected by the same set of events

Page 18: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Events

• External Events– In Big John’s Store, receipt of a customer order

caused the creation of an order, and maybe also a customer

• Internal Events– In the Ticket Agency, the creation of a list of pre-

purchase events causes an order to be placed.

• Time Based– In CD Hotels a statement is produced every week.

Page 19: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Events

• Events will affect entity occurrences in a number of ways

• Create– A new student record is created when a student

registers on a course.• Delete

– A student record is deleted when a student leaves a course.

• Update– A student successfully completes year 1 and so their

year attributes is updated to Year 2.

Page 20: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Events

All entity occurrences will be created

…all will have some events update them during their lifetime

…and all will be deleted at some point

The description of these events and the order in which they occur is called an Entity Life History

Page 21: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Order of Events

• The Order in which events can occur is Governed by three primary structures:– Sequence– Selection– Iteration

Page 22: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Entity Life History

Entity

Creation Life Deletion

This diagram represents a sequence of events. This sequence is always read from left to right and is always carried out in the exact order shown.

Page 23: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Entity Life History

Student

Registration Update Records Student Leaves

Student records are created when a student registers, various changes occur during the life of a student entity. Student records are deleted when a student leaves.

Example: Student Record at Mulchester University

This diagram represents a sequence of events. This sequence is always read from left to right and is always carried out in the exact order shown.

Page 24: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Sequence

Student

Registration Updates 3 Years after departure

Student Leaves

Mulchester realise that they might need to keep student record after a student has left – so they modify their system so that records are kept for 3 years after a student leaves.

Page 25: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Sequence

Student

Registration Updates 3 Years after departure

Student LeavesCourse Completed

A student leaves after a course is complete.

Page 26: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Check the Model!

• This is only correct if a student always leaves after course completed

• Sometime a student may leave before the course is finished

• This means there are two conditions under which a student leaves– Either they complete the course and then

leave OR they leave pre-maturely

• This is an example of a Selection

Page 27: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Selection

Option 2 Option n OOOption 1 O ………

Option boxes have an “O” in the top right hand cornerThe order is no longer important as we are only using one of the options

We show selection in ELHs as follows:

Page 28: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Selection

Student

Registration Updates 3 Years after departure

Student Leaves (Premature)

O Student Leaves (C. Complete)

O

Note that we do not put the options on the same level as the original sequence. They are placed on the level below with an empty box marking their place in the sequence.

In general we do not mix logical structures at the same level on an ELH diagram

Page 29: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Updates

• During the life of the entity, many updates to a student’s personal details occur (student’s move house etc.)

• These updates can occur one or more times and there is no logical order to them

• This is an example of an Iteration Structure and its general form is as follows:

Page 30: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Iteration

Iterated Event*

Iteration boxes have a “*” in the top right hand cornerThe event can happen zero, one or many times

Page 31: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Iteration

Student

Registration 3 Years after departure

Student Leaves (Premature)

O Student Leaves (C. Complete)

OAmend Personal Details

*

Note that, again the iteration is not shown on the same level as the original sequence, but a placeholder is used to show its position in that sequence.

Page 32: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Adding More Detail

• The university realises that it also needs to amend a student’s module details throughout their time on the course

• This will again be iterative as it can occur any number of times

• These updates occur anytime between student registration and a student leaving

Page 33: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

A Solution?Student

Registration 3 Years after departure

Amend Personal Details

* Amend Module Details

* Student Leaves (Premature)

O Student Leaves (C. Complete)

O

It says that Module details will only be amended after all amendments to personal detail have been done.

This is wrong!

Page 34: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

A Solution!

Student

Registration 3 Years after departure

* Student Leaves (Premature)

O Student Leaves (C. Complete)

O

Amend Personal Details

O Amend Module Details

O

When an update occurs it could be to the personal details or it could be to the module details – it doesn’t matter which, and now the order in which these occur doesn’t matter.

This is correct!

Page 35: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

A Useful Structure

Student

Registration 3 Years after departure

* Student Leaves (Premature)

O Student Leaves (C. Complete)

O

Amend Personal Details

O Amend Module Details

O

This is a common structure for the life of an entity as it allows updates in any order

Page 36: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

Further ELH

• There are other structures that can be applied– Quit/Resume (bit like GOTO)– Parallel Structures– State Indicators

• State Diagrams are another way of showing the same thing

Page 37: Further Data Modelling …and the effect of time. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis –Further

References

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

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