data modeling section 3 data modeling constructs
Post on 22-Dec-2015
236 views
TRANSCRIPT
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
Methodologies• Include:
• structured analysis, structured design, and structured programming
Structured Analysis
• Widely used top-down approach
• Primary tool is?
Data Flow Diagrams
• Graphically illustrates a system’s component processes and the flow of data between them
• Four basic symbols1
2
3
4
Data Flow
Process
Data store
Source/Sink
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
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
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
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
Processpayroll
Get validinputs
Writeoutputs
Calculatepay
Validateinputs
Getinputs
Calculatenet pay
Calculategross pay
Write checks,reports, andoutput files
Updatemaster file
High-Level Structure Chart
Structured Programming
• Extends the principles governing structured design to the writing of programs.
• Incorporate the concepts of modularity
• 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
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
The Entity-Relationship Model
• Introduced by Peter Chen in 1976
• Part of a number of Case tools
• Key elements– entities, attributes, identifiers, and relationships
Entities• Something that can be identified in the users’ work environment
• Entity classes
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?
Identifiers• Attributes that name or identify entity instances
• Unique vs. Non-unique
• Composite identifiers
Relationships
• The way entities can be associated with one another
• Degree of relationship
SALESPERSON
ORDER
SP-ORDER
CHILD
MOTHER FATHER
PARENT
• 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
• Cardinality
RESIDENCE STUDENThas(0,400) (1,1)
1 N
STUDENT COURSEtakes1 N
Optional existence
Optional Entity
• Recursive relationship
STUDENT roomswith
Showing Attributes in an ERD
• Ellipses or flag
CUSTOMER
CustomerNumber CustomerNameCustomerAddress
CUSTOMER
CustomerNumber
CustomerAddress
CustomerName
Weak Entities
• Cannot exist in the database unless another type of entity exists
EMPLOYEE has1 M
DEPENDENT
PATIENT has1 M
PRESCRIPTION
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
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.
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.
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
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
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!
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?
REA Model• An Accounting Model
• Resources, Events & Agents
• Resource?• Event?• Agent?