+ All Categories
Home > Documents > 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability,...

1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability,...

Date post: 17-Jan-2016
Category:
Upload: stewart-hensley
View: 212 times
Download: 0 times
Share this document with a friend
48
1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and generic modeling
Transcript
Page 1: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

1

Database Design

Sections 10 & 11Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and generic modeling

Page 2: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

2

Modeling Over Time

Any relationship that changes through time needs special consideration.

An attribute such as status may change over time.

Examples of time sensitive attributes are: rental status, fee payment, country name, or price

Page 3: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

3

Change and Time

1. Every update means loss of information.

2. Time in your model makes the model more complex.

3. There are often complex join conditions.

4. Users can work in advance.

Page 4: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

4

Why Modeling Time - examples

Track trends in products city police department tracks crimes

in each neighborhood frequency of crimes during certain times

of the year holidays or during really hot or cold

weather

Page 5: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

5

Entity DAY or Attribute Date Single attribute

entity without M:1 relationships is usually replaced by attribute

PURCHASE* date

PURCHASE

DAY #date

on

for

Page 6: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

6

What is wrong with revision?

Page 7: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

7

Entity Day vs. Attribute Date

Page 8: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

8

Examples

When there is an interest in a particular day not a date. Is it a holiday? Is it a work day or weekend? Is it leap year? Month end?

Page 9: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

9

Entity DAY

TASK ASSIGNMENT*duration in hours

TASK#id

DAY #date

* public holiday indicator

EMPLOYEE#name

first day of

starts on

for

of

in

with

Page 10: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

10

Modeling Change

ASSIGNMENT#start dateo end date

EMPLOYEE#id

COUNTRY#name

of

for

in

as

Page 11: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

11

Modeling Change

ASSIGNMENT#start dateo end date

EMPLOYEE#id

COUNTRY#name

#start time*end time

of

for

in

as

life cycle attributes

Even a Country has a life cycle

Page 12: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

12

Mapping Historical Price

PRICE = PRICED PRODUCT = HISTORICAL PRICE

PRODUCT#id

*name

PRICE#start date

*price $o end date

have

for

Page 13: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

13

Revised previous ERD

Page 14: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

14

Example Movie Star Jewelry rental

JEWELRY PIECE

#code*description*rental rate

*insured value

MOVIE STAR#id

* first name* last name

rented by

renting

Page 15: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

15

Possible Solution

Page 16: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

16

8.1.8

Page 17: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

17

Review

Page 18: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

18

Modeling time constraint example 1

Be aware of constraints that can result from the time dimension. Here is an example:

Consider a school fair that features several booths. The manager signs up volunteers to work different shifts at different booths. Some volunteers can work for several hours; others can work fewer hours depending on their free time. The schedule has to be determined in advance, so that the manager knows which times are not covered by any volunteers.

Page 19: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

19

Review example 1-

What are some other rules?

Page 20: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

20

Example 2

Page 21: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

21

Modeling change: Price

When do we need to track price? Determine best price for item Sale price vs. original price Grade change Value of home Asking price vs. sale price Stock, bond, or investment Others

Page 22: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

22

Review slide 4

Page 23: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

23

Page 24: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

24

Price with time

Price may fluctuate with time “The Good Old Days” Examples:

Value of Gold or Silver Real Estate Value of currency Gasoline

Page 25: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

25

Price with Time

PRODUCT

#id

*name

PRICE

#start date

*price is $

o end date

with

of

Price =Priced Produce = Historical Price

Page 26: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

26

Slide 11

Page 27: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

27

Journaling

Page 28: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

28

Page 29: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

29

Example

When a student’s grade is changed, we need to record information on the teacher who changed the grade and the reason for the change.

Start with the ENROLLMENT entity, which is the resolution of the M:M between STUDENT and CLASS.

Page 30: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

30

Solution 10.2.13

STUDENT

CLASS

ENROLLMENT#date*grade

GRADE CHANGE*old grade

*changed by#date changed

o reason for change

Student / ClassM:M

Enrollment is the intersection entity

Page 31: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

31Marge Hohly 31

Conventions Review Crows feet

Crows fly East and South Divide complex ERD’s into functional areas Place Highest volume entities in upper left

corner Improve readability

avoid criss-crossing lines increase white spaces so relationships don’t

overlap be consistent with font type, size, and styles

Page 32: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

32Marge Hohly 32

Conventions Review Crows feet

Crows fly East and South Divide complex ERD’s into functional areas Place Highest volume entities in upper left

corner Improve readability

avoid criss-crossing lines increase white spaces so relationships don’t

overlap be consistent with font type, size, and styles

Page 33: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

33

Page 34: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

34

Page 35: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

35

Page 36: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

36

Page 37: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

37

Page 38: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

38

Page 39: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

39

Page 40: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

40Marge Hohly 40

Generic Modeling Can reduce number of entities in diagram Can provide more flexibility in unstable

situations (where business requirements change often)

Use a more distant perspective Review Slide 3 & 4 See next slide. What would happen to the

generic model if we had to add 10 new ARTICLE types, each with their own attributes?

Page 41: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

41

Page 42: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

42Marge Hohly 42

Generic Modeling Have more attributes in fewer entities Many mandatory requirements/attributes

become optional Structural rules become procedural rules Example: PANTS waist size was mandatory,

with ARTICLE waist size becomes optional What other businesses would be good

candidates for generic modeling?

Page 43: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

43

Page 44: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

44

Page 45: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

45

Page 46: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

46

Page 47: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

47

Page 48: 1 Database Design Sections 10 & 11 Modeling Historical Data, conditional nontranferability, time-related constraints, conventions, and g eneric modeling.

48Marge Hohly 48

Relational Database Concepts

Conceptual model transforms into a relational database

A relational database is a database that is perceived by the user as a collection of relations or two-dimensional tables.

Table, each employee (instances), and each column (attribute)


Recommended