data modeling section 3 data modeling constructs

32
DATA MODELING SECTION 3 Data Modeling constructs.

Post on 22-Dec-2015

236 views

Category:

Documents


12 download

TRANSCRIPT

Page 1: DATA MODELING SECTION 3 Data Modeling constructs

DATA MODELING

SECTION 3

Data Modeling constructs.

Page 2: DATA MODELING SECTION 3 Data Modeling constructs

Structured Methodologies

• The techniques are instructions that are carefully drawn up, often step-by-step, with each step building on the previous step.

• Progresses from the highest level of abstraction to the lowest level of detail

• General to the specific

Page 3: DATA MODELING SECTION 3 Data Modeling constructs

Methodologies• Include:

• structured analysis, structured design, and structured programming

Structured Analysis

• Widely used top-down approach

• Primary tool is?

Page 4: DATA MODELING SECTION 3 Data Modeling constructs

Data Flow Diagrams

• Graphically illustrates a system’s component processes and the flow of data between them

• Four basic symbols1

2

3

4

Page 5: DATA MODELING SECTION 3 Data Modeling constructs

Data Flow

Process

Data store

Source/Sink

Page 6: DATA MODELING SECTION 3 Data Modeling constructs

Context Diagram Example

• An overview DFD of the entire system as a single process. Shows major inputs and outputs

Pension benefitsrecordkeeping

system

PayrollDept

Employee

ActuaryActuary factors

Earnings

Hours-worked

Employee Changes

Beneficiary designation

Benefits statements

Page 7: DATA MODELING SECTION 3 Data Modeling constructs

Zero-Level DFD

2.0Track

creditedservice

3.0CaptureEarnings

1.0Track

participation

4.0Maintainactuarytables

5.0Calculate

benefit

PayrollDept.

Employee

ActuaryBenefits master file

Actuarial tableActuarial formula

Actuary factors

Actuary formula

Pensionable-earnings history

Retirement dates

Eligibility

Survivor option

Pension benefit

Pensionable earningsCredited service

Hours worked

Earnings

Beneficiary designation

Employee changes

Benefits statement

System Boundary

Page 8: DATA MODELING SECTION 3 Data Modeling constructs

First-Level DFD

5.3Calculate early

retirementbenefit

5.4Calculatesurvivorbenefit

5.2Calculatenormal

retirementbenefit

5.5Generatebenefits

statement

5.1Calculate

final averageearnings

Actuarial file

Benefits master file

Survivor

Benefit

Retirement

benefits

Employee details

Pensionable earnings history

Actuarial formulaActuarial formula

Normal retirement benefit

Benefits statement

Earlyretirementoption date

Normalretirementoption date

Final average earnings Retirement benefits

Page 9: DATA MODELING SECTION 3 Data Modeling constructs

Structured Design• Encompasses a set of design rules and techniques for designing a system from the top down in a hierarchy

Structure Chart• consider the main function, then break it down into sub-functions

Page 10: DATA MODELING SECTION 3 Data Modeling constructs

Processpayroll

Get validinputs

Writeoutputs

Calculatepay

Validateinputs

Getinputs

Calculatenet pay

Calculategross pay

Write checks,reports, andoutput files

Updatemaster file

High-Level Structure Chart

Page 11: DATA MODELING SECTION 3 Data Modeling constructs

Structured Programming

• Extends the principles governing structured design to the writing of programs.

• Incorporate the concepts of modularity

Page 12: DATA MODELING SECTION 3 Data Modeling constructs

• Sequence construct– executes statements in the order in which they appear

• Selection construct– tests a condition and executes one of two or more alternatives

• Iteration construct– repeats an instruction as lon as the results of a conditional test remain true

Page 13: DATA MODELING SECTION 3 Data Modeling constructs

Basic Control Structures

A

BSequence

Action A then Action B

S

DC

Selection

If Condition = S Then do Action C

Else do Action D

Endif

E

R

Iteration

Do While Condition = R

Action E

Enddo

Page 14: DATA MODELING SECTION 3 Data Modeling constructs

The Entity-Relationship Model

• Introduced by Peter Chen in 1976

• Part of a number of Case tools

• Key elements– entities, attributes, identifiers, and relationships

Page 15: DATA MODELING SECTION 3 Data Modeling constructs

Entities• Something that can be identified in the users’ work environment

• Entity classes

Page 16: DATA MODELING SECTION 3 Data Modeling constructs

Attributes

• Describe the entity’s characteristics

CUSTOMER

CustNumber

CustName

Address

City

Province

PostalCode

ContactName

PhoneNumber

12345

Ajax Manufacturing

123 Elm St

Toronto

Ont

J1K6F9

P. Shwartz

223-5567

67890

Jefferson Dance Club

345 Main St East

Hamilton

Ont

L8P1R5

Frita Bellingsley

545-1267

Two instances of CUSTOMER

Primary Key?

Page 17: DATA MODELING SECTION 3 Data Modeling constructs

Identifiers• Attributes that name or identify entity instances

• Unique vs. Non-unique

• Composite identifiers

Page 18: DATA MODELING SECTION 3 Data Modeling constructs

Relationships

• The way entities can be associated with one another

• Degree of relationship

SALESPERSON

ORDER

SP-ORDER

CHILD

MOTHER FATHER

PARENT

Page 19: DATA MODELING SECTION 3 Data Modeling constructs

• Binary relationships– Relationships of degree 2

– Three type of binary relationships• 1:1, 1:N, N:M

EMPLOYEE COMPANY CARhas1 1

DORMITORY STUDENThas1 N

STUDENT CLUBhasM N

Page 20: DATA MODELING SECTION 3 Data Modeling constructs

• Cardinality

RESIDENCE STUDENThas(0,400) (1,1)

1 N

Page 21: DATA MODELING SECTION 3 Data Modeling constructs

STUDENT COURSEtakes1 N

Optional existence

Optional Entity

Page 22: DATA MODELING SECTION 3 Data Modeling constructs

• Recursive relationship

STUDENT roomswith

Page 23: DATA MODELING SECTION 3 Data Modeling constructs

Showing Attributes in an ERD

• Ellipses or flag

CUSTOMER

CustomerNumber CustomerNameCustomerAddress

CUSTOMER

CustomerNumber

CustomerAddress

CustomerName

Page 24: DATA MODELING SECTION 3 Data Modeling constructs

Weak Entities

• Cannot exist in the database unless another type of entity exists

EMPLOYEE has1 M

DEPENDENT

PATIENT has1 M

PRESCRIPTION

Page 25: DATA MODELING SECTION 3 Data Modeling constructs

ID-Dependent Entities (special type of weak entity)

• One in which the identifier of one entity includes the identifier of another entity

BUILDING has1 M

APPARTMENT

Page 26: DATA MODELING SECTION 3 Data Modeling constructs

EXOTIC RV RENTALS

Exotic RV Rentals is an agent that rents recreational vehicles to customers for a fee. Exotic does not own any RVs but instead leases or rents them on behalf of the RV owner who wishes to earn income when they are not using their RV. Exotic charges a fee for its service. Exotic specializes in RVs that can be used for multi-day, weekly, or monthly rentals. The smallest RV in their inventory is 20 feet and the largest is 40 feet.

Each RV is fully equipped at the time it is rented. Most of the equipment is provided by the owners, but some is added by Exotic. The owner-provided equipment includes what is fixed on the RV, such as radio, stoves, tables, beds, generators, and refrigerators. Other owner-provided equipment is not installed as part of the RV. Such equipment includes dishes, silverware, cooking utensils, bedding, and the like. Exotic provides consumable equipment, which could also be considered supplies, such as maps, soap, dish towels, toilet paper, and similar items.

An important part of Exotic’s responsibilities is keeping track of the equipment on the RV. Some of it is expensive, and some of it, particularly what is not attached to the RV, can be easily lost or stolen. Customers are responsible for all equipment during the period of their charter.

Exotic likes to keep accurate records of its customers and the rentals, not only for marketing but also for recording the trips that customers have taken. Some trips can have poor weather conditions or interesting places and Exotic like to know which customers have what experience.

Page 27: DATA MODELING SECTION 3 Data Modeling constructs

RVs often need maintenance. Exotic is required by its contracts with the RV owners to keep accurate records of all maintenance activities and costs, including normal activities, such as cleaning or engine-oil changes, and unscheduled repairs. In some cases, repairs are necessary during a rental. An engine, for example, might require maintenance while the RV is far away from Exotic’s facility. In this case, the customers phone the Exotic dispatcher, who determines the best facility to make the repair and phones the repair facility so that they can go to the customers aid. To make these decisions, the dispatchers need information about repair facilities as well as past histories of repair quality and cost.

Page 28: DATA MODELING SECTION 3 Data Modeling constructs

Possible Entities for Exotic

• What should one look for?• RENTAL• LEASE• RV• CUSTOMER• OWNER• EQUIPMENT• OWNER-PROVIDED-EQUIPMENT• FIXED-OWNER-EQUIPMENT• REMOVABLE-OWNER-EQUIPMENT• EXOTIC-PROVIDED-EQUIPMENT• ITINERARY/WEATHER• SCHEDULED-MAINTENANCE• UNSCHEDULED-MAINTENANCE• REPAIRS• REPAIR-FACILITY

Page 29: DATA MODELING SECTION 3 Data Modeling constructs

Selected Entities for Exotic for ERD

• Some entities may not be needed• RENTAL or LEASE (synonyms)• RV• CUSTOMER• OWNER• EQUIPMENT• ITINERARY/WEATHER• SCHEDULED-MAINTENANCE• REPAIRS or UNSCHEDULED-MAINTENANCE (synonyms)• REPAIR-FACILITY

Page 30: DATA MODELING SECTION 3 Data Modeling constructs

The ERD

OWNERSCHEDULED-

MAINTENANCE

N:M

RV

RENTAL

CUSTOMER

REPAIREQUIPMENT

WEATHER-ITINERARY

1:N

1:N

1:1

N:1

1:N

N:M

N:M

Note: Not the only model possibility!

Page 31: DATA MODELING SECTION 3 Data Modeling constructs

Models• There are a variety of different ways of modeling a particular situation

• Evaluating alternatives

• Does model accurately reflect the users needs and ways of doing things?

Page 32: DATA MODELING SECTION 3 Data Modeling constructs

REA Model• An Accounting Model

• Resources, Events & Agents

• Resource?• Event?• Agent?