DataModel

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 150

Data Modeling and Database Design

Minder Chen, Ph.D. mchen@gmu.edu


Team Team number Specialty Customer Customer number Customer name Customer address Customer activity Customer telephone Customer fa

member is a member of

Division Division number Division name Division address


belongs to

Employee Employee number First name Last name Employee function Employee salary

subcontract

staffed by

is assigned to

Project Project number Project name Project label Start date End date

Task Task name Task cost


contains

Data Modeling and Database Design Course Outline


" IN !"D#C I"N # Introduction to Data Modeling # Data$a%e De&elo'ment (i)e C*cle "&er&ie+ " ,N I - .ND !,(. I"N/0IP # De&elo' the /u$1ect .rea Diagram # De&elo' Preliminar* Data Model2 ,ntit* 3 !elation%hi' Identi)ication " . !I4# ,/ .ND /#4 -P,/ # .ttri$ute% Identi)ication and De)inition # De&elo' 5ull* .ttri$uted Data Model # Identi)ier% # Data Modeling ,6erci%e # Partitioning and ,ntit* /u$t*'e% " N"!M.(I7. I"N # Normali8ation # Normali8ation ,6erci%e # De-normali8ation " D. . M"D,( ,9.(#. I"N .ND M.PPIN: " !,(. I"N.( D4M/ # !e)ine a Data Model2 .nal*%i% and /im'li)ication # ran%)orm to Ph*%ical Data 4a%e De%ign " Po+erDe%igner2 Data .rchitect " P*%ical D4 De%ign and Data ;arehou%e D4 De%ign
! Minder Chen, 1993~2002 Data Modeling - 2 -

References
Data Modeling and Data$a%e De%ign 1. 4atini, Ceri, Na&athe, Conceptual Database Design, !ed+ood Cit*, C.2 he 4en1amin<Cumming% Pu$li%hing Com'an*, Inc., 1992. 2. eore*, . =., Database Modeling and Design: The Entity-Relationship Approach, Morgan >au)mann Pu$li%her%, Inc., 1990. 3. homa% .. 4ruce, Designing Quality Databases with DE!"# nfor$ation Models, Dor%et 0ou%e Pu$li%hing, N-2 Ne+ -or?, 1991. @. e6a% In%trument%, A %uide to E &sing E!, 2nd edition, Part No. 2A39ABC-0001, 1990. B. Martin, =ame%, nfor$ation Engineering 'oo( : )lanning and Analysis, Prentice0all Inc., 19D9. C. Da&e ,n%or, Ian /te&en%on, Oracle Design, "E!eill* 3 .%%ociate%, 199A A. !o$ :illette, etc., )hysical Database Design for *ybase *Q+ *er,er, Prentice 0all, 199B. D. !al'h >im$all, The Data -arehouse Tool(it, ;ile*, 199C. =.D !e)erence% 1. .ugu%t, =. 0.. .oint Application Design: The %roup *ession Approach to *yste$ Design. ,ngle+ood Cli))%, N-, Prentice 0all, Inc., 1991. 2. ;ood, =. and /il&er, D. .oint Application Design: /ow to Design Quality *yste$s in 012 +ess Ti$e. Ne+ -or?, N-, =ohn ;ile* 3 /on%, 19D9. 3. .ndre+%, D. C. and (e&enthal, N. /., !usion: ntegrating E3 CA*E3 and .AD: A /andboo( for Reengineering the *yste$s Organi4ation, ,ngle+ood Cli))%, N=2 -ourdon Pre%%, 1993.
! Minder Chen, 1993~2002 Data Modeling - 3 -

Data Modeling and Database Design: 5TROD&CT O5

" /*%tem% De&elo'ment (i)e C*cle F/D(CG in a Client</er&er ,n&ironment " Introduction to Data Modeling " Data$a%e De&elo'ment (i)e C*cle "&er&ie+

! Minder Chen, 1993~2002

Data Modeling - @ -

Rationales for Data Modeling


" Data i% the )oundation o) modern in)ormation %*%tem% ena$led $* data $a%e technologie%. " Data in an organi8ation e6i%t and can $e de%cri$ed inde'endentl* o) ho+ the%e data are u%ed. " Data %hould $e managed a% a cor'orate-+ide re%ource. " he t*'e% o) data u%ed in an organi8ation do not change &er* much. " Data ha&e certain inherent 'ro'ertie% +hich lead to correct %tructuring. " I) +e %tructure data according to their inherent 'ro'ertie%, the %tructure Fi.e., data model%G +ill $e %ta$le.
! Minder Chen, 1993~2002 Data Modeling - B -

/istory of Data Modeling


" Im'ortance o) ,ntit*-!elation%hi' Modeling echniHue
# # # # # Data$a%e Data modeling and enter'ri%e-+ide data Data Hualit* Data u'dating and acce%%ing tool% and 'rocedure Data %haring culture

" ,! modeling techniHue +a% )ir%t de&elo'ed $* Peter Chen in 19AC


# # # . conce'tual<logical data modeling tool . u%er-oriented a''roach . gra'hic-$a%ed method

" ,! modeling techniHue i% the ma1or data modeling method in In)ormation ,ngineering and i% +idel* %u''orted $* mo%t o) C./, tool%. " Data modeling i% the )oundation o) mo%t data$a%e-centered tran%action 'roce%%ing %*%tem% and data +arehou%e %*%tem%

! Minder Chen, 1993~2002

Data Modeling - C -

C*C De,elop$ent *trategies


0I:0 0I:0
" !,-C!,. , ne+ $u%ine%% 'roce%% 3 %*%tem% )rom %cratch " !,-,N:IN,,! $u%ine%% 'roce%% 3 %*%tem%

!i%? (ong erm !e+ard /hort erm Co%t% Degree o) Change

" !,-D,/I:N current %*%tem% " !,-0"/ current %*%tem% " !,-IM.:, current %*%tem%

("; (";
! Minder Chen, 1993~2002 Data Modeling - A -

Distribution of 'usiness !unction 6+ogic7


Pre%entation /'ace
Pre%entation Pre%entation /er&ice (ogic 5unction (ogic Data (ogic Data /er&ice

Data /'ace

Client
" " " " " Pre%entation logic (ocal in'ut &alidation "ut'ut 'roduction logic (ocal 'eri'heral dri&er% Per)ormance critical 'roce%%ing " " "

/er&er
5unction% that acce%% data on the %er&er 5unction% that need in'ut )rom multi'le u%er% 5unction% that coordinate the +or? o) %e&eral u%er

I%%ue%2
" " " " "
! Minder Chen, 1993~2002

Di%tri$ution o) data Plat)orm-%'eci)ic ca'a$ilitie% and intero'era$ilit* Connecti&it* ca'a$ilitie%<'lat)orm 5reHuenc* o) change to code% Con)iguration management

Data Modeling - D -

C8* De,elop$ent Methodology


/D(C C</ .rchitecture #%er Inter)ace Conce'tual .nal*%i% ;or? 5lo+ rule%IJ (ogical De%ign 5orm /eHuence% 'er)ormance IJ Ph*%ical De%ign 5orm%, /creen%

.''lication (ogic

Proce%% 5lo+

"$1ect Interaction Model Data$a%e /chema

Program%, Procedure%

In)ormation 3 Data 4a%e

Data Model

a$le%, Inde6e%

/ource2 Da&id 9a%?e&itch, Client</er&er /trategie%, ID: 4oo?%, 1993. Data Modeling - 9 ! Minder Chen, 1993~2002

;h /ta ere D rt K oou

Client8*er,er Application De,elop$ent Methodology


!eHuirement%

nfor$ation 9 Data 'ase

Proce%%e% 4eha&ior

;or?)lo+ #%er Inter)ace

.rchitecture

.''lication De%ign and De&elo'ment


/ource2 Da&id 9a%?e&itch, Client</er&er /trategie%, ID: 4oo?%, 1993. ! Minder Chen, 1993~2002 Data Modeling - 10 -

Data Modeling 6Data 'ase Design7 )rocess


In)ormation !eHuirement% Conce'tual D4 De%ign . conce'tual D4 %chema i% a highle&el de%cri'tion o) the data$a%e, inde'endent o) the 'articular D4M/.

Conce'tual F,nter'ri%eG D4 /chema (ogical D4 De%ign . logical D4 %chema i% a de%cri'tion o) the %tructure o) the data$a%e that can $e 'roce%%ed $* a D4M/2 relational, net+or?, or hierarchical.
. 'h*%ical D4 %chema i% a de%cri'tion o) the im'lementation o) the data$a%e in e6ternal memor*L it de%cri$e% the %torage %tructure% and acce%% method% u%ed in order to e))ecti&el* acce%% and maintain data.

(ogical D4 /chema
Ph*%ical D4 De%ign

Ph*%ical D4 /chema
/ource2 4atini, C., Ceri, /., and Na&athe, /. 4., Conceptual Database Design: An EntityRelationship Approach, he 4en1amin<Cumming% Pu$li%hing Com'an*, Inc., 1992. Data Modeling - 11 ! Minder Chen, 1993~2002

Multiple )erspecti,es
)e use this data

$%E &'S(%ESS

)e do these things

D. .

.C I9I -

0I!, ,MP("-,,

P.,MP("-,,

,MP("-,, P!"M" , ,MP("-,,

...... ...... .... ....

! Minder Chen, 1993~2002

5I!, ,MP("-,,

Data Modeling - 12 -

Data Model 6Entity Relationship Diagra$7


Mem$er "rder 'laced $*L 'lace% i% enrolled underL a''lie% to

Mem$er

.greement

%ell%L i% %old on

generate%L generated $*

e%ta$li%hed $*L e%ta$li%hed

Product

i% )eatured inL )eature%

Promotion

%'on%or%L i% %'on%ored $*

Clu$

! Minder Chen, 1993~2002

Data Modeling - 13 -

Entity Relationship Diagra$: *ub:ect Area and Entity Type

" /u$1ect .rea and /u$1ect .rea Diagram " ,ntit* *'e% " ,ntit* In%tance% " 5inding ,ntit* *'e% " ,&aluating ,ntit* *'e%

! Minder Chen, 1993~2002

Data Modeling - 1@ -

*ub:ect Area 6*ub$odel7


" . natural area o) intere%t to the $u%ine%% that i% centered on a ma1or re%ource, in'ut%, out'ut%, or acti&it* o) the $u%ine%%. " It contain% a %et o) entit* t*'e%. " ;e %tart the data modeling in the I/P %tage $* identi)*ing %u$1ect area% +ith name% and de%cri'tion%. " In 4.. %tage, %u$1ect area% are u%ed to a% high le&el grou'ing o) entit* t*'e%. " Naming2 a %u$1ect area i% a noun in 'lural )orm and o)ten ha% the name a% the central entit* t*'e in the %u$1ect area. " ,6am'le%2

Pro1ect%
Pro1ect Mem$er a%?

Pro1ect
! Minder Chen, 1993~2002 Data Modeling - 1B -

*ub:ect Area Diagra$

Customers

Products Raw-materials Orders Buyers Suppliers Purchas e Orders

Sales-persons
Legends

: Subject Area : Association


! Minder Chen, 1993~2002 Data Modeling - 1C -

Entity Types
" De)inition2
# .n entit* i% an o$1ect or e&ent, real or a$%tract, a$out +hich +e +ould li?e to %tore data. ,ntit* i% the a$$re&iation o) entit* t*'e. It re're%ent a %et o) entit* in%tance% +hich can $e de%cri$ed $* the %ame %et o) attri$ute t*'e%. he &alue o) the %ame attri$ute )or each entit* in%tance ma* $e di))erent.

" Identi)*ing ,ntit* *'e%


# ;hat in)ormation i% reHuired $* the $u%ine%%K # hing% that are o) intere%t to the $u%ine%% that need to $e remem$ered in order to manage and trac? them. # hing% $elong to the %ame entit* t*'e ha&e common characteri%tic%.
! Minder Chen, 1993~2002 Data Modeling - 1A -

5a$ing Entity Types


" he name o) each entit* i% in %ingular )orm
# # # # a noun an ad1ecti&e M a noun a noun M a noun IJ Fnoun %tringG an ad1ecti&e M a noun M a noun

" ,6am'le% " " " "

# Cu%tomer, Cu%tomer "rder, Product, 0ourl* ,m'lo*ee, Pro1ect, De'artment, #n)illed Cu%tomer "rder

4e clear and conci%e .&oid a$$re&iation 4e con%i%t +ith u%erN% terminolog* Identi)* %*non*m%
# Cu%tomer # Product # /u''lier eacher # Client Merchandi%e 9endor 5acult*

" #%e one name a% the o))icial name and document other% a% alia%e%

! Minder Chen, 1993~2002

Data Modeling - 1D -

E;ercise: Entity Type 5a$ing

" Cour%e% " De'artment " Cu%tomer "rder " P"

! Minder Chen, 1993~2002

Data Modeling - 19 -

)roperties of Entity Types


" " " " " " " " Name De%cri'tion Identi)ier Pro'ertie%2 ,%timated num$er FMa6., Min., .&erageG o) entit* in%tance% ,6'ected gro+th rate o) entit* in%tance% /u$1ect .rea in +hich the ,ntit* *'e re%ide% .ttri$ute% that de%cri$e the ,ntit* *'e% ,6am'le% o) entit* t*'e in%tance%

! Minder Chen, 1993~2002

Data Modeling - 20 -

Definition of an Entity Type " . 'oor de)inition o) Cu%tomer2 .n*one that $u*% %omething )rom the com'an*.
# Can em'lo*ee% $e a cu%tomerK # Can a lea%or $e a cu%tomerK # I) the com'an* %old a %u$%idiar* to another com'an*, doe% the ne+ o+ner con%ider a cu%tomerK

" :ood de)inition %hould $e2


# # # # # Com'ati$le Preci%e Conci%e Clear Com'lete
Data Modeling - 21 -

! Minder Chen, 1993~2002

%ood Definition
" Com'ati$le
# Cu%tomer2 .n "!:.NI7. I"N that 'urcha%e P!"D#C % )or 'er%onal u%e. # Di%tri$utor2 .n "!:.NI7. I"N that 'urcha%e P!"D#C % )or re%ale.

" Preci%ion2
# ;ith a''ro'riate Huali)ier% # ,6am'le2 .n "!:.NI7. I"N i% con%idered to ha&e 'urcha%e a P!"D#C +hen +e recei&e a &alid P#!C0./, "!D,! )rom it.

" Com'lete
# "!:.NI7. I"N, P!"D#C , P#!C0./, "!D,! need to $e de)ined.

" Conci%e and Clear


# #%e modular de)inition
! Minder Chen, 1993~2002 Data Modeling - 22 -

E;a$ple of Entity Type Descriptions

Entity Type
Cu%tomer Product !a+-material /u''lier 4u*er

Description
In)ormation a$out all 'er%on% or organi8ation% +ho 'urcha%e%

.ll good% manu)actured and %old Com'onent% u%ed to manu)acture Product%. 9endor% o) !a+ Material%.
Com'an* 'er%onnel re%'on%i$le )or 'urcha%ing !a+-Material% )rom /u''lier%

! Minder Chen, 1993~2002

Data Modeling - 23 -

Entity Type and Entity nstance 6Occurrence7 ,ntit* *'e% 9endor ,m'lo*ee Cour%e De'artment ,ntit* In%tance .4C Co. =ohn /mith Intro. to I,
Mar?eting De'artment

! Minder Chen, 1993~2002

Data Modeling - 2@ -

E;ercise: Entity Types or Entity nstances<

" Mar*land " "rgani8ation #nit " Cu%tomer " Pre%ident " 4ill Clinton " De'artment o) Commerce " .ddre%%

! Minder Chen, 1993~2002

Data Modeling - 2B -

!inding Entity Types " " " " " " Inter&ie+% +ith u%er% =.D +or?%ho'% 4u%ine%% )orm% !e'ort% Com'uter )ile% u%ing re&er%e engineering "'eration manual%

! Minder Chen, 1993~2002

Data Modeling - 2C -

-here to +oo( for an Entity Type<


" angi$le or Intangi$le hing%
he noun% that are u%ed to de%cri$e the 'ro$lem domain +ill o)ten corre%'ond to the ma1or ,ntit* *'e% o) the %*%tem, at lea%t at a high le&el. # ,6am'le%2 Product, /en%or, and ,m'lo*ee, De'artment, and /ale "))ice. #

" !e%ource%
# .n* re%ource% that an organi8ation need% to manage %hould $e re're%ented a% an ,ntit* *'e. In)ormation a%%i%t% the e))icient and e))ecti&e u%e o) other re%ource% through im'ro&ed deci%ion. # ,6am'le%2 In&entor*, Machine, 4an? .ccount, and Cu%tomer.

" !ole% Pla*ed


# !ole% can $e 'la*ed $* 'er%on% or organi8ational unit%. # ,6am'le%2 Cu%tomer%, Manager%, and .ccount re're%entati&e%.

" ,&ent%
# ,&ent% are incident% that occur at 'oint% in time. .n e&ent o)ten in&ol&ed an interaction $et+een t+o ,ntit* *'e% or an action that change% the %tatu% o) an ,ntit* *'e. # ,6am'le%2 /ale, Deli&er*, and !egi%tration o) a motor &ehicle.

! Minder Chen, 1993~2002

Data Modeling - 2A -

' A T:
" " " "

'usiness nfor$ation Analysis and ntegration Techni=ue

.nal*%i% o) "rder% "rdered entitie% can $e a thing, a %'ace, or a %?ill. 9ie+ the order )rom %u''lier %ide. I) an organi8ation recei&e% no order%, it ha% no rea%on )or e6i%ting. " .n organi8ation unit can recei&e multi'le t*'e% o) order%. " @ Hue%tion% a$out the /u''lier2
# # # # 4illing FCa%hGK Deli&er (ate FImmediateGK Pro)ile cu%tomerK Negotiate 'rice F5i6edGK

" 3 Hue%tion% a$out the "rdered ,ntit*2


# !ented F/oldGK # rac?edK # Made to order F/toc?GK
*ource: Carlson3 -> M>3 ?' A T: 'usiness nfor$ation Analysis and ntegration Techni=ue The 5ew /ori4on3? Data 'ase3 @ol> "13 5o> 03 "ABA3 pp> C-A>
! Minder Chen, 1993~2002 Data Modeling - 2D -

Criteria for E,aluating an Entity Type


" Need to $e remem$ered $* the in)ormation %*%tem in order to $e )unctional. " Can $e o'erated on2 C!,. ,, !,.D, #PD. ,, D,(, ,. " 0a% a %et o) o'eration%<%er&ice% that al+a*% a''l* to change the %tatu% o) each occurrence o) an ,ntit* *'e. " Carr* a %et o) attri$ute% that al+a*% a''l* to de%cri$e each occurrence o) an ,ntit* *'e. " 0a&e at lea%t one relation%hi' +ith other entit* t*'e. " ,6i%t more than one entit* occurrence Fin%tanceG in an ,ntit* *'e. " 0a&e at lea%t a uniHue identi)ier. " Domain-$a%ed reHuirement%2 /omething that the %*%tem mu%t ha&e in order to o'erate. he%e ma* $e clearl* %'eci)ied in the 'ro$lem de%cri'tion or ?no+n )rom %u$1ect matter e6'ert%.

! Minder Chen, 1993~2002

Data Modeling - 29 -

Entity Relationship Modeling and Diagra$$ing

" !elation%hi'% " ,ntit* !elation%hi' Diagramming Notation " .ttri$ute% " Identi)ier% " Partitioning and ,ntit* /u$t*'e%

! Minder Chen, 1993~2002

Data Modeling - 30 -

Relationship 6Type7
" De)inition
# . !elation%hi' *'e i% an a%%ociation among ,ntit* *'e%. It indicate% that there i% a $u%ine%% relation%hi' $et+een the%e ,ntit* *'e%. # !elation%hi' Mem$er%hi' i% the 'artici'ation o) an ,ntit* *'e in a !elation%hi'. # In I,, a !elation%hi' *'e can in&ol&e onl* t+o ,ntit* *'e% F$inar* relation%hi'G. /ome other modeling techniHue% allo+ n-ar* relation%hi'%.

" ,6am'le%
# # # # C#/ "M,! 'lace% "!D,! "!D,! i% 'laced $* C#/ "M,! ,MP("-,, +or?% on P!"=,C P!"=,C ha% 'ro1ect mem$er ,MP("-,,
Data Modeling - 31 -

! Minder Chen, 1993~2002

)aring 6Relationship nstance7


" !elation%hi' 'aring i% a 'air o) ,ntit* In%tance% o) t+o ,ntit* *'e% a%%ociated $* a !elation%hi' *'e $et+een the%e t+o ,ntit* *'e%. ,ntit* *'e%
/tudent

,ntit* In%tance
/tudentO1 /tudentO2
Cour%eO. Cour%eO4 Cour%eOC Cour%eOD

Cour%e

!elation%hi'
/tudent ta?e% Cour%e
! Minder Chen, 1993~2002

!elation%hi' Paring
/tudentO1 ta?e% Cour%eO. /tudentO1 ta?e% Cour%eO4 /tudentO1 ta?e% Cour%eOD /tudentO2 ta?e% Cour%eO. /tudentO2 ta?e% Cour%eOC /tudentO2 ta?e% Cour%eOD
Data Modeling - 32 -

Relationship nstances %rouping

" De)inition2 . collection o) 'airing% o) a !elation%hi' Mem$er%hi' in +hich an ,ntit* In%tance i% in&ol&ed. " ,6am'le%2
# /tudentO1 ta?e% Cour%eO., O4, and OD # /tudentO2 ta?e% Cour%eO., OC, and OD # Cour%eO. i% ta?en $* /tudentO1 and /tudentO2

! Minder Chen, 1993~2002

Data Modeling - 33 -

Relationship Cardinality
One-to-One One-to-One
121
! "

One-to-#any One-to-#any
12M

"

#any-to-#any #any-to-#any
M2N

"

! Minder Chen, 1993~2002

Data Modeling - 3@ -

Relationship Cardinality
" he num$er o) ,ntit* In%tance% in&ol&ed in the !elation%hi' In%tance% :rou'ing in a !elation%hi' *'e. " hree 5orm% o) Cardinalit*
1. "ne-to-one F121G D,P.! M,N ha% M.N.:,! ,ach D,P.! M,N ha% one and onl* one M.N.:,! ,ach M.N.:,! manage% one and onl* one D,P.! M,N 2. "ne-to-man* F12mG C#/ "M,! 'lace% "!D,! ,ach C#/ "M,! %ometime% F9BPG 'lace one or more "!D,!% ,ach "!D,! al+a*% i% 'laced $* e6actl* one C#/ "M,! 3. Man*-to-man* Fm2nG IN/ !#C "! teache% C"#!/, ,ach IN/ !#C I"N teache% 8ero, one, or more C"#!/,% ,ach C"#!/, i% taught $* one or more IN/ !#C "!%
Data Modeling - 3B -

! Minder Chen, 1993~2002

Entity Relationship Diagra$ 6ERD7: 5otations


:ra'hical :ra'hicalNotation% Notation% Cardinalit* indicator relation%hi'-de%cri'tion 8ero one man*

,ntit*-Q

re&er%ed-relation-de%cri'tion

,ntit*--

min ma6 ran%late ran%lateinto intot+o t+o%tructured %tructured%tatement% %tatement% ,ach ,ntit*-Q relation%hi'-de%cri'tion cardinalit*-indicator Fone-or-man*G ,ntit*--

,ach ,ntit*-- re&er%ed-relation%hi'-de%cri'tion F8ero-or-oneG ,ntit*-,6am'le ,6am'le

De'artment

i%-managed-$* manage%

Manager

! Minder Chen, 1993~2002

Data Modeling - 3C -

Optionality of Relationship Me$berships " ;hether all entit* in%tance% o) $oth entit* t*'e% need to 'artici'ate in relation%hi' 'airing. " "'tionalit*2
# Mandator* # "'tional

" ,6am'le2
# C#/ "M,! mem$er%hi' i% o'tional # "!D,! mem$er%hi' i% mandator*
'lace%

C#/ "M,!
! Minder Chen, 1993~2002

i% 'laced $*

"!D,!
Data Modeling - 3A -

Relationship *tate$ents
:ra'hical :ra'hicalNotation% Notation%

Cardinalit* indicator 'lace%

one one or more

C#/ "M,!

i% 'laced $*

"!D,!
8ero F%ometime%G one Fal+a*%G

"'tionalit* indicator

,ach ,ach,ntit* ,ntit*Q Q o'tionalit* o'tionalit* relation%hi' relation%hi' cardinalit* cardinalit* ,ntit* ,ntit*,ach C#/ "M,! %ometime% 'lace% one or more "!D,!. ,ach "!D,! al+a*% i% 'laced $* one C#/ "M,!.
! Minder Chen, 1993~2002 Data Modeling - 3D -

Defining Relationships
" Name " De%cri'tion " Pro'ert*
# Cardinalit* &olume% # "'tionalit* 'ercentage2 P o) ,ntit* *'e QE% in%tance% 'airing +ith ,ntit* *'eE% -E% in%tance% # ran%)era$ilit*2 . relation%hi' i% tran%)era$le i) an entit* in%tance can change it% 'airing +ithin the %ame relation%hi'.
* !.N/5,!.4(,2 .n ,MP("-,, can change to a di))erent D,P.! M,N . * N"N- !.N/5,!.4(,2 .n "!D,! cannot $e tran%)erred to another C#/ "M,!.
! Minder Chen, 1993~2002 Data Modeling - 39 -

ERD: More E;a$ples


&a' Customer places belongs-to Order

Product

is-contained-in contains manages

&b' mployee

wor$s-%or

is-managed-by Project has-project-members

Parallel !elation%h i'

&c'

is-consists-o%

Part

contained-in

In&oluted or (oo'ed !elation%hi'

! Minder Chen, 1993~2002

Data Modeling - @0 -

ERD: Alternati,e 5otations


Cu%tomer 'lace% $elong%-to .lternati&e .lternati&eNotation%2 Notation%2 Cu%tomer Cu%tomer Cu%tomer 'lace% 'lace% 1 'lace% $elong%-to "rder $elong%-to "rder M "rder "rder

! Minder Chen, 1993~2002

Data Modeling - @1 -

dentifying Relationships

" .%%ociation $et+een entit* t*'e% " ,ntit* t*'e% that are u%ed on the %ame )orm% or document%. " . de%cri'tion in a $u%ine%% document that ha% a &er$ that relate% t+o entit* t*'e%
# ha% # con%i%t% o) # u%e%
! Minder Chen, 1993~2002 Data Modeling - @2 -

Attributes
" De)inition
# Characteri%tic% that could $e u%ed to de%cri$e ,ntit* *'e% and !elation%hi' *'e%. 0o+e&er, in I,, relation%hi' t*'e% are not allo+ed to ha&e attri$ute%.

" Naming Con&ention%2


# Name% that ha&e $u%ine%% meaning # DonEt u%e a$$re&iation or 'o%%e%%i&e ca%e, e.g., PN and Cu%tomerE% name # DonEt include entit* t*'e name $ecau%e I,5 +ill 're)i6 the attri$ute name +ith entit* t*'e name automaticall* # #%e %tandard )ormat2

,ntit* *'e Name FRuali)ier%G Domain Name Cu%tomer Name ,m'lo*ee /tarting Date " ,6am'le%
# # # # Cu%tomer ha% cu%tomer name, addre%%, and tele'hone num$er Product ha% Huantit*-on-hand, +eight, &olume, color, and name. ,m'lo*ee ha% //N, %alar*, and $irthda*. ,m'lo*ee-+or?%-)or-'ro1ect ha% 'ercentage-o)-time, %tarting-date.

! Minder Chen, 1993~2002

Data Modeling - @3 -

Attributes: 5otations
Student Student () Student *ame
Employee Employee number First name Last name Employee function Employee salary

Birth date Student () Course no+ enrollment Birth date

/tudent %tudentID name 'hone

/tudentF/tudent /tudentF/tudent ID, ID, /tudent /tudent Name, Name, 4irth 4irth DateG DateG
5inding 5inding.ttri$ute%2 .ttri$ute%2 .ttri$ute% .ttri$ute%are areidenti)ied identi)ied'rogre%%i&el* 'rogre%%i&el*during during 4.. 4.. 'ha%e. 'ha%e. "" Data Data.nal*%i% .nal*%i% "" .cti&it* .cti&it*.nal*%i% .nal*%i% "" Interaction Interaction.nal*%i% .nal*%i% "" Current Current /*%tem% /*%tem% .nal*%i% .nal*%i%
! Minder Chen, 1993~2002 Data Modeling - @@ -

Attribute @alue
" De)inition
# .ttri$ute 9alue% are in%tance% o) .ttri$ute% u%ed to de%cri$e %'eci)ic ,ntit* In%tance%

" ,6am'le%
# # # # # Cu%tomer Num$er2 01133@ Cu%tomer Name2 Minder Chen /tate2 9. "rder otal2 S23,000 /ale ta62 S2B0

" .n attri$ute o) an entit* t*'e %hould ha&e onl* one &alue at an* gi&en time. FNo re'eating grou'G " .&oid u%ing com'le6 coding %cheme )or an attri$ute. 5or e6am'le2 P.! Num$er2 Q-QQQ-QQQ
Part *'e
! Minder Chen, 1993~2002

Material

/eHuence Num$er
Data Modeling - @B -

Type 9 nstance
"4=,C -P, ,ntit* *'e ,ntit* ,ntit* *'e !elation%hi' F *'eG .ttri$ute F *'eG "CC#!!,NC, ,ntit* In%tance ,ntit* In%tance ,ntit* Pairing F!elation%hi' In%tanceG F.ttri$uteG 9alue

! Minder Chen, 1993~2002

Data Modeling - @C -

Attribute *ource Categories


" 4a%ic
# De)inition2 .n .ttri$ute 9alue that cannot $e deduced or calculated. # ,6am'le%2 /tudent name and 4irthda*

" Deri&ed
# De)inition2 he .ttri$ute 9alue can $e calculated or deduced )rom relation%hi' :rou'ing% or )rom the &alue% o) other .ttri$ute%. he &alue o) a Deri&ed .ttri$ute change% con%tantl*. # ,6am'le%2 /tudent .ge, .ccount 4alance, Num$er o) cour%e% ta?en.

" De%igned
# De)inition2 he .ttri$ute i% created to o&ercome the %*%tem con%traint%. he &alue o) a De%igned .ttri$ute doe% not change. # ,6am'le%2 /tudent ID, Cour%e num$er.
! Minder Chen, 1993~2002 Data Modeling - @A -

Data Types

! Minder Chen, 1993~2002

Data Modeling - @D -

)roperties of Attributes
" " " " " " " Name De%cri'tion .ttri$ute /ource Categor*2 4a%ic, Deri&ed, De%igned Domain or data t*'e2 e6t, Num$er, Date, ime, ime%tam' "'tionalit*2 Mandator* or o'tional (ength and<or 'reci%ion Permitted 9alue% F(egal 9alue%G
# # !ange% . %et o) &alue% FCode a$leG

" De)ault &alue or algorithm ool% %uch a% Po+er4uilder ha% additional 'ro'ertie% )or ta$leN% column% called e6tended attri$ute%
# 9alidation !ule # ,diting 5ormat # !e'orting 5ormat
# Column 0eading # 5orm (a$el # Code a$le
Data Modeling - @9 -

! Minder Chen, 1993~2002

Co$posite Attribute
" De)inition2 " ,6am'le2
# ele'hone Num$er I

.rea code M ,6change M ,6ten%ion " here i% no %u''ort o) com'o%ite attri$ute t*'e mo%t o) C./, tool%. In %uch ca%e, an com'o%ite attri$ute mu%t $e %tored a% an entit* t*'e.

! Minder Chen, 1993~2002

Data Modeling - B0 -

Do$ain
" . collection o) &alue% +hich can $e ta?en $* one or more attri$ute%. " Date i% the domain )or "rdered Date, /tudentE% 4irthda*, ,m'lo*ee /tarting Date. " . u%ed de)ined domain can ha&e custo$i4ed ,alidation rules and for$ats. " C./, tool% %uch a% I,5 onl* %u''ort% the )ollo+ing $a%ic domain%2
# e6t # Num$er # Date # ime # ime%tam'
! Minder Chen, 1993~2002 Data Modeling - B1 -

dentifiers " he identi)ier o) an entit* t*'e i% a %et o) attri$ute% and<or relation%hi'% +ho%e &alue% can uniHuel* identi)* an entit*. " ,ntit* t*'e% %hould ha&e one identi)ier. " Identi)ier% ma* con%i%t o)
# . %ingle attri$ute2 /tudent ID # . %et o) attri$ute%2 /tudent% ID M Cour%e ID # .n attri$ute and a relation%hi' mem$er%hi' Fim'lemented a% a )oreign >e*G2 "rder Item No M "rder 0a% "rder Item

! Minder Chen, 1993~2002

Data Modeling - B2 -

dentifying Relationship

cu%tomer
'lace%

'roduct
/*m$ol )or Identi)*ing !elation%hi'
i% ordered $*

"!D,!/
i% 'laced $* contain% ha%

order

i% 'art o)

order item

! Minder Chen, 1993~2002

Data Modeling - B3 -

Data Modeling Case *tudy


he )ollo+ing i% de%cri'tion $* a 'harmac* o+ner2

T=ac? /mith catche% a cold and +hat he %u%'ect% i% a )lu &iru%. 0e ma?e% an a''ointment +ith hi% )amil* doctor +ho con)irm hi% diagno%i%. he doctor 're%cri$e% an anti$iotic and na%al deconge%tant ta$let%. =ac? lea&e% the doctorE% o))ice and dri&e% to hi% local drug %tore. he 'harmaci%t 'ac?age% the medication and t*'e% the la$el% )or 'ill $ottle%. he la$el include% in)ormation a$out cu%tomer, the doctor +ho 're%cri$e the drug, the drug Fe.g., PenicillinG, +hen to ta?e it, and ho+ o)ten, the content o) the 'ill F2B0 mgG, the num$er o) re)ill%, e6'iration date, and the date o) 'urcha%e.T
Plea%e de&elo' a data model )or the entitie% and relation%hi'% +ithin the conte6t o) 'harmac*. .l%o de&elo' a de)inition )or T're%cri'tionT. (i%t all *our underl*ing a%%um'tion% u%ed in *our data model%.

! Minder Chen, 1993~2002

Data Modeling - B@ -

Data Modeling Case *tudy


:i&en the )ollo+ing narrati&e de%cri'tion o) entitie% and their relation%hi'%, 're'are a dra)t entit* relation%hi' diagram F,!DG. 4e %ure an* rea%ona$le a%%um'tion% that *ou are ma?ing.

4urger ;orld Di%tri$ution Center %er&e% a% a %u''lier to @B 4urger ;orld )ranchi%e%. -ou are in&ol&ed +ith a 'ro1ect to $uild a data$a%e %*%tem )or di%tri$ution. ,ach )ranchi%e %u$mit% a da*-$*-da* 'ro1ection o) %ale% )or each o) 4urger ;orldE% menu 'roduct% - the 'roduct% li%ted on the menu at each re%taurant - )or the coming month. .ll menu 'roduct reHuire ingredient% and<or 'ac?aging item%. 4a%ed on 'ro1ected %ale% )or the %tore, the %*%tem mu%t generate a da*-$*-da* and ingredient% need and then colla'%e tho%e need% into one-'er-+ee? 'urcha%e reHui%ition% and %hi'ment%.

! Minder Chen, 1993~2002

Data Modeling - BB -

Data Modeling )rocess


" (i%t entit* t*'e% " Create relation%hi'%
# Pic? a central entit* t*'e # ;or? around the neigh$orhood
* .dd entit* t*'e% to the diagram * 4uild relation%hi'% among them

# Determine cardinalitie% o) relation%hi'%

" 5ind<Create identi)ier% )or each entit* t*'e " .dd attri$ute% to the entit* t*'e in the data model " .nal*8e and re&i%e the data model

! Minder Chen, 1993~2002

Data Modeling - BC -

Classifying Attribute and )artitioning


" .n ,ntit* /u$t*'e . collection o) ,ntitie% o) the %ame t*'e to +hich a narro+er de)inition and additional .ttri$ute% and !elation%hi'% a''l*. .n ,ntit* /u$t*'e inherit% Fretain%G all the .ttri$ute% and !elation%hi'% o) it% 'arent ,ntit* *'e. " Cla%%i)*ing .ttri$ute2 .n attri$ute o) the 4a%e ,ntit* *'e +ho%e &alue% 'artition the ,ntit* In%tance% into /u$t*'e%. " Partitioning2 . $a%i% )or %u$di&iding one entit* t*'e into %u$t*'e%. he 'roce%% o) di&iding an ,ntit* *'e into %e&eral /u$t*'e% $a%ed on a Cla%%i)*ing .ttri$ute i% called Partitioning. " he Cla%%i)*ing .ttri$ute i% recorded a% a 'ro'ert* o) the Partitioning and it a''ear% on the diagram.
Data Modeling - BA -

! Minder Chen, 1993~2002

Characteristics of )artitioning
" "'tionalit*2
# Mandator*2 ,&er* ,ntit* in%tance% o) the ,ntit* *'e mu%t )all into one o) the /u$t*'e categorie%. # "'tional2 Not e&er* ,ntit* in%tance% o) the ,ntit* *'e mu%t )all into one o) the /u$t*'e categorie%.

" ,ntit* (i)e C*cle2 he %tate% through +hich an ,ntit* *'e can 'a%% are u%ed )or Partitioning. " ,numeration2
# 5ull* enumerated # Not )ull* enumerated

" Cla%%i)*ing .ttri$ute% and 9alue%


# Cla%%i)*ing .ttri$ute2 *'e # D2 Dome%tic /u$t*'e # 52 5oreign /u$t*'e
! Minder Chen, 1993~2002 Data Modeling - BD -

)artitioning and Entity *ubtype: 5otation


. !I4# ,2 ,m'lo*ee ID Name 4irthda* . !I4# ,2 eaching Rualit* Indicator

,m'lo*ee
*'e

(ecturer /ta))

eache%

/eminar

/tatu%

;age 0ourl*
! Minder Chen, 1993~2002 Data Modeling - B9 -

Alternati,e 5otations for *ubtypes


ID,51Q Com'lete Categor* .ll categorie% %ho+n
em'lo*eeID name 'hone

Po+erDe%igner
,ccount ,ccount %umber %ame

em'lo*ee t*'e

)ull-time-em' em'lo*eeID F5>G %alar*

'art-time-em' em'lo*eeID F5>G hourl*-rate

Savings +ate

Checking Fees

! Minder Chen, 1993~2002

Data Modeling - C0 -

Entity *ubtype )artitioning


(i)e (i)e C*cle C*cle Partitioning Partitioning
"rder
"rder /tatu%

a?en /cheduled /hi''ed 4illed Paid

! Minder Chen, 1993~2002

Data Modeling - C1 -

5or$ali4ation
" . data $a%e i% a model or an image o) the realit*. " (ogical Data 4a%e De%ign i% a 'roce%% o) modeling and ca'turing the end-u%er &ie+% o) an a''lication domain and %*nthe%i% them into a data $a%e %tructure. " Normali8ation i% a logical data $a%e de%ign method. " he $a%i% )or normali8ation i% the )unctional de'endencie% among attri$ute% in a ta$le.

! Minder Chen, 1993~2002

Data Modeling - C2 -

*Q+ Ter$inology
Product Product /able /able
p,no product,name -uantity price Row !.! ".! "." Color /0 B34 /0 PC "1 !. 2 2.. "2. "... Column

Create Create a a table table in in S5L S5L

C!,. , .4(,/ F'Uno C0.!FBG N" N#((, 'roductUname C0.!F20G, Huantit* /M.((IN , 'rice D,CIM.(F10, 2GGL
! Minder Chen, 1993~2002 Data Modeling - C3 -

*Q+ Ter$inology
/et heor* !elational D4 a$le Column !o+ Pool o) legal &alue% 5ile 5ile Data item !ecord Data t*'e ,6am'le ProductUta$le ProductUname ProductU101E% in)o. D. , !elation .ttri$ute u'le Domain

! Minder Chen, 1993~2002

Data Modeling - C@ -

*Q+ )rinciples
" " " " " " " he re%ult o) a /R( Huer* i% al+a*% a ta$le F9ie+ or D*namic a$leG !o+% in a ta$le are con%idered to $e unordered Dominate the mar?et% %ince late 19D0% Can $e u%ed in interacti&e 'rogramming en&ironment% Pro&ide $oth data de)inition language FDD(G and data mani'ulation language FDM(G . non-'rocedural language Can $e em$edded in 3:(2
# ,m$edded /R( # D*namic /R(
! Minder Chen, 1993~2002 Data Modeling - CB -

*Q+: Data Definition +anguage 6DD+7


C!,. , D!"P .4(, 9I,; IND,Q D. .4./,

.( ,!

.4(,

! Minder Chen, 1993~2002

Data Modeling - CC -

*Q+: ntroduction
" . relational data $a%e i% 'ercei&ed $* it% u%er% a% a collection o) ta$le% " ,. 5. Codd 19C9 " Dominate the mar?et% %ince late 19D0% " /trength%2
# /im'licit* # ,nd-u%er orientation # /tandardi8ation # 9alue-$a%ed in%tead o) 'ointer-$a%ed # ,ndor%ed $* ma1or com'uter com'anie%

" Mo%t C./, 'roduct% %u''ort the de&elo'ment o) relational data $a%e centered a''lication%
! Minder Chen, 1993~2002 Data Modeling - CA -

*Q+: Data Manipulation +anguage 6DM+7


S S L L C/ C/ 6P)A/ 6P)A/ (*S (*S R/ R/ ) ) L L / / 'Uno 101 201 202 'roductUname Color 9 43; 9 PC Huantit* 2@ 10 B 'rice B00 2B0 2000

/he /he 7eneric 7eneric 8orm 8orm o% o% the the S S L L C/ C/ Statement Statement /,(,C /,(,C VDI/ VDI/ INC INC WWcolumnF%G columnF%G 5!"M 5!"M ta$leF%G ta$leF%G V;0,!, V;0,!,condition%W condition%W V:!"#P V:!"#P44- columnF%G columnF%G V0.9IN: V0.9IN: conditionWW conditionWW V"!D,! V"!D,!44- columnF%GW columnF%GW
! Minder Chen, 1993~2002 Data Modeling - CD -

Database Table
" he )ollo+ing code retrie&e% onl* the (a%t Name and the ,m'lo*ee ID +here the ,m'lo*ee ID i% greater than B. he record% are retrie&ed in de%cending order. /,(,C (a%tName, ,m'lo*eeID 5!"M ,m'lo*ee% ;0,!, ,m'lo*eeID J B "!D,! 4- ,m'lo*eeID D,/C

! Minder Chen, 1993~2002

Data Modeling - C9 -

-/ERE Clause
" ;0,!,2 #%e the ;here clau%e to limit the %election. he O %*m$ol indicate% literal date &alue%. /,(,C X 5!"M ,m'lo*ee% ;0,!, (a%tName I T/mithT /,(,C ,m'lo*ee%.(a%tName 5!"M ,m'lo*ee% ;0,!, ,m'lo*ee%./tate in FEN-E,E;.EG /,(,C "rderID 5!"M "rder% ;0,!, "rderDate 4, ;,,N O01<01<93O .ND O01<31<93O

! Minder Chen, 1993~2002

Data Modeling - A0 -

Deys
" . ?e*, al%o called identi)ier, i% an .ttri$ute or a Com'o%ite .ttri$ute that can $e u%ed to uniHuel* identi)* an in%tance o) an entit* t*'e. " ,6am'le%2 ,ntit* *'e >e*
;arehou%e Product /tudent /hi' /toc? o) Product ;arehou%e Num$er Product Num$er /tudent ID or //N Name and Port o) !egi%tration Product Num$er and ;arehou%e No.

! Minder Chen, 1993~2002

Data Modeling - A1 -

Types of Dey
" Primar* >e*2 . uniHue ?e* i% an attri$ute or a %et o) attri$ute% that ha% $een u%ed $* the D4M/ a% the identi)ier o) a ta$le. " Candidate F.lternati&eG >e*2 .n attri$ute or a %et o) attri$ute% that could ha&e $een u%ed a% the 'rimar* ?e* o) a ta$le. " /econdar* FInde6G >e*2 .n attri$ute or a %et o) attri$ute% that ha% $een u%ed to con%truct the data retrie&al inde6. " Concatenated FCom$ined or Com'o%iteG >e*2 . %et o) attri$ute% that ha% $een u%ed a% the ?e*. " 5oreign >e*2 .n attri$ute or a %et o) attri$ute% that i% u%ed a% the 'rimar* ?e* in another ta$le.
! Minder Chen, 1993~2002 Data Modeling - A2 -

)urposes of 5or$ali4ation

" .&oid maintenance 'ro$lem% %uch a% #'date . " In%ert2 here ma* $e no 'lace to in%ert ne+ in)ormation. " Delete2 /ome im'ortant in)ormation +ill $e lo%t $* deletion. " #'date2 Incon%i%tenc* ma* occur $ecau%e o) the e6i%tence o) data redundanc*. " Pro&ide ma6imum )le6i$ilit* to meet )uture in)ormation need% $* ?ee'ing ta$le% corre%'onding to o$1ect t*'e% in their %im'li)ied )orm%.
! Minder Chen, 1993~2002 Data Modeling - A3 -

A Co$$on *ense Approach to 5or$ali4ation

" DonEt ru%h to 'ut all the in)ormation in one ta$le. " Create a ta$le to corre%'ond to a cla%% o) a %im'le o$1ect t*'e that %hould e6i%t $* it%el), i.e., Tone )act in one 'lace.T " Include common )ield% Flin?%G a% +a*% o) 1oining in)ormation )rom %e&eral related ta$le%. " .&oid redundanc* $* u%ing lin?% to retrie&e data )rom related ta$le%.

! Minder Chen, 1993~2002

Data Modeling - A@ -

5or$ali4ation Theory

" Normali8ation i% a 'roce%% o) %*%tematicall* $rea?ing a com'le6 ta$le into %im'ler one%. " It i% $uilt around the conce't o) normal )orm%. " . relation i% in a 'articular normal )orm i) it %ati%)ie% a %'eci)ic %et o) con%traint% %uch a% de'endencie% among attri$ute% in the relation. " 5or 6 i% an integer and 6 J 1, i) a relation i% in 6-N5 than it i% in F6-1G-N5. " 0igher order normal )orm% are u%uall* more de%ira$le than lo+er order normal )orm%. " Normali8ation 'roce%% u%uall* %tart% )rom com'le6 relation% +hich are u%uall* dra+n )rom %ome e6i%ting document% %uch a% $u%ine%% )orm%.
! Minder Chen, 1993~2002 Data Modeling - AB -

A 'usiness !or$

! Minder Chen, 1993~2002

Data Modeling - AC -

An nfor$al E;a$ple of 5or$ali4ation


" . C#/ "M,! "!D,! contain% the )ollo+ing in)ormation2
# # # # # # # # "rderNo "rderDate Cu%tNo Cu%t.ddre%% Cu%t *'e a6 otal one or more than one "rder-Item +hich ha%
* * * * * ProductNo De%cri'tion Ruantit* #nitPrice /u$total.
Data Modeling - AA -

! Minder Chen, 1993~2002

*olution
#nnormali8ed ta$le
!emo&e re'eating grou'

&Order*o9 Order)ate9 Cust*o9 CustAddress9 Cust/ype9 /a:9 !;Product*o9 )escription9 5uantity9 6nitPrice9Subtotal<

&Order*o9 Product*o9 )escription9 5uantity9 6nitPrice9 Subtotal' 1%t N5

!emo&e 'artial 5D

2nd N5
!emo&e tran%iti&e 5D

&Order*o9 Order)ate9 Cust*o9 CustAddress9 Cust/ype9 /a:

&Order*o9 Product*o9 5uantity9 6nitPrice9 Subtotal ' &Product*o9 )escription9 6nitPrice'

3rd N5
! Minder Chen, 1993~2002

&Order*o9 Order)ate9 Cust*o9 /a:9 Total &Cust*o9 CustAddress9 Cust/ype'


Data Modeling - AD -

&nnor$ali4ed !or$
" . relation that ha% multi-&alued attri$ute% Fre'eating grou'%G. " Normali8ation Proce%%2 !emo&e Multi-&alue .ttri$ute% " I) an unnormali8ed relation ! ha% a 'rimar* ?e* > and a multi-&alue attri$ute M, the normali8ation 'roce%% i%2

" ,6am'le2 .n ,m'lo*ee relation ha% an attri$ute language%'o?en. 5or %ome em'lo*ee% there ma* $e more than one language that the* can %'ea?.
,MP Fem'lo*eeID, em'Name, em'.ddre%%, Flanguage1, language2, ...GG ,MP Fem'lo*eeID, em'Name, em'.ddre%%G ,MP-(.N:#.:, Fem'lo*eeID, language, %?ill(e&elG
! Minder Chen, 1993~2002 Data Modeling - A9 -

# he multi-&alue attri$ute M %hould $e remo&ed )rom !. # . ne+ relation +ill $e created +ith F>,MG a% the 'rimar* ?e* o) the relation. # here ma* $e %ome other attri$ute% a%%ociated +ith thi% ne+ relation. # ! +ill then $e at lea%t in 1N5.

/ow Do Eou Re$o,e the Repeating %roups<


CREATE TABLE MEM_CONDITION ( MEMBER# VARCHAR2(12) CASE# VARCHAR2(16) DIAG_ARRAY_1 VARCHAR2(6) DIAG_ARRAY_2 VARCHAR2(6) DIAG_ARRAY_3 VARCHAR2(6) DIAG_ARRAY_4 VARCHAR2(6) DIAG_ARRAY_5 VARCHAR2(6) DIAG_EX_ARRAY_1 VARCHAR2(2) DIAG_EX_ARRAY_2 VARCHAR2(2) DIAG_EX_ARRAY_3 VARCHAR2(2) DIAG_EX_ARRAY_4 VARCHAR2(2) DIAG_EX_ARRAY_5 VARCHAR2(2) DRUG_ARRAY_1 VARCHAR2(12) DRUG_ARRAY_2 VARCHAR2(12) DRUG_ARRAY_3 VARCHAR2(12) DRUG_ARRAY_4 VARCHAR2(12) DRUG_ARRAY_5 VARCHAR2(12) LC_ARRAY_1 VARCHAR2(4) LC_ARRAY_2 VARCHAR2(4) LC_ARRAY_3 VARCHAR2(4) LC_ARRAY_4 VARCHAR2(4) LC_ARRAY_5 VARCHAR2(4) MEM_REVIE VARCHAR2(4) O!# VARCHAR2(4) !ROC_ARRAY_1 VARCHAR2(6) !ROC_ARRAY_2 VARCHAR2(6) !ROC_ARRAY_3 VARCHAR2(6) !ROC_ARRAY_4 VARCHAR2(6) !ROC_ARRAY_5 VARCHAR2(6) !ROV_ARRAY_1 VARCHAR2(12) !ROV_ARRAY_2 VARCHAR2(12) !ROV_ARRAY_3 VARCHAR2(12) !ROV_ARRAY_4 VARCHAR2(12) !ROV_ARRAY_5 VARCHAR2(12) REC_TY!E VARCHAR2(2) S!_ARRAY_1 VARCHAR2(4) S!_ARRAY_2 VARCHAR2(4) S!_ARRAY_3 VARCHAR2(4) S!_ARRAY_4 VARCHAR2(4) S!_ARRAY_5 VARCHAR2(4) TRANSCODE VARCHAR2(2) TT_ARRAY_1 VARCHAR2(4) TT_ARRAY_2 VARCHAR2(4) TT_ARRAY_3 VARCHAR2(4) TT_ARRAY_4 VARCHAR2(4) TT_ARRAY_5 VARCHAR2(4) VOID VARCHAR2(2) YMDE"" VARCHAR2(#) YMDEND VARCHAR2(#) YMDTRANS VARCHAR2(#) !RIORITY VARCHAR2(2) )$ NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NOT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL

! Minder Chen, 1993~2002

Data Modeling - D0 -

!unctional Dependency

" Notation2 !.Q IJ !." De)inition2 .ttri$ute - o) !elation ! i% )unctionall* de'endent on the .ttri$ute Q o) !elation ! +hen there i% each &alue o) !.- a%%ociated +ith no more than one &alue o) !.Q. !.Q and !.- ma* $e com'o%ite attri$ute%. " De%cri'tion2
# ! .- i% )unctionall* de'endent on !.Q # !.Q )unctionall* determine% !.! Minder Chen, 1993~2002 Data Modeling - D1 -

!ull 9 )artial Dependency

" !.. IJ !.4 " I) 4 i% not )unctionall* de'endent on an* %u$%et o) . Fother than . it%el)G, 4 i% )ull* de'endent on . in !. " I) 4 i% )unctionall* de'endent on a %u$%et o) . Fother than . it%el)G, 4 i% 'artiall* de'endent on . in !.

! Minder Chen, 1993~2002

Data Modeling - D2 -

!irst 5or$al !or$ 6"5!7


" . relation ! i% in the )ir%t normal )orm F1N5G i) and onl* i) all attri$ute% o) an* tu'le in ! contain onl* atomic &alue%. " Normali8ation Proce%%2
# !emo&e Partial 5unctional De'endencie% # I) ! i% in 1N5 and ha% a com'o%ite 'rimar* ?e* F>1,>2G, an attri$ute P i% )unctionall* de'endent on >1 F>1 IJ PG Fi.e., P i% 'artiall* de'endent on F>1, >2GG, the normali8ation 'roce%% i%2 # he attri$ute P %hould $e remo&ed )rom ! and a ne+ relation +ill $e created +ith >1 a% the 'rimar* ?e* and P a% a non-?e* attri$ute. # . relation that i% in 1N5 and not in 2N5 mu%t ha&e a com'o%ite 'rimar* ?e*.

" ,6am'le
# /u''lier-Part relation ha% attri$ute% %u''lierO, 'artO, Ht*, cit*, di%tance, +here F%u''lierO, 'artOG i% the ?e*. # Cit* i% 'artiall* de'endent on %u''lierO.

/#PP(I,!-P.! F%u''lierO, 'artO, Ht*, cit*, di%tanceG /#PP(I,!-P.! F%u''lierO, PartO, Ht*G /#PP(I,! F%u''lierO, cit*, di%tanceG
! Minder Chen, 1993~2002 Data Modeling - D3 -

5on-loss Deco$position
" Normali8ation i% a reduction Fdecom'o%itionG 'roce%% that re'lace% a relation $* %uita$le 'ro1ection%. ,ach o) the 'ro1ection i% a ne+ relation that i% in a )urther normali8ed )orm than the original relation. he collection o) 'ro1ection% i% eHui&alent to the original relation. " he original relation can al+a*% $e reco&ered $* ta?ing the natural 1oin o) the%e 'ro1ection%. " .n* in)ormation that can $e deri&ed )rom the original relation can al%o $e deri&ed )rom the )urther normali8ed relation%. he con&er%e i% not true. " he 'roce%% i% re&er%i$le $ecau%e no in)ormation i% lo%% in the reduction 'roce%%.

! Minder Chen, 1993~2002

Data Modeling - D@ -

Transiti,e Dependency

In a relation !, i) !.. IJ!.4 and !.4 IJ !.C then attri$ute C i% %aid to $e tran%iti&el* de'endent on attri$ute ..

! Minder Chen, 1993~2002

Data Modeling - DB -

*econd 5or$al !or$ 6F5!7


" . relation ! i% in the %econd normal )orm F2N5G i) and onl* i) it i% in 1N5 and e&er* non-?e* attri$ute i% )ull* de'endent on the 'rimar* ?e*. " Normali8ation Proce%%2 !emo&e ran%iti&e De'endencie% " I) ! i% in 2N5 and ha% t+o non-?e* attri$ute% .1 and .2 +here .2 i% )unctionall* de'endent on .1 F.1 IJ .2G. he .2 %hould $e remo&ed )rom ! and a ne+ relation +ill $e created +ith .1 a% the 'rimar* ?e* and .2 a% a non-?e* attri$ute. " ,6am'le
# /u''lier relation ha% attri$ute% %u''lierO, cit*, di%tance, +here %u''lierO i% the ?e* and di%tance to a %u''lier can $e determined $* the cit* o) the %u''lier.

/#PP(I,! F%u''lierO, cit*, di%tance, Hualit*Ule&elG /#PP(I,! F/u''lierO, cit*, Hualit*Ule&elG CI --DI/ .NC, Fcit*, di%tanceG
! Minder Chen, 1993~2002 Data Modeling - DC -

Third 5or$al !or$ 6C5!7


" . relation ! i% in the third normal )orm F3N5G i) and onl* i) the non?e* attri$ute% Fi) there i% an*G are )ull* de'endent on the 'rimar* ?e* o) ! Fi.e., ! i% in it% 2N5G and are mutuall* inde'endent. " 0euri%tic to Chec? ;hether a !elation I% in 3N5
# .ll the non-?e* attri$ute% F+hich are not multi-&alue attri$ute%G are de'endent on the F'rimar*G ?e*, the +hole ?e*, and nothing $ut the ?e*.

,6'lanation ,6'lanation " .ll the non-?e* attri$ute% ha&e atomic &alue and de'endent on the ?e* F1N5 - No multi-&alue attri$uteG, " the +hole ?e*, F2N5 - No Partiall* 5unctional De'endenc*G " and nothing $ut the ?e* F3N5 - No ran%iti&e 5unctional De'endenc*G
! Minder Chen, 1993~2002 Data Modeling - DA -

5or$ali4ation )rocess
#nnormali8ed #nnormali8ed5orm 5orm

A
!*8 !*8

=
"*8 "*8

remo?e repeating groups

remo&e 'artial de'endencie%


>*8 >*8

remo&e tran%iti&e de'endencie%


>*8 >*8

7 8

>*8 >*8

>*8 >*8

) B C )
Data Modeling - DD -

! Minder Chen, 1993~2002

5or$ali4ation: )ros and Cons


" Pro%
# !educe data redundanc* 3 %'ace reHuired # ,nhance data con%i%tenc* # ,n)orce data integrit* # !educe u'date co%t # Pro&ide ma6imum )le6i$ilit* in re%'onding ad hoc Huerie%

" Con%
# Man* com'le6 Huerie% +ill $e %lo+er $ecau%e 1oin% ha&e to $e 'er)ormed to retrie&e rele&ant data )rom %e&eral normali8ed ta$le% # Programmer%<u%er% ha&e to under%tand the underl*ing data model o) an data$a%e a''lication in order to 'er)orm 'ro'er 1oin% among %e&eral ta$le% # he )ormulation o) multi'le-le&el Huerie% i% a nontri&ial ta%?.
Data Modeling - D9 -

! Minder Chen, 1993~2002

.oin Two Tables


/,(,C Categorie%.Categor*Name, Product%.ProductName 5!"M Categorie%, Product% ;0,!, Product%.Categor*ID I Categorie%.Categor* ID

! Minder Chen, 1993~2002

Data Modeling - 90 -

Tables in Relational D'


" Identi)* Primar* >e*% and 5oreign >e*% in the )ollo+ing a$le%YYY

(D

(D

(D

! Minder Chen, 1993~2002

Data Modeling - 91 -

.oin Tables
/,(,C "rder%."rderID, "rder%.Cu%tID, (a%tName, 5ir%tname, "rder%.ItemID, De%cri'tion 5!"M Cu%tomer, "rder%, In&entor* ;0,!, Cu%tomer.Cu%tID I "rder%.Cu%tID .ND "rder%.ItemID I In&entor*.ItemID "!D,! 4- Cu%tID, "rder%.ItemID

(D

(D

! Minder Chen, 1993~2002

Data Modeling - 92 -

!oreign Deys 9 )ri$ary Deys in a *a$ple Access Database

! Minder Chen, 1993~2002

Data Modeling - 93 -

An E;a$ple of a Co$ple; Query


Plea%e li%t name and 'hone num$er o) cu%tomer% +ho ha&e ordered 'roduct num$er 00A. /,(,C cu%tomerUname, cu%tomerU'hone 5!"M cu%tomer ;0,!, cu%tomerUnum$er IN /,(,C cu%tomerUnum$er 5!"M order ;0,!, orderUno IN /,(,C orderUno 5!"M orderItem ;0,!, 'roductUnum$er I 00A
! Minder Chen, 1993~2002 Data Modeling - 9@ -

Denor$ali4ation
" he 'roce%% o) intentionall* $ac?ing a+a* )rom normali8ation to im'ro&e 'er)ormance. Denormali8ation %hould not $e the )ir%t choice )or im'ro&ing 'er)ormance and %hould onl* $e u%ed )or )ine tuning a data$a%e )or a 'articular a''lication. " !eHuirement%
# Prior normali8ation # >no+ledge o) data u%age

" 4ene)it%
# # # # # # # # # Minimi8e the need )or 1oin% !educe num$er o) ta$le% !educe num$er o) )oreign ?e*% !educe num$er o) indice% 0o+ o)ten are t+o data item% needed together 0o+ man* ro+% are in&ol&ed 0o+ &olatile i% denormali8ed data 0o+ im'ortant i% &i%i$ilit* o) data to u%er% ;hat i% the minimum re%'on%e time and )reHuenc* o) an Huer*
Data Modeling - 9B -

" >no+ledge o) Data #%age

! Minder Chen, 1993~2002

De-nor$ali4ation: An E;a$ple

!1

="IN

!2
Denormali8ation

!1 X ! 2
" ;here2

!2

# !1 FProductNo, /u''lierNo, PriceG # !2 F/u''lierNo, Name, .ddre%%, PhoneG # !1X!2 FProductNo, /u''lierNo, Name, .ddre%%, Phone, PriceG

" !2 %hould $e ?e't to 're&ent data lo%%. " Data redundanc* in !1X!2 and !2 could cau%e 'otential data incon%i%tenc* 'ro$lem% i) the redundant data in the%e t+o ta$le% are not maintained 'ro'erl*.
Data Modeling - 9C -

! Minder Chen, 1993~2002

Data Model Refine$ent and Transfor$ation


" " " " " Data Model !e)inement .%%ociati&e ,ntit* *'e !emo&ing Man*-to-Man* !elation%hi'% >e*% ran%)ormation to !elational Data$a%e%

! Minder Chen, 1993~2002

Data Modeling - 9A -

Refine$ent of a Data Model: Analysis and *i$plification

" " " " " " "

I%olated ,ntit* *'e /olitar* ,ntit* *'e "ne-to-"ne !elation%hi' !edundant !elation%hi' Multi-9alued .ttri$ute% .ttri$ute +ith .ttri$ute% Man*-to-Man* !elation%hi'

! Minder Chen, 1993~2002

Data Modeling - 9D -

solated Entity Type


" .n ,ntit* *'e that doe% not 'artici'ate in a !elation%hi'. " /ince e&er* ,ntit* *'e %hould 'artici'ate in at lea%t one !elation%hi', there e6i%t t+o alternati&e%2 # Identi)* a rele&ant !elation%hi' # !emo&e the ,ntit* *'e )rom the model

! Minder Chen, 1993~2002

Data Modeling - 99 -

*olitary Entity Type


" .n ,ntit* *'e that ha% onl* one ,ntit* In%tance. ,6am'le%2 Com'uter Center, /ale% a6, and Current "rder Num$er. /olitar* ,ntit* *'e% ma* $e too re%tricti&e. " .lternati&e%2
# Introduce another ,ntit* *'e +ith a +ider %co'e. # Com'uter Center IIJ "rgani8ation #nit # De)ine it a% an .ttri$ute o) an ,ntit* *'e. # /ale% a6 IIJ /ale% a6 o) "rder # De)ine it a% a data element in an 'arameter ta$le. . 'arameter ta$le ha% onl* one ro+. # Current "rder Num$er IIJ Current "rder Num$er o) Parameter a$le
! Minder Chen, 1993~2002 Data Modeling - 100 -

E,aluate One-to-One Relationship


" It ma* $e an unnece%%ar* relation%hi' $et+een t+o ,ntit* *'e% i) the* ha&e the %ame attri$ute and relation%hi'% Fi.e., the* are identicalG. " It %hould $e then com$ined into one ,ntit* *'e.

Ma*$e Ma*$eIncorrect Incorrect


Purcha%e !eHue%t $ecome% ha% reHue%t Purcha%e "rder

Correct Correct
Purchase Order

! Minder Chen, 1993~2002

Data Modeling - 101 -

Redundant Relationship
I% thi% relation%hi' redundantK ha% ordered

cu%tomer
'lace%

'roduct
i% ordered $*

"!D,!/
i% 'laced $* contain% ha%

order

i% 'art o)

order item

Di))erence% in ti$ing o) an entit* t*'e in it% li)e c*cle2


" Im'lemented a% %e'arate entit* t*'e% or u%e %u$t*'e% " #%e &alue o) attri$ute% or additional attri$ute% to di))erentiate them
! Minder Chen, 1993~2002 Data Modeling - 102 -

Redundant Relationship
!edundant !edundant Product i% held a% /toc? contain% Non-redundant Non-redundant i% contained in Product contain% i% held in %toc?% ;arehou%e hold%

"rder (ine

i% contained in contain%

"rder

i% 'laced $* i% contained in contain% i% contained in contain% 'lace% Cu%tomer

"rder 0i%tor*

! Minder Chen, 1993~2002

Data Modeling - 103 -

Multi-@alued Attribute
" De)inition
# .n .ttri$ute that ma* ha&e more than one &alue at a time i% called a multi&alued attri$ute. Create an ,ntit* *'e )or the multi-&alued attri$ute (anguage% %'o?en $* an ,m'lo*ee ,m'lo*eeFID, Name, Phone, (anguage%G ,m'lo*eeF111, Z=ohn /mith[, 201-999-DDDD, F,ngli%h, Chine%eGG

" /olution2
# # # #

" ,6am'le2

# # # # #

,m'lo*eeFID, Name, PhoneG ,m'lo*eeF111, Z=ohn /mith[, 210-999-DDDDG ,m'lo*eeUlanguageFID, (anguageG ,m'lo*eeUlanguageF111, ,ngli%hG ,m'lo*eeUlanguageF111, Chine%eG
Data Modeling - 10@ -

! Minder Chen, 1993~2002

Attribute with Attributes


" .n .ttri$ute that can $e de%cri$ed $* other .ttri$ute% i% called an attri$ute +ith attri$ute%. " ,6am'le2
# College Degree $* an ,m'lo*ee # F=ohn /mith ha% a College Degree in Com'uter /cience% )rom :eorge Ma%on #ni&er%it*G

" /olution2
# Create an ,ntit* *'e to a&oid an .ttri$ute +ith .ttri$ute%. # .dd ne+ attri$ute% to the e6i%ting ,ntit* *'e.
! Minder Chen, 1993~2002 Data Modeling - 10B -

Associati,e Entity Type


" .n .%%ociati&e ,ntit* *'e i% an ,ntit* *'e +ho%e e6i%tence i% meaning)ul onl* i) it 'artici'ate% in %e&eral FJI2G !elation%hi' *'e% at the %ame time. " .%%ociati&e ,ntit* *'e% are o)ten introduced to re're%ent additional in)ormation in man*-toman* !elation%hi'% or to decom'o%e a man*-toman* !elation%hi' into t+o one-to-man* !elation%hi'%. " .%%ociati&e ,ntit* *'e% are al%o u%ed to re're%ent n-ary !elation%hi'% in a $inar* data model.

! Minder Chen, 1993~2002

Data Modeling - 10C -

Re$o,e Many-to-Many Relationship


:i&en :i&en "rder contain% $elong%-to Product

;h*K ;h*K
here i% no 'lace to attach .ttri$ute% that are reHuired to de%cri$e a man*-to-man* !elation%hi'. " It i% di))icult to tran%late man*-to-man* !elation%hi'% into relational ta$le% automaticall*. "

0o+K 0o+K . man*-to-man* relation%hi' can $e decom'o%ed into t+o

one-to-man* !elation%hi'% $* creating an Associati,e Entity Type $et+een the e6i%ting t+o ,ntit* *'e%.
"rder
contain% $elong% to ha%

"rder (ine

i% contained in

Product

! Minder Chen, 1993~2002

Data Modeling - 10A -

Re$o,e Many-to-Many Relationships: E;ercises


!emo&e the man*-to-man* relation%hi' )rom the )ollo+ing ,! diagram%
FaG Product ha%-%ource% o))er% /u''lier

F$G /tudent

ta?e% i%-ta?en-$*

Cour%e

FcG

con%i%t%-o)

Part

i%-contained-in
Data Modeling - 10D -

! Minder Chen, 1993~2002

'ills of Material
Part con%i%t%-o) i%-a-com'onent-in 4 . C

2
,

1
5

Product /tructure

Product-/tructureFParent Part No, Child Part No, Ruantit*G . . 4 4 C C


! Minder Chen, 1993~2002

4 C D , D 5

2 1 1 3 2 2
Data Modeling - 109 -

&sing an Associati,e Entity Type to Represent an 5-ary Relationship

in&ol&ed in 'roduct Product u%age

in&ol&ed in 'roduct u%age Pro1ect in&ol&ed in 'roduct u%age /u''lier

Product Product#%age #%agei% i%an an.%%ociati&e .%%ociati&e,ntit* ,ntit* *'e *'e)or )ora a3-ar* 3-ar*!elation%hi'. !elation%hi'.

i% u%ed in Product Product #%age

u%e%

Pro1ect

%u''lie% /u''lier
! Minder Chen, 1993~2002 Data Modeling - 110 -

Translate Data Models to Relational Tables


:i&en :i&en "rder
contain% $elong% to ha%

"rder (ine

i% contained in

Product

>e*2 "rderO .ttri$ute2 "rder date Cu%tomer ID /ale Per%on ID

>e*2 "rderOMProductO .ttri$ute2 Ruantit* #nit Price

>e*2 ProductO .ttri$ute2 De%cri'tion Rt*-on-hand #nit Price

!elational !elational a$le% a$le%Created Created


C!,. , .4(, "!D,! F"rderNo C0.!F10G "rderDate D. ,, Cu%tomerID C0.!F10G, /alePer%onID C0.!F10GGL
! Minder Chen, 1993~2002

N" N#((,

Data Modeling - 111 -

Transfor$ation of Data Models to Relational Database Tables

"

he entire, or 'art o), a data Fentit*-relation%hi'G model can $e tran%lated into a normali8ed data$a%e de%ign.

" "$1ect% Created


# .t mo%t one relational data$a%e # "ne or more relation% Fta$le%G # Data %tructure% FDD(G re're%enting the element% Fattri$ute%G and the 'rimar* ?e* o) each relation # Data t*'e o) each data element%

! Minder Chen, 1993~2002

Data Modeling - 112 -

/euristics of Transfor$ation
" . ta$le i% created )or each ,ntit* *'e in the ,! diagram. " . ta$le i% created )or each multi-&alued attri$ute. " !elation%hi' *'e% are im'lemented a% ta$le% or a% )oreign ?e*% in other ta$le%. " Man*-to-man* relation%hi' t*'e% are tran%lated into ta$le%. " 5oreign ?e*% are u%ed )or im'lementing one-to-one and one-toman* !elation%hi' *'e%. " 5or one-to-man* !elation%hi' *'e%, the )oreign ?e* i% 'laced in the ta$le that re're%ent% the ,ntit* *'e on the Tman*T end o) the !elation%hi' *'e. " 5or identifying one-to-man* !elation%hi' *'e%, the P> o) the ToneT ta$le migrate to the Tman*T ta$le a% a 5> and the 5> i% al%o 'art o) the P> o) the Tman*T ta$le. " 5or non-identifying one-to-man* !elation%hi' *'e%, the P> o) the ToneT ta$le migrate to the Tman*T ta$le a% a 5> and the 5> i% a non-?e* attri$ute o) the Tman*T ta$le.
Data Modeling - 113 -

! Minder Chen, 1993~2002

)owerDesign: Data Architect

:eneration<!e&er%e ,ngineering2 CD-. PD-

:eneration 3 !e&er%e ,ngineering2

:eneration 3 !e&er%e ,ngineering2

Database Structure Triggers / Stored Procedures

E tended ,ttributes Database Structure


arget @:( ool

htt'2<<+++.'o+er%o)t.com<
Data Modeling - 11@ -

arget D4M/
! Minder Chen, 1993~2002

)owerDesigner

! Minder Chen, 1993~2002

Data Modeling - 11B -

A *a$ple Conceptual Data Model


Di&i%ion Di&i%ion num$er Di&i%ion name Di&i%ion addre%% eam eam num$er /'ecialit*

Conce'tual Data Model Pro1ect 2 Management Model 2 Pro1ect Management .uthor 2 #%er 9er%ion C.6 A<21<9D
Cu%tomer Cu%tomer num$er Cu%tomer name Cu%tomer addre%% Cu%tomer acti&it* Cu%tomer tele'hone Cu%tomer )a6

I% mem$er o) %u'er&i%e% ,m'lo*ee ,m'lo*ee num$er 5ir%t name (a%t name ,m'lo*ee )unction ,m'lo*ee %alar* I% manager o)

#%e%

/u$contract

.cti&it* /tart date ,nd date

Material Material num$er Material name Material t*'e Partici'ate /tart date ,nd date

Pro1ect Pro1ect num$er Pro1ect name Pro1ect la$el

a%? a%? name a%? co%t

com'o%e%

com'o%ed o)

! Minder Chen, 1993~2002

Data Modeling - 11C -

5otations
Employee Employee number First name Last name Employee function Employee salary

,nt it*

!elation%hi'

Division Division number Division name Division address

Employee Employee number First name Last name Employee function Employee salary

"ne-to-man*
! Minder Chen, 1993~2002 Data Modeling - 11A -

More on Relationships
,m'lo*ee ,m'lo*ee num$er 5ir%t name (a%t name ,m'lo*ee )unction ,m'lo*ee %alar* i% a mem$er o) eam mem$er
Man*-to-man* cardinalit*

eam num$er /'ecialt*

Pro1ect Pro1ect num$er Pro1ect name Pro1ect la$el

a%? a%? name a%? co%t

. 'ro1ect Econtain%N one or more ta%?%, and a ta%?E% e6i%tence i% dependent on the 'ro1ect.

! Minder Chen, 1993~2002

Data Modeling - 11D -

Ad,anced Concepts
Material Material num$er Material name Material t*'e
com'o%e% com'o%ed o)

.ccount .ccount Num$er Name

/a&ing% !ate

Chec?ing 5ee% ,m'lo*ee ,m'lo*ee num$er 5ir%t name (a%t name ,m'lo*ee )unction ,m'lo*ee %alar*

/u$t*'e

!e)le6i&e relation%hi'
Data Modeling - 119 -

! Minder Chen, 1993~2002

Define Entities

! Minder Chen, 1993~2002

Data Modeling - 120 -

Define Attributes

! Minder Chen, 1993~2002

Data Modeling - 121 -

Chec( )ara$eters

! Minder Chen, 1993~2002

Data Modeling - 122 -

Relationship Definition

! Minder Chen, 1993~2002

Data Modeling - 123 -

Dependent 6 dentifying Relationship7


" Chec? the $o6 to indicate a de'endent relation%hi'. T"ne to man*T and Tmandator*T are automaticall* cho%en a% the cardinalit* and o'tionalit*. " .t the 'h*%ical data model le&el, the 'arent entit* t*'eE% 'rimar* ?e* FP>G +ill $ecome 'art o) the de'endent child entit* t*'eE% P>. It i% al%o a )oreign ?e*.

! Minder Chen, 1993~2002

Data Modeling - 12@ -

nheritance 6*uper-Type and *ub-Type7

! Minder Chen, 1993~2002

Data Modeling - 12B -

%enerate )hysical Data Model

! Minder Chen, 1993~2002

Data Modeling - 12C -

)hysical Data Model


Conce'tual Conce'tual Data DataModel Model

Di&i%ion Di&i%ion num$er $elong% to Di&i%ion name Di&i%ion addre%%

,m'lo*ee ,m'lo*ee num$er 5ir%t name (a%t name ,m'lo*ee )unction ,m'lo*ee %alar*

Ph*%ical Ph*%ical Data DataModel Model

! Minder Chen, 1993~2002

ran%)ormation

Do not de)ine 5> a% an attri$ute.

DI9I/I"N DI9N#M \'?J DI9N.M, DI9.DD!

DI9N#M I DI9N#M

,MP("-,, ,MPN#M \'?J DI9N#M \)?J ,MP5N.M ,MP(N.M ,MP5#NC ,MP/.(

DI9N#M automaticall* migrate% a% a )oreign ?e*.


Data Modeling - 12A -

Dependent Relationship
Conce'tual Conce'tual Data DataModel Model

Pro1ect Pro1ect num$er Pro1ect name Pro1ect la$el

a%? a%? name a%? co%t

Ph*%ical Ph*%ical Data DataModel Model

! Minder Chen, 1993~2002

ran%)ormation

P!"=,C P!"N#M \'?J C#/N#M \)?J ,MPN#M \)?J .C 4,: .C ,ND P!"N.M, P!"(.4(

P!"N#M I P!"N#M

./> P!"N#M \'?,)?J />N.M, \'?J .C 4,: .C ,ND />C"/

Data Modeling - 12D -

)hysical Data Model


DI9I/I"N DI9N#M \'?J DI9N.M, DI9.DD! ,.M ,.N#M \'?J ,./P, C#/ "M,! C#/N#M \'?J C#/N.M, C#/.DD! C#/.C C#/ ,( C#/5.Q

Ph*%ical Data Model Pro1ect2Management Model 2 Pro1ect Management .uthor 2#%er 9er%ionC.6 A<21<9D

,.N#M I ,.N#M

M,M4,! ,.N#M \'?,)?J ,MPN#M \'?,)?J


DI9N#M I DI9N#M ,MPN#M I ,MPN#M

,MP("-,UM. ,!I.( M. ,!I.(.M. N.M, charF30G P!"=.,MP("-,,.,MPN#M numericFBG P!"=.,MP("-,,.,MP5N.M charF30G P!"=.,MP("-,,.,MP(N.M charF30G P!"=.,MP("-,,.,MP5#NC charF30G M. ,!I.( P!"=.,MP("-,, #/,D

C#/N#M I C#/N#M

#/,D M. N#M \'?,)?J ,MPN#M \'?,)?J


,MPN#M I ,MPN#M M. N#M I M. N#M

,MPN#M I ,MPU,MPN#M

M. ,!I.( M. N#M \'?J M. N.M, M. -P,


M. N#M I CPDUM. N#M N#M I CPNUM. N#M

,MP("-,, ,MPN#M \'?J ,MPU,MPN#M \)?J DI9N#M \)?J ,MP5N.M \a?J ,MP(N.M \a?J ,MP5#NC \a?J ,MP/.(

,MPN#M I ,MPN#M

P!"=,C P!"N#M \'?J C#/N#M \)?J ,MPN#M \)?J .C 4,: .C ,ND P!"N.M, P!"(.4(

,MPN#M I ,MPN#M

P!"N#M I P!"N#M

C"MP"/, CPDUM. N#M \'?,)?J CPNUM. N#M \'?,)?J

P.! ICIP. , P!"N#M \'?,)?J />N.M, \'?,)?J ,MPN#M \'?,)?J P.!4,: P.!,ND

P!"N#M I P!"N#M />N.M, I />N.M,

./> P!"N#M \'?,)?J />N.M, \'?J .C 4,: .C ,ND />C"/

! Minder Chen, 1993~2002

Data Modeling - 129 -

References 6Relationships at the )hysical Data Model7

! Minder Chen, 1993~2002

Data Modeling - 130 -

Referential ntegrity
" he arro+ i% 'ointing )rom the ta$le containing the )oreign ?e* to the ta$le +here the )oreign ?e* i% u%ed a% a 'rimar* ?e*.

! Minder Chen, 1993~2002

Data Modeling - 131 -

Deletion Rules

" #'date Con%traint% " Delete Con%traint% #None #!e%trict #Ca%cade #/et null #/et De)ault

! Minder Chen, 1993~2002

Data Modeling - 132 -

%eneration of Oracle *Q+ D++


-- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Data$ a%e name2 P!"=,C -- D4M/ name2 "!.C(, 9er%ion D -- Created on2 A<21<9D D2B9 PM -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 DI9I/I"N -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le .DMIN.DI9I/I"N F DI9N#M numericFBG n ot null co n%traint C>CUDI9N#MUDI9I/I"N chec? FDI9N#M JI E1EG, DI9N.M, charF30G not n ull, DI9.DD! charFD0G null , con%traint P>UDI9I/I"N ' rimar* ?e* FDI9N#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 C#/ "M,! -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.C#/ "M,! F C#/N#M numericFBG n ot null co n%traint C>CUC#/N#MUC#/ "M,! chec? F C#/N#M JI E1EG, C#/N.M, ch arF30G not nu ll, C#/.DD! ch arFD0G not nu ll, C#/.C charFD0G null , C#/ ,( charF12G nu ll , C#/5.Q charF12G n ull , con%traint P>UC#/ "M,! 'rimar* ?e* FC#/N#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 ,.M -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=. ,.M F ,.N#M numericFBG not null co n%traint C>CU ,.N#MU ,.M ch ec? F ,.N#M JI E1EG, ,./P, charFD0G nu ll , con%traint P>U ,.M 'rimar* ?e* F ,.N#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 M. ,!I.( -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.M. ,!I.( F M. N#M numericFBG not nu ll co n%traint C>CUM. N#MUM. ,!I.( ch ec? FM. N#M JI E1EG, M. N.M, charF30G not n ull, M. -P, charF30G no t null, con%traint P>UM. ,!I.( 'rimar* ?e* FM. N#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 ,MP( "-,, -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.,MP("-,, F ,MPN#M numericFBG n ot null co n%traint C>CU,MPN#MU,MP("-,, ch ec? F ,MPN#M JI E1EG, ,MPU,MPN#M n umericFBG null , DI9N#M numericFBG n ot null, ,MP5N.M ch arF30G null , ,MP(N.M ch arF30G not nu ll, ,MP5#NC charF30G n ull , ,MP/.( n umericFD,2G null , con%traint P>U,MP( "-,, 'rimar* ?e* F,MPN#MG, con%traint .>U,MPU.>1U,MP("-,, un iHue F,MP(N.M, ,MP5 N.M, ,MP5#NCG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 C0I,5 U5 > -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.C0I,5U5> on P!"=.,MP("-,, F,MPU,MPN#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 4,("N:/U "U5 >2 -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.4,( "N:/U "U5 >2 on P!"=.,MP("-,, FDI9N#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 P!"=,C -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.P!"=,C F P!"N#M numericFBG n ot null co n%traint C>CUP!"N#MUP!"=,C chec? F P!"N#M JI E1EG, C#/N#M numericFBG n ot null, ,MPN#M numericFBG n ull , .C 4,: time%tam' null co n%traint C>CU.C 4,:UP!"=,C chec? F .C 4,: i% nu ll or FFacti&it*.$ egind ate \ acti&it*.enddateGGG, .C ,ND time%tam' null co n%traint C>CU.C ,NDUP!"=,C chec? F .C ,ND i% nu ll or FFacti&it*.$ egind ate \ acti&it*.enddateGGG, P!"N.M, ch arF30G not nu ll, P!"(.4( charFD0G n ull , con%traint P>UP!"=,C 'rimar* ?e* FP!"N#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 /#4C"N !.C U5 > -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=./#4C"N !.C U5> on P!"=.P!"=,C FC#/N#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 I/U!,/P"N/I4( ,U5"!U5> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.I/U!,/P"N/I4( ,U5"!U5> on P!"=.P!"=,C F,MPN#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 ./> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=. ./> F P!"N#M numericFBG n ot null, />N.M, charF30G n ot null, .C 4,: time%tam' null co n%traint C>CU.C 4,:U ./> chec? F.C 4,: i% nu ll or FFacti&it*.$ egind ate \ acti&it*.enddateGGG, .C ,ND time%tam' null co n%traint C>CU.C ,NDU ./> chec? F.C ,ND i% nu ll or FFacti&it*.$ egind ate \ acti&it*.enddateGGG, />C"/ numericFD,2G not nu ll, con%traint P>U ./> 'rimar* ?e* FP!"N#M, />N.M,G, con%traint C> U ./> ch ec? F Fta%?.$eg in date \ minF' artici' ate.$egindateG an d ta%?.enddate \ ma6F'artici'ate.enddateGGG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 4,("N:/U "U5 > -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.4,( "N:/U "U5 > on P!"=. ./> FP!"N#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 P.! ICIP. , -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.P.! ICIP. , F P!"N#M numericFBG n ot null, />N.M, charF30G n ot null, ,MPN#M numericFBG n ot null, P.!4,: time%tam' null co n%traint C>CUP.!4,:UP.! ICIP chec? FP.!4,: i% null o r FFFta%?.$egindate \ minF'artici'ate.$eg in dateG an d ta%?.enddate \ ma6F'artici'ate.enddateGG an d F'artici'ate.$eg in date \ 'artici' ate.enddateGGGG, P.!,ND time%tam' null co n%traint C>CUP.!,NDUP.! ICIP chec? FP.!,ND i% null o r FFFta%?.$egindate \ minF'artici'ate.$eg in dateG an d ta%?.enddate \ ma6F'artici'ate.enddateGG an d F'artici'ate.$eg in date \ 'artici' ate.enddateGGGG, con%traint P>UP.! ICIP. , 'rimar* ?e* FP!"N#M, />N.M,, ,MPN#MG, con%traint C> UP.! ICIP. , chec? F FFta%?.$egindate \ minF'artici'ate.$egind ateG an d ta%?.enddate \ ma6F'artici'ate.enddateGG an d F'artici'ate.$eg in date \ 'artici' ate.enddateGGG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 ;"!>/U"NU5> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.;"!>/U"NU5> on P!"=. P.! ICIP. , F,MPN#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 I/UD"N,U4-U5 > -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.I/UD"N,U4-U5> on P!"=. P.! ICIP. , FP!"N#M a%c, />N.M, a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 M,M4,! -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.M,M4,! F ,.N#M numericFBG not null, ,MPN#M numericFBG n ot null, con%traint P>UM,M4,! ' rimar* ?e* F ,.N#M, ,MPN#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 M,M4,!U5> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.M,M4,!U5> on P!"=.M,M4,! F ,.N#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 I/UM,M4,!U"5U5 > -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.I/UM,M4,!U"5U5> on P!"=.M,M4,! F,MPN#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 #/,D -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.#/,D F M. N#M numericFBG not nu ll, ,MPN#M numericFBG n ot null, con%traint P>U#/,D 'rimar* ?e* FM. N#M, ,MPN#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 #/,DU5> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.#/,DU5> on P!"=.#/,D FM. N#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 #/,/U5> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.#/,/U5> on P!"=.#/,D F,MPN#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -a$le2 C"MP"/, -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ta$le P!"=.C"MP"/, F CPDUM. N#M numericFBG not null, CPNUM. N#M numericFBG not null, con%traint P>UC"MP"/, ' rimar* ?e* FCPDUM. N#M, CPNUM. N#MG G < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 C"MP"/,/U5> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.C"MP"/,/U5> o n P!"=.C"MP"/, FCPDUM. N#M a%cG < -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII -- Inde62 C"MP"/,DU"5U5> -- IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII create ind e6 P!"=.C"MP"/,DU"5U5> on P!"=.C"MP"/, FCPNUM. N#M a%cG < alter ta$le P!"=.,MP( "-,, add con%train t 5>U,MP("-,,UC0I,5U,MP("-,, )oreign ?e* F,MPU,MPN#MG re)erence% P!"=.,MP("-,, F,MPN#MG < alter ta$le P!"=.,MP( "-,, add con%train t 5>U,MP("-,,U4,("N:/U UDI9I/I"N )o reign ?e* FDI9N#MG re)erence% .DMIN.DI9I/I"N FDI9N#MG < alter ta$le P!"=.P!"=,C add con%train t 5>UP!"=,C U/#4C"N !.UC#/ "M,! )o reign ?e* FC#/N#MG re)erence% P!"=.C#/ "M,! FC#/N#MG < alter ta$le P!"=.P!"=,C add con%train t 5>UP!"=,C UI/U!,/P"NU,MP("-,, )oreign ?e* F,MPN#MG re)erence% P!"=.,MP("-,, F,MPN#MG < alter ta$le P!"=. ./> add con%train t 5>U ./>U4,("N:/U UP!"=,C re)erence% P!"=.P!"=,C FP!"N#MG < )oreig n ?e* FP!"N#MG

alter ta$le P!"=.P.! ICIP. , add con%train t 5>UP.! ICIPU;"!>/U"NU,MP("-,, )oreign ?e* F,MPN#MG re)erence% P!"=.,MP("-,, F,MPN#MG < alter ta$le P!"=.P.! ICIP. , add con%train t 5>UP.! ICIPUI/UD"N,U4U ./> )oreign ?e* FP!"N#M, />N.M,G re)erence% P!"=. ./> FP!"N#M, />N.M,G < alter ta$le P!"=.M,M4,! add con%train t 5>UM,M4,!UM,M4,!U ,.M )oreig n ?e* F ,.N#MG re)erence% P!"=. ,.M F ,.N#MG < alter ta$le P!"=.M,M4,! add con%train t 5>UM,M4,!UI/UM,M4,!U,MP("-,, )oreign ?e* F,MPN#MG re)erence% P!"=.,MP("-,, F,MPN#MG < alter ta$le P!"=.#/,D add con%train t 5>U#/,DU#/,DUM. ,!I.( )oreig n ?e* FM. N#MG re)erence% P!"=.M. ,!I.( FM. N#MG < alter ta$le P!"=.#/,D add con%train t 5>U#/,DU#/,/U,MP( "-,, )oreig n ?e* F,MPN#MG re)erence% P!"=.,MP("-,, F,MPN#MG < alter ta$le P!"=.C"MP"/, add con%train t 5>UC"MP"/,UC"MP"/,/UM. ,!I.( )o reign ?e* FCPDUM. N#MG re)erence% P!"=.M. ,!I.( FM. N#MG < alter ta$le P!"=.C"MP"/, add con%train t 5>UC"MP"/,UC"MP"/,DUUM. ,!I.( )oreign ?e* FCPNUM. N#MG re)erence% P!"=.M. ,!I.( FM. N#MG <

! Minder Chen, 1993~2002

Data Modeling - 133 -

Referential ntegrity
alter ta$le P!"=.,MP("-,, add con%traint 5>U,MP("-,,UC0I,5U,MP("-,, )oreign ?e* F,MPU,MPN#MG re)erence% P!"=.,MP("-,, F,MPN#MG < alter ta$le P!"=.,MP("-,, add con%traint 5>U,MP("-,,U4,("N:/U UDI9I/I"N )oreign ?e* FDI9N#MG re)erence% .DMIN.DI9I/I"N FDI9N#MG < alter ta$le P!"=.P!"=,C add con%traint 5>UP!"=,C U/#4C"N !.UC#/ "M,! )oreign ?e* FC#/N#MG re)erence% P!"=.C#/ "M,! FC#/N#MG < alter ta$le P!"=.P!"=,C add con%traint 5>UP!"=,C UI/U!,/P"NU,MP("-,, )oreign ?e* F,MPN#MG re)erence% P!"=.,MP("-,, F,MPN#MG < alter ta$le P!"=. ./> add con%traint 5>U ./>U4,("N:/U UP!"=,C )oreign ?e* FP!"N#MG re)erence% P!"=.P!"=,C FP!"N#MG <

! Minder Chen, 1993~2002

Data Modeling - 13@ -

)hysical Database Design Acti,ities


De)ine a$le% 3 Column% De)ine >e*% Identi)* Critical ran%action% .dd Column%2
" !edundant column% " Deri&ed data column%

Mani'ulate a$le%2
" Colla'%e ta$le% " /u'ert*'e% 3 %u$t*'e%

.dd a$le%2
" Deri&ed data ta$le%

0andle Integrit* I%%ue%2


" !o+ uniHuene%% 3 Domain re%triction% " !e)erential integrit* 3 :enerate %eHuence num$er% " Deri&ed and redundant data

/ource2 :illete, !o$, etc., )hysical Database Design for *ybase *Q+ *er,er, Prentice 0all, 199B.

Controlling .cce%%
Manage "$1ect%2
" /i8e% " Placement Data Modeling - 13B -

! Minder Chen, 1993~2002

Architecture of Data -arehouse


Data ;arehou%e
Cor'orate "'erational Data$a%e Metadata In)o. Director* /ummari8ed ,nd #%er .cce%% and "(.P )rontend ool%

Data !e'lication 3 Clean%ing

Deri&ed

Detailed Pa%t

In)ormational Data$a%e

Pro1ecte Current d

Data 4ridging< ran%)ormati on


! Minder Chen, 1993~2002

" Data e6traction " Data )iltering " a$le 1oining " ran%lation " !e-5ormatting

" " " "

,I/ D// !e'ort ;riter% /'read%heet%

Data Modeling - 13C -

Operational ,s> nfor$ational Databases


Characteri%tic%
Data Content Data organi8ation% Data 9olatilit* Data normali8ation .cce%% )reHuenc* Data #'date #%age !e%'on%e ime
! Minder Chen, 1993~2002

"'erational Data$a%e
Current &alue .''lication $* a''lication D*namic 5ull* normali8ed )or tran%action 'roce%%ing 0igh #'dated on a record and )ield $a%i% 0ighl* %tructured tran%action 'roce%%ing /u$-%econd to 2-3 %econd%

In)ormational Data$a%e
.rchi&al data, %ummari8ed data, calculated data /u$1ect area% acro%% enter'ri%e /tatic until re)re%hed =oined &ie+% %uita$le )or $u%ine%% anal*%i% (o+ - Medium .cce%% onl*L no direct u'date 0ighl* un%tructured, heuri%tic or anal*tical 'roce%%ing /e&eral %econd% to minute%
Data Modeling - 13A -

,6cel Pi&ot a$le ;i8ard

!elational 9ie+

Multidimen%ional 9ie+
! Minder Chen, 1993~2002 Data Modeling - 13D -

Di$ensional Model
Product
" " " " " >e* Name De%cri'tion /i8e Price

/ale Product >e* Mar?et >e* Promotion >e* ime >e*


" " " " Dollar% #nit% Price Co%t

Mar?et !egion
" " " " " >e* De%cri'tion Di%trict !egion Demogra'hic%

Promotion
" " " " >e* De%cri'tion Di%count Media

ime
" " " " >e* ;ee?da* 0olida* 5i%cal

!egion

Product

! Minder Chen, 1993~2002

ime

Data Modeling - 139 -

Modeling a Data -arehouse


" MDM2 Multidimen%ional Modeling
# . logical model o) $u%ine%% in)ormation # ,a%* to under%tand # .''lica$le to relational and multidimen%ional data$a%e% # ,6tremel* u%e)ul )or anal*%i% # . tried-and-te%ted techniHue%

" ;h*K
# .n "( P F"n-(ine ran%action Proce%%G de%ign o) an order 'roce%%ing %*%tem ma* ha&e do8en% or hundred% o) ta$le%. It $ecome% di))icult )or $u%ine%% manager% to under%tand the de%ign in order to anal*8e the data.
! Minder Chen, 1993~2002 Data Modeling - 1@0 -

Approach " De%igned around numeric data2


# # # # &alue% count% +eight% occurrence

" .n e6am'le o) a MDM 'ro$lem %tatement2


# T;hat i% m* 'ro)ita$ilit* $* cu%tomer o&er time, $* organi8ationKT

! Minder Chen, 1993~2002

Data Modeling - 1@1 -

The Classic *tar *che$a


Mar?et Dimen%ion Mar?et ID de%cri'tion region %tate di%trict cit* ,ach dimen%ion i% de%cri$ed $* it% o+n ta$le and the )act% are arranged in a %ingle large ta$le +ith a concatenated 'rimar* ?e* com'ri%e% the indi&idual ?e*% o) each dimen%ion. 5act a$le Mar?et ID Product ID Period ID dollar% unit% 'rice Period Dimen%ion Period ID de%cri'tion *ear Huarter month current )lag re%olution %eHuence

Product Dimen%ion Product ID de%cri'tion %u''lier ID $rand color %i8e


! Minder Chen, 1993~2002

Data Modeling - 1@2 -

*now !la(e *tructure


&rand &rand identifier 3pk4 int &rand name char5678
&rand identifier 0 &rand identifier

Product Product identifier 3pk4 &rand identifier 3fk4 Product description Product category Product unit price

int int char5978 char5678 int

Customer Customer identifier 3pk4 Customer name Customer address Customer activity Customer phone number Customer fa number

int char5678 char5978 char5978 char5:;8 char5:;8 1ear identifier 1ear name 1ear 3pk4 int char5678

Customer identifier 0 Customer identifier Product identifier 0 Product identifier 1ear identifier 0 1ear identifier

Sale Time identifier Customer identifier Store identifier Product identifier Sale total Sale revenu 3fk4 3fk4 3fk4 3fk4 int int int int real real

2uarter 2uarter identifier 3pk4 int 1ear identifier 3fk4 int 2uarter name char5:78
2uarter identifier 0 2uarter identifier

Country Country identifier 3pk4 int Country name char5978

Country identifier 0 Country identifier

-onth -onth identifier 3pk4 int 2uarter identifier 3fk4 int -onth name char5:78
-onth identifier 0 -onth identifier

+egion +egion identifier 3pk4 int Country identifier 3fk4 int +egion name char5678
+egion identifier 0 +egion identifier

Store identifier 0 Store identifier Time identifier 0 Time identifier

)eek )eek identifier 3pk4 int -onth identifier 3fk4 int )eek name char5678 )eek number in year int
)eek identifier 0 )eek identifier

Store Store identifier +egion identifier Store name Store address Store manager Store phone number Store F,= number Store financial services type Store photo services type

3pk4 int 3fk4 int char5<78 char5978 char5678 char5;78 char5;78 char5:78 char5:78

Day )eek identifier 3fk4 Time identifier 3pk4 Date Day of >eek Day number in month

int int datetime char5678 int

! Minder Chen, 1993~2002

Data Modeling - 1@3 -

*teps to 'uild MDM


" Pic? a $u%ine%% %u$1ect area
# ;ee?l* %ale% re'ort%, monthl* )inancial %tatement%, in%urance claim co%t%.

" .%?ing %i6 )undamental Hue%tion%2


# ;hat $u%ine%% 'roce%% i% $eing modeledK # .t +hat le&el o) detail Fgranularit*G i% Tacti&eT anal*%i% conductedK # ;hat do the mea%ure% ha&e in common Fthe Tdimen%ion%TGK # ;hat are the dimen%ion%E attri$ute%K # .re the attri$ute% %ta$le or &aria$le o&er time and i% their Tcardinalit*T $ounded or un$oundedK

! Minder Chen, 1993~2002

Data Modeling - 1@@ -

ssues " .cti&e anal*%i%


# Mechanical mani'ulation2 Pi&oting, Drilling do+n, :ra'hing # .gent-$a%ed mani'ulation2 .lert re'orting, e6ce'tion re'orting # ;or?)lo+ mani'ulation2 Pu$li%hing, di%tri$uting document%.

" Cardinalit* mean% Tho+ man*T


# . relational data$a%e u%uall* ha% Tun$oundedT cardinalit* # . multidimen%ional data$a%e u%uall* ha% T$oundedT cardinalit*. Com'lete reorgani8ation i% needed to change cardinalit*.
! Minder Chen, 1993~2002 Data Modeling - 1@B -

dept?id 0 parent?id dept dept?id int parent?id int name varchar5;<<8 description te t date?changed datetime pfid 0 pfid product?variant sku int pfid varchar5678 attribute7 tinyint attribute: tinyint attribute; tinyint attribute6 tinyint attribute@ tinyint

. Data Model )or an ,lectronic Commerce .''lication


dept?id 0 dept?id pfid 0 pfid product?attribute pfid varchar5678 attribute?id tinyint attribute?inde tinyint attribute?value varchar5;78 pfid 0 pfid promo?cross pfid varchar5678 related?pfid varchar5678 description varchar5;<<8 pfid 0 pfid promo?upsell pfid varchar5678 related?pfid varchar5678 description varchar5;<<8

product?family pfid varchar5678 dept?id int manufacturer?id int name varchar5;<<8 short?description varchar5;<<8 long?description te t image?filename varchar5;<<8 intro?date datetime date?changed datetime list?price int monogramable tinyint

pfid 0 pfid

shopper sku 0 sku shopper?id char56;8 order?id 0 order?id created datetime name varchar5;6<8 pass>ord varchar5;78 street varchar5<78 city varchar5<78shopper?id 0 shopper?id state varchar5678 receipt Cip varchar5:<8 order?id char5;A8 country varchar5;78 shopper?id char56;8 phone varchar5:A8 total int email varchar5<78 status tinyint date?entered datetime date?changed datetime marshalled?receipt image shopper?id 0 shopper?id basket shopper?id char56;8 date?changed datetime marshalled?order image

receipt?item pfid varchar5678 sku int order?id char5;A8 ro>?id int Buantity int adjusted?price int promo?price promo?name varchar5;<<8 promo?type int promo?description te t promo?rank int active int date?start datetime date?end datetime shopper?all int shopper?column varchar5A@8 shopper?op varchar5;8 shopper?value varchar5A@8 cond?all int cond?column varchar5A@8 cond?op varchar5;8 cond?value varchar5A@8 cond?basis char5:8 cond?min int a>ard?all int a>ard?column varchar5A@8 a>ard?op varchar5;8 a>ard?value varchar5A@8 a>ard?ma int disjoint?cond?a>ard int disc?type char5:8 disc?value realData Modeling

! Minder Chen, 1993~2002

- 1@C -

.ttri$ute 0 o) ')id 1@ i% %i8e and the attri$ute &alue 1 i% :rande and 2 i% all and 3 i% /hort

! Minder Chen, 1993~2002

Data Modeling - 1@A -

-eb-based 'uild-To-Order Application

! Minder Chen, 1993~2002

Data Modeling - 1@D -

Data Model for 'uild-To-Order Application

! Minder Chen, 1993~2002

Data Modeling - 1@9 -

http://www.oracle.com/tools/jdeveloper/documents/jsptwp/index.html?content.html

.uction ;e$ /iteE% Data Model


! Minder Chen, 1993~2002 Data Modeling - 1B0 -

You might also like