Top Banner
Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010
17

Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Dec 13, 2015

Download

Documents

Flora Gardner
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Statistical databases in theory and practice

Part II: Data models

Bo Sundgren

2010

Page 2: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

 Conceptual data model and relational data model in normalised form

PERSON

IdentifierHouseholdIdentifier*SexAgeEducationOccupationIncomeWealthHealth

ESTABLISHMENT

EstablishmentIdentifierOrganisationIdentifier*LocationKindOfActivityNumberOfEmployeesNetProfit

ORGANISATION

OrganisationIdentifierLocationOfHQ

BELONGS TO

HOUSEHOLD

IdentifierDwellingIdentifier*SizeStructureIncome

BELONGS TO

DWELLING

IdentifierLocationSizeStandardRent

LIVES IN

MIGRATIONEVENT

IdentifierPersonIdentifier*FromDwellingId*ToDwellingId*Time

OF

FROM TO

PERSONESTABLISH-

MENT

ORGANISATION

BELONGS TO

HOUSEHOLD

BELONGS TO

DWELLINGLIVES IN

MIGRATIONEVENT

OF

FROM TO

WORKS AT

EMPLOYMENT

EMPLOYMENT

PersonIdentifier*EstablishmentIdentifier*PercentOfFullTimeSalary

Page 3: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Conceptual modelling

• Define concepts and relations between them• Conceptual models and data models• Visualise models graphically

Page 4: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Rent-A-Video: first object graph

VideoFilm CustomerIsRentedBy

Rents

Page 5: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Rent-A-Video: elaborated object graph

VideoFilm CustomerIsRentedBy

Rents

FilmTitle

Rep

rese

nts

IsRep

resented

By

FilmId

Title

Category

Price

Actor*

Story

NumberOfCopies=

NumberOfRents=

FilmId

CopyNr

Rented?

NumberOfRents

CustomerId

Name

Address

Discount

Rental

CustomerId

FilmId

CopyNr

RentalNr

RentalDate

AgreedReturnDate

Returned?

ActualReturnDate

Page 6: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Rent-A-Video: further aspects

VideoFilm CustomerIsRentedBy

Rents

FilmTitle

Rep

rese

nts

IsRep

resented

By

IsRentedBy

Ren

ts

IsReservedBy

Res

erve

s

Page 7: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Relations between two object types

• one-to-one, symbolised by “arrow-to-arrow”

• one-to-many, symbolised by “arrow-to-fork”

• many-to-one, symbolised by “fork-to-arrow”

• many-to-many, symbolised by “fork-to-fork”

Note: The relation is usually not a flow relation!

(But you should tell what kind of relation it is.)

Page 8: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Object graphs: another example

PERSON

PersonId

HOUSEHOLD

HouseholdId

NumberOfPersons=

Income=

Sex

CO

NS

IST

S O

F

BE

LO

NG

S T

O

Income

Age

HomeMunicipality

PostalCode

HighestEducation

IS FATHER OF

IS MOTHER OF

Page 9: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Different roles of concept modelling

• Clarifying a small number of related concepts• Information model for an application

– defining meaning– basis for data design

• Corporate information model– for more efficient communication between people– basis for system integration

Page 10: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Concept model ---> Data model

FilmCopy CustomerIsRentedBy

Rents

FilmTitle

Re

pre

se

nts

IsR

ep

res

en

ted

By

FilmId

Title

Category

Price

Actor*

Story

NumberOfCopies=

NumberOfRents=

FilmId

CopyNr

Rented?

NumberOfRents

CustomerId

Name

Address

Discount

Rental

Rental date

AgreedReturnDate

Returned?

ActualReturnDate

CustomerId

FilmId

CopyNr

RentalNr

CopyNr Rented?FilmId

FilmId CopyNr CustomerId RentalNrRentals

FilmCopies

Name AddressCustomerIdCustomers

NumberOfRents

RentalDate

AgreedReturnDate

Returned?Actual

ReturnDate

Discount

FilmId Title Category Price StoryAgreed

ReturnDateReturned?

ActualReturnDate

ActorNameFilmIdActorsInFilms ActorsRoleInFilm

FilmTitles

Page 11: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

CopyNr Rented?FilmId

FilmId CopyNr CustomerId RentalNrRentals

FilmCopies

Name AddressCustomerIdCustomers

NumberOfRents

RentalDate

AgreedReturnDate

Returned?Actual

ReturnDate

Discount

FilmId Title Category Price StoryAgreed

ReturnDateReturned?

ActualReturnDate

ActorNameFilmIdActorsInFilms ActorsRoleInFilm

FilmTitles

Page 12: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Conceptual model ---> Star/cube model

FilmCopy CustomerIsRentedBy

Rents

FilmTitle

Re

pre

se

nts

IsR

ep

res

en

ted

By

FilmId

Title

Category

Price

Actor*

Story

NumberOfCopies=

NumberOfRents=

FilmId

CopyNr

Rented?

NumberOfRents

CustomerId

Name

Address

Discount

Rental

Rental date

AgreedReturnDate

Returned?

ActualReturnDate

CustomerId

FilmId

CopyNr

RentalNr

OBJECT IN FOCUS

FilmTitle

Customer

PriceGroup

NumberOfRentsPerCopy

FilmId

Title

Category

NumberOfRents

CustomerId

Category

Area

Rental

Rental date

Delayed?

CustomerId

FilmId

RentalNr

FILMCATEGORY

CUSTOMER DIS-COUNT CATEGORY

Number of rentals of film copiesduring the year t by customer

discount category and film category

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

Page 13: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Star model for Data Warehouse

OBJECT IN FOCUS

FilmTitle

Customer

PriceGroup

NumberOfRentsPerCopy

FilmId

Title

Category

NumberOfRents

CustomerId

Category

Area

Rental

Rental date

Delayed?

CustomerId

FilmId

RentalNr

Page 14: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Multidimensional model (cube model)

FILMCATEGORY

CUSTOMER DIS-COUNT CATEGORY

Number of rentals of film copiesduring the year t by customer

discount category and film category

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

number ofrentals

Page 15: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Part II: Extra material

Bo Sundgren

2010

Page 16: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Concept modelling: Exercises

• B2B– The customers of companies are companies– Companies have employees (persons)

• B2C– The customers of companies are consumers (persons)– Companies have employees (persons)

• B2B+B2C– The customers of companies are companies or

consumers (persons)– Companies have employees (persons)

Hint: There are two basic object types, COMPANY and PERSON in all three examples

Page 17: Statistical databases in theory and practice Part II: Data models Bo Sundgren 2010.

Illustrate the following three examples by:

• basic object graphs (micro-level)• relational data models (micro-level)• multidimensional cubes (hypercubes)• star models• relational data models (macro-level)