Statistical databases in theory and practice Part II: Data models

16
Statistical databases in theory and practice Part II: Data models Bo Sundgren, 2011 [email protected] https://sites.google.com/site/bosundgre n/ https://sites.google.com/site/bosundgren/my-life/Statisticaldatabases-anintrod uction.pdf?attredirects=0

description

Statistical databases in theory and practice Part II: Data models. Bo Sundgren, 2011 [email protected] https://sites.google.com/site/bosundgren/ https://sites.google.com/site/bosundgren/my-life/Statisticaldatabases-anintroduction.pdf?attredirects=0. - PowerPoint PPT Presentation

Transcript of Statistical databases in theory and practice Part II: Data models

Statistical databases in theory and practice

Part II: Data models

Bo Sundgren, [email protected]

https://sites.google.com/site/bosundgren/https://sites.google.com/site/bosundgren/my-life/Statisticaldatabases-anintroduction.pdf?attredirects=0

 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

Conceptual modelling

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

Rent-A-Video: first object graph

VideoFilm CustomerIsRentedBy

Rents

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

Rent-A-Video: further aspects

VideoFilm CustomerIsRentedBy

Rents

FilmTitle

Rep

rese

nts

IsRep

resented

By

IsRentedBy

Ren

ts

IsReservedBy

Res

erve

s

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.)

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

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

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

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

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

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

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

Part II: Extra material

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