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

Learning Data M odelling by Example Chapter 1) Data M odelling Windsor Castle - Part 1 1 Williams | Learn Modeling by Example

Learn Data M odelling by Example

Barry Williams

Williams | Learn Data Modeling by Example - Part 1 2

Part 1 - Table of Contents


Part 1 - Table of Contents Wel!ome 1 Data Modeling at Windsor Castle in England 2 Data Modeling in Denmar# " Data Modeling in T%r#ey ' (ome Basi! Con!epts ) + Database for a ,ideo -ame 2 " " 2$ "& )* *2

First Edition: London, 2011 ISBN-13: 978-1466237414

Williams | Learn Data Modeling by Example - Part 1 "

Welcome
This is Part 1 o o!r "oo# has "$$n %rod!&$d in r$s%ons$ to a n!'"$r o r$(!$sts ro' )isitors to o!r *ata"as$ +ns,$rs -$" Sit$.

It is int$nd$d or "$/inn$rs to *ata 0od$1in/

It in&or%orat$s a s$1$&tion ro' o!r Li"rar2 o a"o!t 930 data 'od$1s that ar$ $at!r$d on o!r -$" sit$:

htt%:44,,,.data"as$ans,$rs.or/4data5'od$1s4ind$6.ht'

I ho%$ 2o! $n7o2 this Boo# and ,o!1d "$ )$r2 %1$as$d to ha)$ 2o!r &o''$nts at "arr2,8data"as$ans,$rs.or/. Barr2 -i11ia's Prin&i%a1 9ons!1tant *ata"as$ +ns,$rs Ltd. London, En/1and

1. Data Modeling at Windsor Castle in England


1.1 Introduction
This irst 9ha%t$r is a t!toria1 on data 'od$1in/ or 2o!n/ %$o%1$. It %ro)id$s an introd!&tion to data 'od$1in/ that ,$ ho%$ 2o! ind int$r$stin/ and $as2 to r$ad. It &o)$rs th$ "asi& &on&$%ts and has a )$r2 !s$r- ri$nd12 a%%roa&h, $at!rin/ a t$dd2 "$ar and #itt$n &r$atin/ a data 'od$1 on a tri% as to!rists to -indsor 9ast1$, ,hi&h is 7!st o!tsid$ London, En/1and. :o! &an ind this &ha%t$r as a t!toria1 on th$ *ata"as$ +ns,$rs -$" sit$:
htt%:44,,,.data"as$ans,$rs.or/4t!toria145data5'od$1in/5di'%1$5and5to"25)isit5,indsor5&ast1$4ind$6.ht'

In this t!toria1, ,$ ,i11 o11o, t,o 2o!n/ to!rists as th$2 )isit -indsor 9ast1$ and &r$at$ a data 'od$1. ;!r to!rists ar$ *i'%1$, a 10-2$ar-o1d /ir1, ,ho 1i#$s si/hts$$in/ and i&$ &r$a' and To"2, *i'%1$<s 12-2$ar-o1d "roth$r, ,ho 1i#$s si/hts$$in/ and d$si/nin/ data 'od$1s.

Williams | Learn Data Modeling by Example - Part 1 '


1.1.1 What is this? This is a t!toria1 on data 'od$1in/ or 2o!n/ %$o%1$ that r$%r$s$nts a t2%i&a1 data 'od$1in/ %ro7$&t and i11!strat$s th$ "asi& %rin&i%1$s in)o1)$d.

Williams | Learn Data Modeling by Example - Part 1 )

1.1.2 Wh is it im!ortant? *ata 'od$1in/ is i'%ortant "$&a!s$ it is th$ o!ndation or so 'an2 a&ti)iti$s:

It %ro)id$s a )$hi&1$ or &o''!ni&ation a'on/ a ,id$ )ari$t2 o int$r$st$d %arti$s, in&1!din/ 'ana/$'$nt, d$)$1o%$rs, data ana12sts, *B+s and 'or$. + %h2si&a1 data"as$ &an $asi12 "$ /$n$rat$d ro' a data 'od$1 !sin/ a &o''$r&ia1 data 'od$1in/ too1.

1.1." What Will I #earn? :o! ,i11 1$arn:

=o, to &r$at$ a data 'od$1, startin/ ro' s&rat&h. -hat a t2%i&a1 data 'od$1 1oo#s 1i#$.

1.2 To!ics
In this &ha%t$r, ,$ ,i11 &o)$r so'$ "asi& &on&$%ts in data 'od$1in/: Pri'ar2 and For$i/n >$2s ;n$-to-0an2 and 0an2-to-0an2 ?$1ationshi%s =i$rar&hi$s and Inh$ritan&$ ?$ $r$n&$ *ata

1." #et$s go to Windsor

@*i'%1$A: To"2, it<s /r$at "$in/ in London, ,hi&h is so $6&itin/ and "!BBin/.

@To"2A: I<' /1ad 2o! 1i#$ it, *i'%1$. -hat ,o!1d 2o! 1i#$ to do toda2C @*i'%1$A: To"2, ,$ ha)$ s$$n B!&#in/ha' Pa1a&$, ,h$r$ th$ D!$$n o th$ Enit$d >in/do' 1i)$s, and no, I<d 1i#$ to )isit -indsor 9ast1$, "$&a!s$ it<s on$ o th$ 'ost %o%!1ar to!rist attra&tions in th$ E>, and it<s 7!st a short tri% ro' London.

Williams | Learn Data Modeling by Example - Part 1 .

Williams | Learn Data Modeling by Example - Part 1 /


@To"2A: ;>. L$t<s /o... -$ ar$ startin/ ro' B!&#in/ha' Pa1a&$, ,h$r$ th$ D!$$n o th$ Enit$d >in/do' 1i)$s F

To"2 and *i'%1$ 1$a)$ London and arri)$ at -indsorF

1.% &rri'ing at Windsor


@*i'%1$A -o,, To"2, -indsor has a "$a!ti !1 &ast1$ and h$r$ is a ro2a1 %ar# ,ith 1ots o d$$r.

Williams | Learn Data Modeling by Example - Part 1 *


@To"2A :$s, *i'%1$, and ,h$n ,$ 1oo# aro!nd th$r$ ar$ so 'an2 "an#s, &a $s, %!"s, r$sta!rants, sho%s, ,in$ "ars and hos%ita1sG Th$ oth$r thin/ that ,$ s$$ ,h$n ,$ 1oo# aro!nd is %$o%1$ - 1ots o %$o%1$. So ,$ &an start thin#in/ a"o!t o!r data 'od$1.

1.( )tarting our Data Model


@*i'%1$A: =o, do ,$ /$t start$dC @To"2A: -$11, ,$ #no, that ,$ ha)$ %$o%1$ and %1a&$s. Th$ si'%1$st start is to &a11 a11 th$s$ %1a&$s establishments. Th$n ,$ si'%12 ha)$ di $r$nt #inds o $sta"1ish'$nts.

+nd ,$ ha)$ %$o%1$ - 1o&a1 %$o%1$, to!rists, st!d$nts, %$o%1$ %assin/ thro!/h, %$o%1$ ,or#in/ h$r$, %$o%1$ h$r$ on "!sin$ss and so on. @*i'%1$A: =''' - so ho, do ,$ trans1at$ ,hat ,$ #no, to h$1% !s /$t start$d ,ith o!r data 'od$1C @To"2A: L$tHs start a dia/ra' ,ith %$o%1$ and $sta"1ish'$nts. This si'%1$ dia/ra' is /oin/ to /ro, into a data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 $ 1.* Identifiers and Primar +e s

@*i'%1$A: To"2, I a' on$ o th$s$ %$o%1$ so ho, do I &r$at$ a !ni(!$ id$ntit2 or '2s$1 to 'a#$ '$ di $r$nt ro' $)$r2"od2 $1s$C @To"2A: -$ ,i11 /i)$ $)$r2 %$rson a uni,ue identifier and $)$r2 $sta"1ish'$nt its o,n !ni(!$ Id$nti i$r. -h$n ,$ !s$ th$s$ ,$ &a11 th$' Primar +e s, and sho, th$' in th$ dia/ra' ,ith a P+ on th$ 1$ t-hand sid$. @*i'%1$A: That so!nds /ood, To"2, "!t I don<t #no, ,hat it '$ans. @To"2A: -$11, *i'%1$, 1$t<s 1oo# at ho, ,$ !s$ th$s$ id$nti i$rs...

Lots o %$o%1$ )isit $sta"1ish'$nts 1i#$ Star"!&#s in -indsor I0J

1.- .elationshi!s and /oreign +e s


@To"2A: *i'%1$, no, ,$ &an add so'$ int$r$stin/ d$tai1s "$&a!s$ ,$ #no, that on$ %$rson &an )isit 'an2 $sta"1ish'$nts. -$ a1so #no, that on$ $sta"1ish'$nt is )isit$d "2 'an2 to!rists. Th$n ,$ &a11 this a man -to-man relationshi! "$t,$$n %$o%1$ and $sta"1ish'$nts.

Williams | Learn Data Modeling by Example - Part 1 1&


To 'a#$ it $asi$r or 2o! to !nd$rstand I ha)$ $6%and$d th$ man -to-man relationshi! into t,o di $r$nt thin/s, ,hi&h ar$ &a11$d one-to-man relationshi!s. @*i'%1$A: So To"2, is that 1i#$ sa2in/ that on$ %$rson &an 'a#$ 'an2 )isits to 'an2 $sta"1ish'$ntsC @To"2A: :$s, *i'%1$ - that<s /r$at - and ,$ &an a1so sa2 that on$ $sta"1ish'$nt &an ha)$ )isits ro' 'an2 %$o%1$. +t this %oint, ,$ &an sho, ho, a11 th$s$ "o6$s ar$ r$1at$d, and that is a )$r2 "i/ st$%, "$&a!s$ it ta#$s !s to th$ id$a o <r$1ationshi%s<.

-$ &an &a11 th$s$ "o6$s tables - or entities i ,$ ,ant to s%$a# to %ro $ssiona1 data 'od$1$rs. + ta"1$ si'%12 stor$s data a"o!t on$ %arti&!1ar #ind o KThin/ o Int$r$stH. For $6a'%1$, %$o%1$ or $sta"1ish'$nts. Ea&h r$&ord in a ta"1$ ,i11 "$ id$nti i$d "2 its o,n !ni(!$ id$nti i$r, ,hi&h ,$ &a11 th$ primary key. It is not !s!a112 $as2 to ind a s%$&i i& it$' o data a1r$ad2 in th$ ta"1$ that ,i11 a1,a2s "$ !ni(!$. For $6a'%1$, in th$ Enit$d Stat$s, So&ia1 S$&!rit2 N!'"$rs LSSNsJ ar$ s!%%os$d to "$ !ni(!$, "!t L or )ario!s 1$/iti'at$ r$asonsJ that is not a1,a2s th$ &as$. +1so, or$i/n )isitors and to!rists ,i11 not ha)$ SSNs. Th$r$ or$, it is "$st %ra&ti&$ to &r$at$ a n$, i$1d 7!st or this %!r%os$. This ,i11 "$ ,hat is &a11$d an auto-increment data t2%$, ,hi&h ,i11 "$ /$n$rat$d a!to'ati&a112 "2 th$ *ata"as$ 0ana/$'$nt S2st$' L*B0SJ at r!n-ti'$. This is &a11$d a surrogate 0e and it do$s not ha)$ an2 oth$r %!r%os$.

It is si'%12 a #$2 that stands or so'$thin/ $1s$. It is a '$anin/1$ss int$/$r that is /$n$rat$d a!to'ati&a112 "2 th$ data"as$ 'ana/$'$nt so t,ar$, s!&h as ;ra&1$ or SDL S$r)$r. Th$ )a1!$s ar$ !s!a112 &ons$&!ti)$ int$/$rs, startin/ ,ith 1,2,3,4 and so on.

No, ,$ &an s$$ ho, !s$ !1 o!r id$nti i$rs &an "$ "$&a!s$ ,$ &an in&1!d$ th$ %$rson and $sta"1ish'$nt id$nti i$rs in o!r Misits Ta"1$.

Williams | Learn Data Modeling by Example - Part 1 11


Th$n th$ P$rson5I* i$1d "$&o'$s a 1in# to a r$&ord or a %$rson in th$ P$rson Ta"1$. This 1in# is ,hat is &a11$d a /oreign +e and ,$ &an s$$ it<s sho,n ,ith 1/+1 on th$ 1$ thand sid$.

1.2 Products and Product T !es


@*i'%1$A: To"2, ,h$n ,$ /o into a sho% ,$ ,ant to "!2 so'$thin/. +nd th$r$ ar$ tho!sands and tho!sands o %ossi"i1iti$s. =o, do ,$ d$a1 ,ith a11 that in o!r 1itt1$ data 'od$1C @To"2A: -$11 *i'%1$, it<s r$a112 (!it$ $as2. It<s 1i#$ a11 o!r 'od$1in/ ,h$r$ ,$ 1oo# or si'%1$ %att$rns that &o)$r 'an2 sit!ations. @*i'%1$A: ='' - I don<t #no, ,hat that '$ans. 0a2"$ i 2o! sho,$d '$ I 'i/ht !nd$rstand it. @To"2A: ;>. E)$r2thin/ that ,$ "!2 is &a11$d a !roduct, and a11 ,$ ha)$ to do is si'%12 d$ in$ th$ t2%$ o $a&h %rod!&t - s!&h as a &o $$, '! in or a n$,s%a%$r.

Th$n ,$ dra, a 1itt1$ "o6 &a11$d Products and sa2 that $)$r2 %rod!&t has a t2%$. In oth$r ,ords, th$r$ is a r$1ationshi% "$t,$$n th$ Products and Product_Types "o6$s.

Th$ 1in$s ar$ &a11$d relationshi!s and th$2 ar$ )$r2 i'%ortant in data 'od$1in/. -$ ar$ no, &r$atin/ an Entit2-?$1ationshi% *ia/ra' or NE?*N. This dia/ra' sho,s on12 a 1in$ or th$ r$1ationshi%:

Th$ s2'"o1 at th$ %rod!&ts $nd is &a11$d crows feet and it sho,s th$ many $nd. Th$ short strai/ht 1in$ at th$ Prod!&t5T2%$s $nd sho,s th$ one $nd. In oth$r ,ords, this 1in$ sho,s a on$-to-'an2 r$1ationshi%.

Williams | Learn Data Modeling by Example - Part 1 12

*i'%1$, 1$t '$ $6%1ain a"o!t th$ dott$d 1in$. It '$ans that th$ r$1ationshi% r$s!1ts in a KFor$i/n >$2H in th$ %rod!&ts ta"1$. This is sho,n "2 th$ KF>H s2'"o1 n$6t to th$ product_type_code i$1d and it '$ans that th$r$ is a 1in# "a&# to th$ Prod!&t5T2%$s. =o,$)$r, th$ %ri'ar2 #$2 is on12 th$ Prod!&t5I*, and o &o!rs$, this is sho,n "2 th$ KP>H s2'"o1 n$6t to th$ Product3ID i$1d. Lat$r, ,h$n ,$ ta1# a"o!t inh$ritan&$, ,$ ,i11 !s$ a strai/ht 1in$, in &ontrast to this dott$d 1in$ h$r$. This is to sho, that th$ or$i/n #$2 i$1d is a1so a %ri'ar2 #$2.

I ha)$ to sa2 so'$thin/ a "it di i&!1t a"o!t %ri'ar2 #$2s ri/ht no,. In th$ Prod!&ts Ta"1$, ,$ ha)$ to a11o, or a )$r2 1ar/$ n!'"$r o %rod!&ts "$in/ stor$d. Th$r$ or$ ,$ !s$ an I* i$1d or th$ %ri'ar2 #$2. -$ th$n &r$at$ this I* i$1d a!to'ati&a112 as a n!'"$r L&a11$d an a!to-in&r$'$nt int$/$rJ. This n!'"$r has no '$anin/ and is si'%12 !s$d to id$nti 2 $a&h r$&ord !ni(!$12 a'on/ %ossi"12 'i11ions or h!ndr$ds o 'i11ions. =o,$)$r, thin/s ar$ di $r$nt or Kt2%$H i$1ds. Th$s$ ar$ ,hat ,$ &a11 $n!'$rat$d data and ar$ t2%i&a112 reference data. Th$2 ar$ a1,a2s r$1ati)$12 s'a11 in n!'"$r and ,$ &hoos$ a &od$ or th$ %ri'ar2 #$2 "$&a!s$ ,$ &an &r$at$ th$' and r$)i$, th$' 'an!a112. It a1so h$1%s !s to &r$at$ a &od$ that ,$ &an !s$ and r$ $r to, in &ontrast to th$ I* i$1ds that ha)$ no '$anin/. T2%i&a1 $6a'%1$s ,o!1d "$: SiB$s O S'a11, 0$di!' and Lar/$ ,h$r$ ,$ ar$ a&&!sto'$d to s$$in/ S,0 and L. P$nd$r O 0a1$ and F$'a1$, ,h$r$ ,$ !s$ 0 and F.

Williams | Learn Data Modeling by Example - Part 1 1"


This '$n! "oard at Star"!&#s sho,s 1ots o %rod!&ts.

-$ #no, that th$2 ar$ or/aniB$d in /ro!%s, 1i#$ ood and drin#, and $a&h o th$s$ has 'or$ /ro!%s and so on, ri/ht do,n to th$ %arti&!1ar %rod!&t, 1i#$ &ara'$1 'a&&hiato or a %anini. This to%-do,n or/aniBation is &a11$d a hierarch and a%%$ars a11 o)$r th$ %1a&$. L!&#i12 ,$ &an sho, this )$r2 $asi12 and n$at12 in o!r data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 1' 1.4 Products5 T !es and Product 6ierarchies
@*i'%1$A: To"2, ,h$n ,$ 1oo# &1os$12 at th$ '$n! "oard to tr2 to d$&id$ ,hat to ord$r ,$ &an s$$ 1ots o %ossi"i1iti$s. B!t a t$r a ,hi1$ ,$ &an s$$ a %att$rn that h$1%s !s d$&id$. =o, do ,$ d$a1 ,ith a11 that in o!r 1itt1$ data 'od$1C @To"2A: -$11 *i'%1$, it<s r$a112 (!it$ $as2. -$ d$ in$ so'$thin/ &a11$d a hierarchy. =i$rar&hi$s ar$ )$r2 &o''on and si'%12 '$an an2 sit!ation ,h$r$ th$r$ ar$ %ar$nts, &hi1dr$n, /rand&hi1dr$n and so on. I ,$ 1oo# at th$ Star"!&#s '$n! "oard on th$ ri/ht-hand sid$ ,$ &an s$$ a si'%1$ $6a'%1$ o <$s%r$sso< and !nd$r it a n!'"$r o di $r$nt drin#s. 02 a)orit$ is &ara'$1 'a&&hiato. So in this &as$, th$ to%-1$)$1 o o!r hi$rar&h2 is a %rod!&t &at$/or2 &a11$d $s%r$sso, and th$ n$6t 1$)$1 do,n is a %rod!&t &a11$d &ara'$1 'a&&hiato. @*i'%1$A: ;>. That so!nds ;>. @To"2A: Fina112, ,$ sho, this hi$rar&h2 "2 a dott$d 1in$ in th$ to%-ri/ht hand &orn$r in th$ $ntit2 &a11$d <?$ 5T2%$s5o 5Prod!&ts<. This is or'a112 &a11$d a recursive or reflexive r$1ationshi% and is in or'a112 &a11$d rabbit ears.

Williams | Learn Data Modeling by Example - Part 1 1) 1.17 T !es of Peo!le


@*i'%1$A: To"2, that 1oo#s ;>. I /!$ss ,$ &an d$a1 ,ith t2%$s o %$o%1$ th$ sa'$ ,a2, &an ,$C @To"2A: :$s, *i'%1$, and t2%$s o $sta"1ish'$nts as ,$11. @*i'%1$A: ;>, that so!nds s$nsi"1$. +nd do th$2 !s$ th$s$ id$nti i$rs in a data"as$C @To"2A: :$s, and ,hat is $)$n "$tt$r is that th$ data"as$ ,i11 a!to'ati&a112 /$n$rat$ a n$, !ni(!$ Id$nti i$r or 2o! and 2o!r )isits and %!r&has$s i 2o! ,ant to /$t a r$ !nd 1at$r.

1.11 T !es of Peo!le and Establishments


@*i'%1$A: I s$$, To"2. I /!$ss ,$ &an d$a1 ,ith t2%$s o $sta"1ish'$nts th$ sa'$ ,a2, &an ,$C @To"2A: :$s, *i'%1$. @*i'%1$A: ;>, that so!nds s$nsi"1$. +nd do th$2 !s$ th$s$ id$nti i$rs in a data"as$C @To"2A: :$s, and ,$ &an !s$ o!r n$, !ni(!$ id$nti i$r or 2o! and 2o!r )isits and %!r&has$s in &as$ ,$ ,ant to #$$% tra&# o thin/s. Li#$ 'a2"$ 2o! ,ant to /$t a r$ !nd 1at$r so ,$ n$$d to /$t 2o!r d$tai1s ro' th$ data"as$.

Williams | Learn Data Modeling by Example - Part 1 1.

@To"2A: B$ or$ ,$ 'o)$ on, 1$t<s ta1# a"o!t $sta"1ish'$nts. ;n$ s%$&ia1 thin/ a"o!t -indsor is that it has a &ast1$ ,h$r$ th$ D!$$n 1i)$s and a )$r2 1ar/$ ro2a1 %ar#, ,h$r$ sh$ #$$%s d$$r. B!t ,h$n ,$ thin# a"o!t th$s$ thin/s, ,$ ind that ,$ &an si'%12 it th$' into o!r d$ inition o $sta"1ish'$nts.

Williams | Learn Data Modeling by Example - Part 1 1/ 1.12 8isits and Purchases9
=$r$ ,$ &an s$$ 'an2 )isitors to -indsorHs ?o2a1 Sho%%in/ +r&ad$.

@*i'%1$A: To"2, ,ith so 'an2 %$o%1$, $sta"1ish'$nts and %!r&has$s ho, do th$2 #$$% tra&# o $)$r2thin/C

@To"2A: -$11, *i'%1$, "2 this ti'$, $)$r2thin/ has its o,n id$nti i$r that is !s$d ,h$r$)$r th$2 n$$d to #$$% tra&#.

@*i'%1$A: ;>, that so!nds s$nsi"1$. +nd do th$2 !s$ th$s$ id$nti i$rs in a data"as$C

Williams | Learn Data Modeling by Example - Part 1 1*


@To"2A: :$s, *i'%1$, and in this dia/ra', ,$ &an s$$ that ,$ &an !s$ th$ !ni(!$ id$nti i$rs that ar$ sho,n as KP>,H or Pri'ar2 >$2s. -$ &an s$$ that ,$ ha)$ a P> or $)$r2 $ntit2 or ta"1$ so ,$ &an "$ %r$tt2 s!r$ ,$ &an /$t ro' an2 ta"1$ to an2 oth$r ta"1$. This is &a11$d navigating aro!nd th$ data 'od$1 and is a /ood t$st or a ,$11-d$si/n$d data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 1$ 1.1" Peo!le and Inheritance
@To"2A: *i'%1$, 1$t<s ta#$ a &1os$r 1oo# at th$ di $r$nt t2%$s o %$o%1$ ,$ &an ind in -indsor. @*i'%1$A: ;>, To"2. I ho%$ I don<t ha)$ to thin# too '!&h "$&a!s$ I 'i/ht /$t a h$ada&h$C

@To"2A: No, *i'%1$, I ,i11 do th$ thin#in/ and ta1#in/ and a11 2o! ha)$ to do is nod 2o!r h$ad ,h$n 2o! !nd$rstand. @*i'%1$A: ;>, To"2. I %ro'is$ to do that. @To"2A: -$ a1r$ad2 said that ,$ ha)$ 1o&a1 %$o%1$ and to!rists. Th$r$ ar$ a1,a2s 1ots and 1ots o %$o%1$ )isitin/ -indsor 9ast1$. -h$n ,$ 1oo# at this %i&t!r$, ,$ &an s$$ &$r$'onia1 /!ards in &$r$'onia1 r$d !ni or's, and a "i/ &ro,d, ,ith 'ain12 to!rists "!t a1so sta in sho%s r$s%onsi"1$ or &ontro11in/ th$ &ro,d, to!rists, 1o&a1 %$o%1$ and so on.

So'$ o th$s$ 1o&a1 %$o%1$ ar$ sho%%$rs and so'$ o th$' ,i11 "$ ,or#in/ in th$ sho%s. -$ ,i11 &a11 th$ ,or#$rs staff and ,$ #no, di $r$nt thin/s a"o!t th$' than th$ thin/s ,$ #no, a"o!t th$ to!rists.

For $6a'%1$, ,$ ,i11 %ro"a"12 #no, th$ /$nd$r o $)$r2"od2 7!st "2 1oo#in/ at th$'. For sta , ,$ ,i11 !s!a112 a1so #no, th$ir dat$ o "irth and th$ir ho'$ addr$ss.

Williams | Learn Data Modeling by Example - Part 1 2&

In data 'od$1in/ ,$ ha)$ a )$r2 %o,$r !1 a%%roa&h that ,$ &a11 Inheritance that ,$ &an !s$ h$r$.

I ,$ ,ant to d$s&ri"$ this in En/1ish, ,$ ,o!1d sa2 that sta inh$rit th$ P$o%1$5T2%$59od$ and /$nd$r ro' th$ %ar$nt $ntit2 o %$o%1$, and in addition, th$2 ha)$ a dat$ o "irth and ho'$ addr$ss.

For to!rists, ,$ donHt #no, '!&h, $6&$%t or th$ dat$ o th$ir )isit, and 'a2"$, i th$2 "!2 so'$thin/ in a sho% !sin/ a &r$dit &ard, th$n th$ sho% ,o!1d #no, th$ &r$dit &ard d$tai1s. For th$ &$r$'onia1 /!ards in r$d !ni or's, ,$ &an t$11 th$ir ran# "2 1oo#in/ at th$ir !ni or' and 'a2"$ it ,o!1d a1so t$11 !s ,hi&h !nit o th$ ar'2 th$2 "$1on/ to. *o$s that 'a#$ s$ns$, *i'%1$C @*i'%1$A: I thin# so, To"2. Is it 1i#$ sa2in/ that ,$ inh$rit ha)in/ t,o ar's and t,o 1$/s ro' o!r %ar$nts "$&a!s$ th$2 ha)$ t,o ar's and t,o 1$/s, "!t that ,$ ha)$ a1so ha)$ thin/s that ar$ 7!st !sC @To"2A: :$s, *i'%1$ - that<s /r$at - 1$t<s ta#$ a "r$a# and do so'$ sho%%in/G @*i'%1$A: I 1i#$ th$ so!nd o that, To"2. 9an I ha)$ an i&$ &r$a'C @To"2A: :$s, o &o!rs$, *i'%1$ O this dia/ra' sho,s ,$ ar$ doin/ ,$11. It sho, inh$ritan&$ "$t,$$n %$o%1$ and th$ thr$$ di $r$nt t2%$s o %$o%1$:

Williams | Learn Data Modeling by Example - Part 1 21

-$ &an s$$ a i$1d 'ar#$d as KP/$ in th$ thr$$ ta"1$s or &$r$'onia1 /!ards, sta to!rists.

and

This is !n!s!a1 "$&a!s$ it '$ans a i$1d that is a Pri'ar2 >$2 in th$ thr$$ ta"1$s and a1so a /or$i/n >$2 to th$ P$o%1$ Ta"1$. Th$r$ or$, i 2o!r irst r$&ord ,as a &$r$'onia1 /!ard, th$n ,$ ,o!1d ha)$ a r$&ord in th$ P$o%1$ Ta"1$ ,ith a P$rson5I* o 1 and a r$&ord in th$ &$r$'onia1 /!ard ,ith a P!ard5I* o 1. Si'i1ar12, i o!r s$&ond r$&ord ,as a '$'"$r o sta , ,$ ,o!1d ha)$ a r$&ord in th$ P$o%1$ Ta"1$ ,ith a P$rson5I* o 2 and a r$&ord in th$ Sta Ta"1$ ,ith a Sta 5I* o 3.

1.1% )taff5 Establishments and Deri'ed /ields


@*i'%1$A: To"2, ho, do ,$ s%$&i 2 that sta '!st ,or# in so'$ $sta"1ish'$ntC

@To"2A: *i'%1$, that<s a )$r2 /ood (!$stion. Fort!nat$12, th$ ans,$r is )$r2 $as2. -$ add a on$-to-'an2 r$1ationshi% "$t,$$n th$ sta and $sta"1ish'$nt $ntiti$s. In En/1ish, ,$ ,o!1d sa2 that $)$r2 '$'"$r o sta '!st ,or# in on$ $sta"1ish'$nt and $)$r2 $sta"1ish'$nt &an $'%1o2 'an2 '$'"$rs o sta .

In th$ dia/ra', ,$ sho, this ,ith a foreign 0e $ntit2.

"2 th$ Esta"1ish'$nt5I* i$1d in th$ sta

Williams | Learn Data Modeling by Example - Part 1 22


So i ,$ 1oo# &1os$12 at th$ sta $ntit2, ,$ ,i11 s$$ K/+H "2 th$ Esta"1ish'$nt5I* i$1d.

@*i'%1$A: ;>, that so!nds /ood, and I &an s$$ ho, th$ id$nti i$rs ar$ )$r2 i'%ortant. @To"2A: I a' /1ad to h$ar it, *i'%1$. Th$r$ is on$ 'or$ thin/ I ha)$ to sa2. -$ ar$ 1$arnin/ data 'od$1in/ and on$ i'%ortant thin/ a"o!t data 'od$1in/ is that it has to o11o, a s$t o rules. Th$s$ r!1$s h$1% !s to %rod!&$ /ood data 'od$1s and so th$2 ar$ )$r2 i'%ortant. ;n$ o th$ r!1$s is that ,$ &annot in&1!d$ an2 "its o data that &an "$ d$ri)$d ro' an2 oth$r "its o data. For $6a'%1$, ,$ !s!a112 ,ant to #no, ho, 'an2 %$o%1$ ,or# in a sho% or &a $. Th$r$ or$ ,$ in&1!d$ a staff count i$1d ,ith th$ $sta"1ish'$nt. B!t ,h$n it &o'$s to indin/ th$ )a1!$ that /o$s in h$r$, ,$ ,i11 &o!nt th$ r$&ords in th$ Sta Ta"1$ or $a&h $sta"1ish'$nt. Th$r$ or$, it<s a deri'ed field and ,$ &a11 it a na'$ that starts ,ith <d$ri)$d5< to 'a#$ thin/s &1$ar. This is "$&a!s$, a&&ordin/ to th$ r!1$s, ,$ sho!1d not in&1!d$ d$ri)$d i$1ds in o!r data 'od$1 at this $ar12 sta/$. I ha)$ sho,n it h$r$ si'%12 as an $6a'%1$ "$&a!s$ it is a sit!ation that o&&!rs (!it$ o t$n so itHs /ood to r$&o/niB$ it ,h$n 2o! s$$ it.

*o$s that so!nd s$nsi"1$, *i'%1$C @*i'%1$A: I s!%%os$ so, To"2. B!t I<)$ /ot a h$ada&h$, &an ,$ /o or an i&$ &r$a' no,C

1.1( .eference Data


@To"2A: *i'%1$, 2o! &an s$$ that I a' !sin/ a P$nd$r Ta"1$ and P$o%1$ T2%$s Ta"1$. I ha)$ /i)$n th$' "oth na'$s that "$/in ,ith <r$ 5< to 'a#$ it &1$ar that th$2 ar$ r$ $r$n&$ data. This '$ans that th$ )a1!$s don<t &han/$ '!&h and I &an !s$ th$' to d$ in$ ,hat th$ )a1id )a1!$s &an "$. This is a t$&hni(!$ that %ro $ssiona1 data 'od$1$rs !s$ "!t ,$ don<t n$$d to ,orr2 a"o!t it toda2.

Williams | Learn Data Modeling by Example - Part 1 2"


@*i'%1$A: I<' /1ad to h$ar it, To"2G +1tho!/h it isnHt di i&!1t to !nd$rstand and it s$$'s 1i#$ a /ood id$a. @To"2A: In o!r s'a11 $6a'%1$, ,$ ha)$ on12 o!r #inds o r$ $r$n&$ data a1to/$th$r /$nd$r, t2%$s o $sta"1ish'$nt, %$o%1$ and %rod!&ts.

1.1* :ringing it all Together


@To"2A: *i'%1$, i ,$ "rin/ to/$th$r $)$r2thin/ ,$ ha)$ ta1#$d a"o!t, ,$ ,i11 s$$ that ,$ ha)$ (!it$ a /ood data 'od$1 that an2 %ro $ssiona1 ,o!1d "$ %ro!d o . @*i'%1$A: ;>, To"2. *o 2o! thin# I ,i11 !nd$rstand itC @To"2A: L$t '$ h$1% 2o! "2 'a#in/ a 1ist o th$ business rules or o!r 'od$1:

P$o%1$ &an "$ $ith$r &$r$'onia1 /!ards, sta

or to!rists.

Th$r$ ar$ a n!'"$r o $sta"1ish'$nts o di $r$nt t2%$s. To!rists &an 'a#$ )isits to $sta"1ish'$nts and 'a#$ %!r&has$s. Sta assist th$ to!rists ,h$n th$2 'a#$ a %!r&has$.

+ %!r&has$ in)o1)$s on$ %rod!&t.

@To"2A: ;>, *i'%1$ - ,$ ha)$ a )$r2 ni&$ data 'od$1 and no, ,$ &an ta#$ th$ "r$a# I %ro'is$d 2o!. @*i'%1$A: That<s /r$at, To"2 - &an I ha)$ an i&$ &r$a'C @To"2A: S!r$, "!t "$ or$ ,$ do I sho!1d sa2 so'$thin/ a"o!t P/, ,hi&h a%%$ars in th$ Sta Ta"1$.

Williams | Learn Data Modeling by Example - Part 1 2'

It<s !n!s!a1 and it<s &a11$d P/ "$&a!s$ it '$ans a i$1d ,hi&h is a Pri'ar2 >$2 in th$ Sta Ta"1$ and a /or$i/n >$2 to th$ P$o%1$ Ta"1$. @*i'%1$A: =''', I<)$ /ot a h$ada&h$, To"2 - &an ,$ %1$as$ /o and /$t an i&$ &r$a'C @To"2A: ;>, *i'%1$. :o!<)$ "$$n a )$r2 /ood /ir1 and 2o! d$s$r)$ a "r$a#. :o! &an ad'ir$ ,hat ,$ ha)$ &r$at$d, ,hi&h is this )$r2 %ro $ssiona1-1oo#in/ data 'od$1.

1.1- To!-#e'el Model ;ith <ames =nl


-$ &an sho, o!r data 'od$1 at th$ to%-1$)$1, sho,in/ on12 th$ na'$s o th$ Kthin/s o int$r$st,H ,hi&h ,$ &a11 $ntiti$s or ta"1$s i ,$ ar$ thin#in/ a"o!t a data"as$. This is s!ita"1$ or $6%1ainin/ ,hat ,$ sa, in -indsor to o!r a'i12 or ri$nds. I ,$ ,ant$d to d$s&ri"$ it, ,$ &o!1d si'%12 sa2:

Th$r$ ar$ 1ots o %$o%1$ in -indsor, in&1!din/ &$r$'onia1 /!ards, sta Th$r$ ar$ a1so 1ots o $sta"1ish'$nts, 1i#$ sho%s and th$ 9ast1$.

and to!rists.

To!rists 'ad$ )isits to $sta"1ish'$nts ,h$r$ th$2 'ad$ %!r&has$s o %rod!&ts.

Williams | Learn Data Modeling by Example - Part 1 2)

Williams | Learn Data Modeling by Example - Part 1 2. 1.12 To!-#e'el Model ;ith +e /ields
This is ,hat o!r data 'od$1 1oo#s 1i#$ i ,$ sho, #$2 i$1ds on12 and 1$a)$ o!t th$ ?$ $r$n&$ *ata Ta"1$s. This 1$)$1 o dis%1a2 is s!ita"1$ i ,$ ,ant to &on ir' to $a&h oth$r ho, th$ ta"1$s Lor $ntiti$sJ ar$ r$1at$d.

Williams | Learn Data Modeling by Example - Part 1 2/

1.14 To!-#e'el Model ;ith all Details


Fina112, this is ,hat o!r data 'od$1 1oo#s 1i#$ i ,$ sho, th$ #$2 i$1ds, a11 th$ data it$'s on12 and th$ ?$ $r$n&$ *ata Ta"1$s. :o! &an s$$ that th$ a'o!nt o d$tai1 in)o1)$d 'a#$s it 'or$ di i&!1t to !nd$rstand ,hatHs /oin/ on and to id$nti 2 ,hat is i'%ortant. This 1$)$1 o dis%1a2 is s!ita"1$ i ,$ ,ant to ta1# a"o!t d$tai1s and d$)$1o% a data"as$ ro' o!r data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 2* 1.27 Ice Cream


@To"2A: *i'%1$, I<)$ /ot so'$ ,ond$r !1 n$,s or 2o!. @*i'%1$A: I<' /1ad to h$ar it, To"2 - ,hat is itC @To"2A: I ha)$ o!nd 2o!r a)orit$ Bas#in-?o""ins i&$ &r$a' h$r$ in -indsor IJ @*i'%1$A: To"2, ar$ 2o! t$asin/ '$C @To"2A: No, *i'%1$ - 1oo#, th$r$ it is a&ross th$ road ro' -indsor 9ast1$G @*i'%1$A: -o, - that<s /r$at, so I &an ha)$ '2 a)orit$ "!tt$r %$&an i&$ &r$a'.

1.21 What ha'e ;e learned?


In this &ha%t$r, ,$ ha)$ 1$arn$d ho, to thin# 1i#$ a data 'od$1$r and ho, to /rad!a112 %!t to/$th$r a data 'od$1 in o!r h$ads. -$ #no, that i ,$ /$t in th$ ha"it o doin/ this r$/!1ar12 it /$ts $asi$r and 'or$ nat!ra1 and soon ,$ ,i11 "$ s$$in/ th$ ,or1d aro!nd !s as %i$&$s o a data 'od$1 that ,$ &an it to/$th$r 1i#$ a 7i/sa, %!BB1$.

1.22 Please Email Me


I ho%$ 2o! ha)$ o!nd this t!toria1 !n and !s$ !1. I ,o!1d "$ )$r2 %1$as$d to ha)$ 2o!r &o''$nts O do 2o! 1i#$ this &ha%t$r or ar$ th$r$ an2 &han/$s 2o! ,o!1d r$&o''$ndC :o! &an $'ai1 '$ at "arr2,8data"as$ans,$rs.or/.

Williams | Learn Data Modeling by Example - Part 1 2$

2. Data Modeling in Denmar0

Fr$d$ri#s"or/ 9ast1$ in *$n'ar#

-$ ha)$ 'o)$d this 9ha%t$r to a s$%arat$ do&!'$nt that 2o! &an do,n1oad h$r$ :-

htt%:44,,,.data"as$ans,$rs.or/4do,n1oads49ha%t$r525L$arn5*ata50od$11in/5Boo#5 or5*$n'ar#.%d

Williams | Learn Data Modeling by Example - Part 1 "&

". Data Modeling in Tur0e


".1 Introduction
In this t!toria1, ,$ ,i11 o11o, t,o 2o!n/ to!rists as th$2 )isit T!r#$2, ,hi&h is a &o!ntr2 ,ith a tr$'$ndo!s histor2 and )$r2 %o%!1ar ,ith to!rists 1oo#in/ or so'$thin/ s%$&ia1.

;!r to!rists ar$ *i'%1$, a 10-2$ar o1d /ir1, ,ho 1i#$s si/hts$$in/ and i&$ &r$a' and To"2, *i'%1$<s 12-2$ar-o1d "roth$r, ,ho 1i#$s si/hts$$in/ and d$si/nin/ data 'od$1s. ".1.1 What is this? This is a t!toria1 on data 'od$1in/ or 2o!n/ %$o%1$ that r$%r$s$nts a t2%i&a1 data 'od$1in/ %ro7$&t and i11!strat$s th$ "asi& %rin&i%1$s in)o1)$d.

".1.2 Wh is it im!ortant? *ata 'od$1in/ is i'%ortant "$&a!s$ it is th$ o!ndation or so 'an2 a&ti)iti$s:

Williams | Learn Data Modeling by Example - Part 1 "1


It %ro)id$s a )$hi&1$ or &o''!ni&ation a'on/ a ,id$ )ari$t2 o int$r$st$d %arti$s, in&1!din/ 'ana/$'$nt, d$)$1o%$rs, data ana12sts, *B+s and 'or$. + %h2si&a1 data"as$ &an $asi12 "$ /$n$rat$d ro' a data 'od$1 !sin/ a &o''$r&ia1 data 'od$1in/ too1.

".1." What Will I #earn? :o! ,i11 1$arn:

=o, to &r$at$ a data 'od$1, startin/ ro' s&rat&h Th$ i'%ortant d$si/n %rin&i%1$s in)o1)$d -hat a t2%i&a1 data 'od$1 1oo#s 1i#$

".2 To!ics
In this &ha%t$r, ,$ ,i11 &o)$r so'$ "asi& &on&$%ts in data 'od$1in/: Pri'ar2 and For$i/n >$2s ;n$-to-0an2 and 0an2-to-0an2 ?$1ationshi%s =i$rar&hi$s and Inh$ritan&$ ?$ $r$n&$ *ata

"." #et$s get started


@To"2A: -$ ha)$ 7!st arri)$d in T!r#$2. -hat ,o!1d 2o! 1i#$ to do toda2C @*i'%1$A: To"2, It<s /r$at "$in/ in T!r#$2 ,hi&h is so $6&itin/ and has so 'an2 thin/s to s$$ and $n7o2.

@To"2A: I<' /1ad 2o! 1i#$ it, *i'%1$. -hat ,o!1d 2o! 1i#$ to do toda2C @*i'%1$A: To"2, ,$ ha)$ &o'$ to T!r#$2, and I ,o!1d 1i#$ to s$$ Istan"!1 and )isit th$ B1!$ 0os(!$, "$&a!s$ it<s on$ o th$ 'ost %o%!1ar to!rist attra&tions h$r$, th$n I ,o!1d 1i#$ to do so'$ sho%%in/, th$n s$$ th$ s$a, and I ,o!1d 1i#$ to inish !% at Star"!&#s.

Williams | Learn Data Modeling by Example - Part 1 "2

@To"2A: ;>. L$t<s /o.

-$ ar$ startin/ ro' Istan"!1, ,hi&h is a "$a!ti !1 %1a&$F

To"2 and *i'%1$ 1$a)$ En/1and and arri)$ in T!r#$2F

Williams | Learn Data Modeling by Example - Part 1 "" ".% &rri'ing at Istanbul

@*i'%1$A -o,, To"2, 1oo# at a11 th$s$ %$o%1$.

@To"2A :$s, *i'%1$, ,h$n ,$ 1oo# aro!nd th$r$ ar$ so 'an2 %$o%1$, sho%s, "an#s and so onG So ,$ &an start thin#in/ a"o!t o!r data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 "'

".( )tarting our Data Model


@*i'%1$A: =o, do ,$ /$t start$dC @To"2A: -$11, ,$ #no, that ,$ ha)$ %$o%1$ and %1a&$s. Th$ si'%1$st start is to &a11 a11 th$s$ %1a&$s establishments. Th$n ,$ si'%12 ha)$ di $r$nt #inds o $sta"1ish'$nts.

+nd ,$ ha)$ %$o%1$ - 1o&a1 %$o%1$, to!rists, st!d$nts, %$o%1$ %assin/ thro!/h, %$o%1$ ,or#in/ h$r$, %$o%1$ h$r$ on "!sin$ss and so on. @*i'%1$A: =''' - so ho, do ,$ trans1at$ ,hat ,$ #no, to h$1% !s /$t start$d ,ith o!r data 'od$1C @To"2A: L$tHs start a dia/ra' ,ith %$o%1$ and $sta"1ish'$nts. This si'%1$ dia/ra' is /oin/ to /ro, into a data 'od$1.

".* Identifiers and Primar

@*i'%1$A: To"2, I a' on$ o th$s$ %$o%1$ so ho, do I &r$at$ a !ni(!$ id$ntit2 or '2s$1 to 'a#$ '$ di $r$nt ro' $)$r2"od2 $1s$C @To"2A: -$ ,i11 /i)$ $)$r2 %$rson a uni,ue identifier and $)$r2 $sta"1ish'$nt its o,n !ni(!$ id$nti i$r. -h$n ,$ !s$ th$s$ ,$ &a11 th$' Primar +e s, and sho, th$' in th$ dia/ra' ,ith a P+ on th$ 1$ t-hand sid$. @*i'%1$A: That so!nds /ood, To"2, "!t I don<t #no, ,hat it '$ans. @To"2A: -$11, *i'%1$, 1$t<s 1oo# at ho, ,$ !s$ th$s$ id$nti i$rs...

+e s

Williams | Learn Data Modeling by Example - Part 1 ")


-$ ha)$ 'ana/$d to ind a (!i$t ar$a ,h$r$ a )$r2 ha%%2 'an is s$11in/ a T!r#ish a)orit$, &a11$d SI0IT I0J So, in oth$r ,ords, ,$ ha)$ on$ %$rson, ,ho is th$ ha%%2 'an, and on$ $sta"1ish'$nt, ,hi&h is his si'%1$ sta11. So ,$ &an &r$at$ a %$o%1$ r$&ord ,ith a %$rson I* o 1 and an $sta"1ish'$nts r$&ord or th$ sta11, ,ith an $sta"1ish'$nt I* o 3.

".- .elationshi!s and /oreign +e s


@To"2A: *i'%1$, no, ,$ &an add so'$ int$r$stin/ d$tai1s "$&a!s$ ,$ #no, that on$ %$rson &an )isit 'an2 $sta"1ish'$nts. -$ a1so #no, that on$ $sta"1ish'$nt is )isit$d "2 'an2 to!rists. Th$n ,$ &a11 this a man -to-man relationshi! "$t,$$n %$o%1$ and $sta"1ish'$nts. To 'a#$ it $asi$r or 2o! to !nd$rstand I ha)$ $6%and$d th$ man -to-man relationshi! into t,o di $r$nt thin/s, ,hi&h ar$ &a11$d one-to-man relationshi!s. @*i'%1$A: So To"2, is that 1i#$ sa2in/ that on$ %$rson &an 'a#$ 'an2 )isits to 'an2 $sta"1ish'$ntsC

Williams | Learn Data Modeling by Example - Part 1 ".

@To"2A: :$s, *i'%1$ - that<s /r$at - and ,$ &an a1so sa2 that on$ $sta"1ish'$nt &an ha)$ )isits ro' 'an2 %$o%1$. +t this %oint, ,$ &an sho, ho, a11 th$s$ "o6$s ar$ r$1at$d, and that is a )$r2 "i/ st$%, "$&a!s$ it ta#$s !s to th$ id$a o <r$1ationshi%s<.

-$ &an &a11 th$s$ "o6$s tables - or entities i ,$ ,ant to s%$a# to %ro $ssiona1 data 'od$1$rs. + ta"1$ si'%12 stor$s data a"o!t on$ %arti&!1ar #ind o KThin/ o Int$r$stH. For $6a'%1$, %$o%1$ or $sta"1ish'$nts. Ea&h r$&ord in a ta"1$ ,i11 "$ id$nti i$d "2 its o,n !ni(!$ id$nti i$r, ,hi&h ,$ &a11 th$ Primary Key. It is not !s!a112 $as2 to ind a s%$&i i& it$' o data a1r$ad2 in th$ ta"1$ that ,i11 a1,a2s "$ !ni(!$. For $6a'%1$, in th$ Stat$s, So&ia1 S$&!rit2 N!'"$rs ar$ s!%%os$d to "$ !ni(!$, "!t L or )ario!s 1$/iti'at$ r$asonsJ that is not a1,a2s th$ &as$. +1so, or$i/n )isitors and to!rists ,i11 not ha)$ SSNs. Th$r$ or$, it is "$st %ra&ti&$ to &r$at$ a n$, i$1d 7!st or this %!r%os$. This ,i11 "$ ,hat is &a11$d an auto-increment data t2%$, ,hi&h ,i11 "$ /$n$rat$d a!to'ati&a112 "2 th$ *ata"as$ 0ana/$'$nt S2st$' L*B0SJ at r!n-ti'$. This is &a11$d a surrogate 0e and it do$s not ha)$ an2 oth$r %!r%os$.

It is si'%12 a #$2 that stands or so'$thin/ $1s$. It is a '$anin/1$ss int$/$r that is /$n$rat$d a!to'ati&a112 "2 th$ data"as$ 'ana/$'$nt so t,ar$, s!&h as ;ra&1$ or SDL S$r)$r, Th$ )a1!$s ar$ !s!a112 &ons$&!ti)$ int$/$rs, startin/ ,ith 1,2,3,4 and so on.

No, ,$ &an s$$ ho, !s$ !1 o!r id$nti i$rs &an "$ "$&a!s$ ,$ &an in&1!d$ th$ %$rson and $sta"1ish'$nt id$nti i$rs in o!r )isits ta"1$. Th$n th$ P$rson5I* i$1d "$&o'$s a 1in# to a r$&ord or a %$rson in th$ P$rson Ta"1$. This 1in# is ,hat is &a11$d a /oreign +e and ,$ &an s$$ it<s sho,n ,ith </+< on th$ 1$ thand sid$.

Williams | Learn Data Modeling by Example - Part 1 "/

".2 Products and Product T !es


@*i'%1$A: To"2, ,h$n ,$ /o into a sho% ,$ ,ant to "!2 so'$thin/. +nd th$r$ ar$ tho!sands and tho!sands o %ossi"i1iti$s. =o, do ,$ d$a1 ,ith a11 that in o!r 1itt1$ data 'od$1C @To"2A: -$11 *i'%1$, it<s r$a112 (!it$ $as2. It<s 1i#$ a11 o!r 'od$1in/ ,h$r$ ,$ 1oo# or si'%1$ %att$rns that &o)$r 'an2 sit!ations. @*i'%1$A: ='' - I don<t #no, ,hat that '$ans. 0a2"$ i 2o! sho,$d '$ I 'i/ht !nd$rstand it. @To"2A: ;>. E)$r2thin/ that ,$ "!2 is &a11$d a %rod!&t, and a11 ,$ ha)$ to do is si'%12 d$ in$ th$ t2%$ o $a&h %rod!&t - s!&h as a &o $$, '! in or a n$,s%a%$r.

Th$n ,$ dra, a 1itt1$ "o6 &a11$d Products and sa2 that $)$r2 %rod!&t has a t2%$. In oth$r ,ords, th$r$ is a r$1ationshi% "$t,$$n th$ Products and Product_Types "o6$s.

Th$ 1in$s ar$ &a11$d relationshi!s and th$2 ar$ )$r2 i'%ortant in data 'od$1in/. -$ ar$ no, &r$atin/ an Entit -.elationshi! Diagram or HE.DH. This dia/ra' sho,s on12 a 1in$ or th$ r$1ationshi%:

Th$ s2'"o1 at th$ %rod!&ts $nd is &a11$d crows feet and it sho,s th$ many $nd. Th$ short strai/ht 1in$ at th$ Prod!&t5T2%$s $nd sho,s th$ one $nd. In oth$r ,ords, this 1in$ sho,s a on$-to-'an2 r$1ationshi%.

Williams | Learn Data Modeling by Example - Part 1 "*

*i'%1$, 1$t '$ $6%1ain a"o!t th$ dott$d 1in$. It '$ans that th$ r$1ationshi% r$s!1ts in a or$i/n #$2 in th$ Prod!&ts Ta"1$. This is sho,n "2 th$ KF>H s2'"o1 n$6t to th$ product_type_code i$1d and it '$ans that th$r$ is a 1in# "a&# to th$ Prod!&t5T2%$s. =o,$)$r, th$ %ri'ar2 #$2 is on12 th$ Prod!&t5I*, and o &o!rs$, this is sho,n "2 th$ KP>H s2'"o1 n$6t to th$ Product3ID i$1d. Lat$r, ,h$n ,$ ta1# a"o!t inh$ritan&$, ,$ ,i11 !s$ a strai/ht 1in$, in &ontrast to this dott$d 1in$ h$r$. This is to sho, that th$ or$i/n #$2 i$1d is a1so a %ri'ar2 #$2.

I ha)$ to sa2 so'$thin/ a "it di i&!1t a"o!t %ri'ar2 #$2s ri/ht no,. In th$ Prod!&ts Ta"1$, ,$ ha)$ to a11o, or a )$r2 1ar/$ n!'"$r o %rod!&ts "$in/ stor$d. Th$r$ or$ ,$ !s$ an I* i$1d or th$ Pri'ar2 #$2. -$ th$n &r$at$ this I* i$1d a!to'ati&a112 as a n!'"$r L&a11$d an a!to-in&r$'$nt int$/$rJ. This n!'"$r has no '$anin/ and is si'%12 !s$d to id$nti 2 $a&h r$&ord !ni(!$12 a'on/ %ossi"12 'i11ions or h!ndr$ds o 'i11ions. =o,$)$r, thin/s ar$ di $r$nt or t !e i$1ds. Th$s$ ar$ ,hat ,$ &a11 $n!'$rat$d data and ar$ t2%i&a112 r$ $r$n&$ data. Th$2 ar$ a1,a2s r$1ati)$12 s'a11 in n!'"$r and ,$ &hoos$ a &od$ or th$ %ri'ar2 #$2 "$&a!s$ ,$ &an &r$at$ th$' and r$)i$, th$' 'an!a112. It a1so h$1%s !s to &r$at$ a &od$ that ,$ &an !s$ and r$ $r to, in &ontrast to th$ I* i$1ds that ha)$ no '$anin/. T2%i&a1 $6a'%1$s ,o!1d "$:

SiB$s O S'a11, 0$di!' and Lar/$ ,h$r$ ,$ ar$ a&&!sto'$d to s$$in/ S,0 and L. P$nd$r O 0a1$ and F$'a1$, ,h$r$ ,$ !s$ 0, F and E or En#no,n.

Williams | Learn Data Modeling by Example - Part 1 "$


This '$n! "oard sho,s a t2%i&a1 '$n! in a T!r#ish r$sta!rant that s$r)$s a ,id$ ran/$ o ood and drin#.

-$ &an s$$ that th$2 ar$ or/aniB$d in /ro!%s, 1i#$ d$ss$rts and hot and &o1d drin#s, and $a&h o th$s$ has %rod!&ts, 1i#$ a%%1$ "a#1a)a or t!r#ish &o $$. This to%-do,n or/aniBation is &a11$d a hierarch and a%%$ars a11 o)$r th$ %1a&$ in o!r ,or1d. L!&#i12 ,$ &an sho, this )$r2 $asi12 and n$at12 in o!r data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 '&

".4 Products5 T !es and Product 6ierarchies


@*i'%1$A: To"2, ,h$n ,$ 1oo# &1os$12 at th$ '$n! to tr2 to d$&id$ ,hat to ord$r ,$ &an s$$ 1ots o %ossi"i1iti$s B!t a t$r a ,hi1$ ,$ &an s$$ a %att$rn that h$1%s !s d$&id$. =o, do ,$ d$a1 ,ith a11 that in o!r 1itt1$ data 'od$1C @To"2A: -$11 *i'%1$, it<s r$a112 (!it$ $as2. -$ d$ in$ so'$thin/ &a11$d a hierarch . =i$rar&hi$s ar$ )$r2 &o''on and si'%12 '$an an2 sit!ation ,h$r$ th$r$ ar$ %ar$nts, &hi1dr$n, /rand&hi1dr$n and so on. I ,$ 1oo# at this '$n! "oard at th$ to% ,$ &an s$$ h$adin/s sa2in/ K*$ss$rtsH and "$1o, K=ot and 9o1d B$)$ra/$sH.

So in this &as$, th$ to%-1$)$1 o o!r hi$rar&h2 is KFood and *rin#H. KFoodH has 7!st on$ &at$/or2, ,hi&h is K*$ss$rtsH. K*rin#H has t,o &at$/ori$s, ,hi&h ar$ K9o1d *rin#sH and K=ot *rin#sH. Th$n K9o1d *rin#sH has t,o &at$/ori$s, ,hi&h ar$ K+%%1$-Tr$$H and K;th$rH.

ME()

DESSERTS

HOT BE ER!" E L#ST

COLD BE ER!" E L#ST

!pple Tree $%i&es

Other Cold Be'erages

Williams | Learn Data Modeling by Example - Part 1 '1

@*i'%1$A: I thin# I !nd$rstand that, it so!nds ;>. @To"2A: Fina112, ,$ sho, this hi$rar&h2 "2 a dott$d 1in$ in th$ to%-ri/ht hand &orn$r in th$ $ntit2 &a11$d <?$ 5T2%$s5o 5Prod!&ts<. This is or'a112 &a11$d a Recursive or Reflexive r$1ationshi% and is in or'a112 &a11$d rabbit ears.

Williams | Learn Data Modeling by Example - Part 1 '2 ".17 T !es of Peo!le
@*i'%1$A: To"2, that 1oo#s ;>. I /!$ss ,$ &an d$a1 ,ith t2%$s o %$o%1$ th$ sa'$ ,a2, &an ,$C @To"2A: :$s, *i'%1$, and t2%$s o $sta"1ish'$nts as ,$11. @*i'%1$A: ;>, that so!nds s$nsi"1$. +nd do th$2 !s$ th$s$ id$nti i$rs in a data"as$C @To"2A: :$s, and ,hat is $)$n "$tt$r is that th$ data"as$ ,i11 a!to'ati&a112 /$n$rat$ a n$, !ni(!$ id$nti i$r or 2o! and 2o!r )isits and %!r&has$s i 2o! ,ant to /$t a r$ !nd 1at$r.

".11 T !es of Peo!le and Establishments


@*i'%1$A: To"2, that 1oo#s ;>. I /!$ss ,$ &an d$a1 ,ith t2%$s o $sta"1ish'$nts th$ sa'$ ,a2, &an ,$C @To"2A: :$s, *i'%1$. @*i'%1$A: ;>, that so!nds s$nsi"1$. +nd do th$2 !s$ th$s$ id$nti i$rs in a data"as$C @To"2A: :$s, and ,$ &an !s$ o!r n$, !ni(!$ id$nti i$r or 2o! and 2o!r )isits and %!r&has$s in &as$ ,$ ,ant to #$$% tra&# o thin/s. Li#$ 'a2"$ 2o! ,ant to /$t a r$ !nd 1at$r so ,$ n$$d to /$t 2o!r d$tai1s ro' th$ data"as$.

Williams | Learn Data Modeling by Example - Part 1 '"

@To"2A: B$ or$ ,$ 'o)$ on, 1$t<s ta1# a"o!t $sta"1ish'$nts. In T!r#$2, th$r$ ar$ 'an2 di $r$nt #inds o $sta"1ish'$nts, 1i#$ sho%s, "an#s, &a $s, r$sta!rants, hot$1s, hos%ita1s, /ara/$s and so on. B!t ,h$n ,$ thin# a"o!t th$s$ thin/s, ,$ ind that ,$ &an si'%12 it th$' into o!r d$ inition o $sta"1ish'$nts and id$nti 2 th$' as di $r$nt t2%$s o $sta"1ish'$nts.

".12 8isits and Purchases9


=$r$ ,$ &an s$$ t,o )isitors ta#in/ to a sta11ho1d$r in a BaBaar.

Williams | Learn Data Modeling by Example - Part 1 ''

@*i'%1$A: To"2, ,ith so 'an2 to!rists, sta11s, sho%s and thin/s to "!2, ho, do ,$ #$$% tra&# o $)$r2thin/C @To"2A: -$11, *i'%1$, "2 this ti'$, $)$r2thin/ has its o,n id$nti i$r that is !s$d ,h$r$)$r th$2 n$$d to #$$% tra&#. @*i'%1$A: ;>, that so!nds s$nsi"1$. +nd do ,$ !s$ th$s$ id$nti i$rs in a data"as$C

@To"2A: :$s, *i'%1$, and in this dia/ra', ,$ &an s$$ that ,$ &an !s$ th$ !ni(!$ id$nti i$rs that ar$ sho,n as KP>,H or %ri'ar2 #$2s. -$ &an s$$ that ,$ ha)$ a P> or $)$r2 $ntit2 or ta"1$ so ,$ &an "$ %r$tt2 s!r$ ,$ &an /$t ro' an2 ta"1$ to an2 oth$r ta"1$. This is &a11$d navigating aro!nd th$ data 'od$1 and is a /ood t$st or a ,$11-d$si/n$d data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 ') ".1" Peo!le and Inheritance
@To"2A: *i'%1$, 1$t<s ta#$ a &1os$r 1oo# at th$ di $r$nt t2%$s o %$o%1$ ,$ &an ind in Istan"!1. @*i'%1$A: ;>, To"2. I ho%$ I don<t ha)$ to thin# too '!&h "$&a!s$ I 'i/ht /$t a h$ada&h$C

@To"2A: No, *i'%1$, I ,i11 do th$ thin#in/ and ta1#in/ and a11 2o! ha)$ to do is nod 2o!r h$ad ,h$n 2o! !nd$rstand. @*i'%1$A: ;>, To"2. I %ro'is$ to do that. @To"2A: -$ a1r$ad2 said that ,$ ha)$ 1o&a1 %$o%1$ and to!rists. Th$r$ ar$ a1,a2s 1ots o %$o%1$ )isitin/ th$ B1!$ 0os(!$. -h$n ,$ 1oo# at this t2%i&a1 str$$t s&$n$, ,$ &an s$$ sho%%$rs, sta11ho1d$rs, ,or#$rs and 1o&a1 %$o%1$.

-$ !s!a112 #no, di $r$nt thin/s a"o!t th$ sta11ho1d$rs and ,or#$rs than th$ thin/s ,$ #no, a"o!t th$ to!rists. For $6a'%1$, ,$ ,i11 %ro"a"12 #no, th$ /$nd$r o $)$r2"od2 7!st "2 1oo#in/ at th$'. For ,or#$rs, ,$ 'i/ht a1so #no, thin/s r$1at$d to th$ir $'%1o2'$nt, s!&h as th$ir dat$ o "irth and th$ir ho'$ addr$ss.

Williams | Learn Data Modeling by Example - Part 1 '.

In data 'od$1in/ ,$ ha)$ a )$r2 %o,$r !1 a%%roa&h that ,$ &a11 Inheritance that ,$ &an !s$ h$r$. I ,$ ,ant to d$s&ri"$ this in En/1ish, ,$ ,o!1d sa2 that sta inh$rit th$ P$o%1$5T2%$59od$ and /$nd$r ro' th$ %ar$nt $ntit2 o %$o%1$, and in addition, th$2 ha)$ a dat$ o "irth and ho'$ addr$ss. For to!rists, ,$ donHt #no, '!&h, $6&$%t or th$ dat$ o th$ir )isit, and 'a2"$, i th$2 "!2 so'$thin/ in a sho% !sin/ a &r$dit &ard, th$n th$ sho% ,o!1d #no, th$ &r$dit &ard d$tai1s. *o$s that 'a#$ s$ns$, *i'%1$C @*i'%1$A: I thin# so, To"2. Is it 1i#$ sa2in/ that ,$ inh$rit ha)in/ t,o ar's and t,o 1$/s ro' o!r %ar$nts "$&a!s$ th$2 ha)$ t,o ar's and t,o 1$/s, "!t that ,$ ha)$ a1so ha)$ thin/s that ar$ 7!st !sC @To"2A: :$s, *i'%1$ - that<s /r$at - 1$t<s ta#$ a "r$a# and do so'$ sho%%in/G @*i'%1$A: I 1i#$ th$ so!nd o that, To"2. 9an I ha)$ an i&$ &r$a'C @To"2A: :$s, o &o!rs$, *i'%1$ O this dia/ra' sho,s ,$ ar$ doin/ ,$11. It sho,s inh$ritan&$ "$t,$$n %$o%1$ and th$ t,o di $r$nt t2%$s o %$o%1$:

Williams | Learn Data Modeling by Example - Part 1 '/

-$ &an s$$ a i$1d 'ar#$d as KPFH in th$ ta"1$s or sta

and to!rists.

This is !n!s!a1 "$&a!s$ it '$ans a i$1d that is a Pri'ar2 >$2 in th$ thr$$ ta"1$s and a1so a /or$i/n >$2 to th$ P$o%1$ Ta"1$. Th$r$ or$, i 2o!r irst r$&ord ,as a '$'"$r o sta , th$n ,$ ,o!1d ha)$ a r$&ord in th$ P$o%1$ Ta"1$ ,ith a P$rson5I* o 1 and a r$&ord in th$ sta ta"1$ ,ith a Sta 5I* o 3. Si'i1ar12, i o!r s$&ond r$&ord ,as a to!rist, ,$ ,o!1d ha)$ a r$&ord in th$ P$rson Ta"1$ ,ith a P$rson5I* o 2 and a r$&ord in th$ to!rist ta"1$ ,ith a Sta 5I* o 3.

".1% )taff5 Establishments and Deri'ed /ields


@*i'%1$A: To"2, ho, do ,$ s%$&i 2 that sta '!st ,or# in so'$ $sta"1ish'$ntC

@To"2A: *i'%1$, that<s a )$r2 /ood (!$stion. Fort!nat$12, th$ ans,$r is )$r2 $as2. -$ add a on$-to-'an2 r$1ationshi% "$t,$$n th$ sta

and $sta"1ish'$nt $ntiti$s

Williams | Learn Data Modeling by Example - Part 1 '*


In En/1ish, ,$ ,o!1d sa2 that $)$r2 '$'"$r o sta '!st ,or# in on$ $sta"1ish'$nt and $)$r2 $sta"1ish'$nt &an $'%1o2 'an2 '$'"$rs o sta . In th$ dia/ra', ,$ sho, this ,ith a /oreign +e "2 th$ Esta"1ish'$nt5I* i$1d in th$ sta $ntit2. So i ,$ 1oo# &1os$12 at th$ sta $ntit2, ,$ ,i11 s$$ 1/+1 "2 th$ Esta"1ish'$nt5I* i$1d. @*i'%1$A: ;>, that so!nds /ood, and I &an s$$ ho, th$ id$nti i$rs ar$ )$r2 i'%ortant. @To"2A: I a' /1ad to h$ar it, *i'%1$. Th$r$ is on$ 'or$ thin/ I ha)$ to sa2. -$ ar$ 1$arnin/ data 'od$1in/ and on$ i'%ortant thin/ a"o!t data 'od$1in/ is that it has to o11o, a s$t o rules. Th$s$ r!1$s h$1% !s to %rod!&$ /ood data 'od$1s and so th$2 ar$ )$r2 i'%ortant. ;n$ o th$ r!1$s is that ,$ &annot in&1!d$ an2 "its o data that &an "$ d$ri)$d ro' an2 oth$r "its o data. For $6a'%1$, ,$ !s!a112 ,ant to #no, ho, 'an2 %$o%1$ ,or# in a sho% or &a $. Th$r$ or$ ,$ in&1!d$ a staff Count i$1d ,ith th$ $sta"1ish'$nt. B!t ,h$n it &o'$s to indin/ th$ )a1!$ that /o$s in h$r$, ,$ ,i11 &o!nt th$ r$&ords in th$ Sta Ta"1$ or $a&h $sta"1ish'$nt. Th$r$ or$, it<s a deri'ed /ield and ,$ &a11 it a na'$ that starts ,ith <d$ri)$d5< to 'a#$ thin/s &1$ar. This is "$&a!s$, a&&ordin/ to th$ r!1$s, ,$ sho!1d not in&1!d$ d$ri)$d i$1ds in o!r data 'od$1 at this $ar12 sta/$. I ha)$ sho,n it h$r$ si'%12 as an $6a'%1$ "$&a!s$ it is a sit!ation that o&&!rs (!it$ o t$n so itHs /ood to r$&o/niB$ it ,h$n 2o! s$$ it.

*o$s that so!nd s$nsi"1$, *i'%1$C @*i'%1$A: I s!%%os$ so, To"2. B!t I<)$ /ot a h$ada&h$, &an ,$ /o to Star"!&#s no,C

".1( .eser'ations and >eneric Data Models


@To"2A: *i'%1$, this "it is (!it$ hard-/oin/ so i 2o! ,ant to ta#$ a r$st, thatHs ;>. @*i'%1$A: ;>, To"2, I ,i11 7!st sit (!i$t12 and ,at&h th$ %$o%1$ I0J

Williams | Learn Data Modeling by Example - Part 1 '$


@To"2A: P$o%1$ 'a#$ r$s$r)ations $)$r2 da2 a11 aro!nd th$ ,or1d. Th$s$ r$s$r)ations ha)$ a 1ot in &o''on: =ot$1 "oo#in/s, air1in$ "oo#in/s, th$atr$s and sho,s, a%%oint'$nts to s$$ a do&tor or d$ntist and so on. Th$ "asi& &o''on thin/s ar$ a dat$ and ti'$, !s!a112 a s%$&i i& a&i1it2, 1i#$ a hot$1, an air1in$ s$at, a th$atr$ and so on.

This '$ans that ,$ &an id$nti 2 ,hat th$2 ha)$ in &o''on and ,hat th$2 ha)$ that is di $r$nt and s%$&i i& to th$ t2%$ o a%%oint'$nt.

Williams | Learn Data Modeling by Example - Part 1 )&


".12.1 .eser'ations for a 6otel =$r$ is a )$r2 "$a!ti !1 and !ni(!$ hot$1 in th$ &a)$s at :!na# E)1$ri La"o!t 400 #' ro' Istan"!1J, ,hi&h has roo's datin/ "a&# to th$ 3th &$nt!r2. For a hot$1, o &o!rs$, 2o! ,o!1d "oo# or a s%$&i i& ni/ht Lor ni/htJ and 'a2"$ a nons'o#in/ roo' "!t that is a"o!t a11.

6otel in the Ca'es at ?una0 E'leri5 Tur0e

Williams | Learn Data Modeling by Example - Part 1 )1

".12.2 .eser'ations for Whirling Der'ishes + )$r2 !n!s!a1 s%$&ta&1$ that is !ni(!$ to T!r#$2 is th$ si/ht o -hir1in/ *$r)ish$s dan&in/. It is %art o th$ 0!s1i' r$1i/io!s %ra&ti&$ o th$ dis&i%1$s For this r$s$r)ation, 2o! ,o!1d "oo# or a s%$&i i& sho, and a s$at at th$ %ri&$ 2o! ,ant$d.

".12." >eneric Data Model for .eser'ations In this 'od$1, ,$ d$ in$ a a&i1it2 to "$ ,hat ,$ ar$ 'a#in/ a r$s$r)ation or. This data 'od$1 is sho,n on this %a/$ o o!r *ata"as$ +ns,$rs -$" sit$:

htt%:44,,,.data"as$ans,$rs.or/4data5'od$1s4/$n$ri&5r$s$r)ations4/$n$ri&5r$s$r) ations5inh$ritan&$5 or5t!r#$2.ht'

Williams | Learn Data Modeling by Example - Part 1 )2

".1* .eference Data


@To"2A: *i'%1$, 2o! &an s$$ that I a' !sin/ a P$nd$r Ta"1$ and P$o%1$ T2%$s Ta"1$. I ha)$ /i)$n th$' "oth na'$s that "$/in ,ith <r$ 5< to 'a#$ it &1$ar that th$2 ar$ r$ $r$n&$ data.

This '$ans that th$ )a1!$s don<t &han/$ '!&h and I &an !s$ th$' to d$ in$ ,hat th$ )a1id )a1!$s &an "$. This is a t$&hni(!$ that %ro $ssiona1 data 'od$1$rs !s$ "!t ,$ don<t n$$d to ,orr2 a"o!t it toda2. @*i'%1$A: I<' /1ad to h$ar it, To"2G +1tho!/h it isnHt di i&!1t to !nd$rstand and it s$$'s 1i#$ a /ood id$a. @To"2A: In o!r s'a11 $6a'%1$, ,$ ha)$ on12 o!r #inds o r$ $r$n&$ data a1to/$th$r /$nd$r, t2%$s o $sta"1ish'$nt, %$o%1$ and %rod!&ts.

Williams | Learn Data Modeling by Example - Part 1 )"

".1- :ringing it all Together


@To"2A: *i'%1$, i ,$ "rin/ to/$th$r $)$r2thin/ ,$ ha)$ ta1#$d a"o!t, ,$ ,i11 s$$ that ,$ ha)$ (!it$ a /ood data 'od$1 that an2 %ro $ssiona1 ,o!1d "$ %ro!d o . @*i'%1$A: ;>, To"2. *o 2o! thin# I ,i11 !nd$rstand itC @To"2A: L$t '$ h$1% 2o! "2 'a#in/ a 1ist o th$ business rules or o!r 'od$1:

P$o%1$ &an "$ $ith$r sta

or to!rists.

Th$r$ ar$ a n!'"$r o $sta"1ish'$nts o di $r$nt t2%$s. To!rists &an 'a#$ )isits to $sta"1ish'$nts and 'a#$ %!r&has$s. Sta assist th$ to!rists ,h$n th$2 'a#$ a %!r&has$.

+ %!r&has$ in)o1)$s on$ or 'or$ %rod!&ts.

@To"2A: ;>, *i'%1$ - ,$ ha)$ a )$r2 ni&$ data 'od$1 and no, ,$ &an ta#$ th$ "r$a# I %ro'is$d 2o!. @*i'%1$A: That<s /r$at, To"2 - &an ,$ /o to Star"!&#sC @To"2A: S!r$, "!t "$ or$ ,$ do I sho!1d sa2 so'$thin/ a"o!t P/, ,hi&h a%%$ars in th$ Sta Ta"1$. It<s !n!s!a1 and it<s &a11$d P/ "$&a!s$ it '$ans a i$1d ,hi&h is a Pri'ar2 >$2 in th$ Sta Ta"1$ and a /or$i/n >$2 to th$ P$o%1$ Ta"1$. @*i'%1$A: =''', I<)$ /ot a h$ada&h$, To"2 - &an ,$ %1$as$ /o to Star"!&#sC

Williams | Learn Data Modeling by Example - Part 1 )'

@To"2A: ;>, *i'%1$. :o!<)$ "$$n a )$r2 /ood /ir1 and 2o! d$s$r)$ a "r$a#. :o! &an ad'ir$ ,hat ,$ ha)$ &r$at$d, ,hi&h is this )$r2 %ro $ssiona1-1oo#in/ data 'od$1.

".12 To!-#e'el Model ;ith <ames =nl


-$ &an sho, o!r data 'od$1 at th$ to%-1$)$1, sho,in/ on12 th$ na'$s o th$ Kthin/s o int$r$st,H ,hi&h ,$ &a11 $ntiti$s or ta"1$s i ,$ ar$ thin#in/ a"o!t a data"as$. This is s!ita"1$ or $6%1ainin/ ,hat ,$ sa, in -indsor to o!r a'i12 or ri$nds. I ,$ ,ant$d to d$s&ri"$ it, ,$ &o!1d si'%12 sa2:

Th$r$ ar$ 1ots o %$o%1$ in -indsor, in&1!din/ &$r$'onia1 /!ards, sta Th$r$ ar$ a1so 1ots o $sta"1ish'$nts, 1i#$ sho%s and th$ 9ast1$.

and to!rists.

To!rists 'ad$ )isits to $sta"1ish'$nts ,h$r$ th$2 'ad$ %!r&has$s o %rod!&ts.

Williams | Learn Data Modeling by Example - Part 1 )) ".14 To!-#e'el Model ;ith +e /ields
This is ,hat o!r data 'od$1 1oo#s 1i#$ i ,$ sho, >$2 i$1ds on12 and 1$a)$ o!t th$ ?$ $r$n&$ *ata Ta"1$s. This 1$)$1 o dis%1a2 is s!ita"1$ i ,$ ,ant to &on ir' to $a&h oth$r ho, th$ ta"1$s Lor $ntiti$sJ ar$ r$1at$d.

Williams | Learn Data Modeling by Example - Part 1 ). ".27 To!-#e'el Model ;ith all Details
Fina112, this is ,hat o!r data 'od$1 1oo#s 1i#$ i ,$ sho, th$ #$2 i$1ds, a11 th$ data it$'s on12 and 'ost o th$ ?$ $r$n&$ *ata Ta"1$s. :o! &an s$$ that th$ a'o!nt o d$tai1 in)o1)$d 'a#$s it 'or$ di i&!1t to !nd$rstand ,hatHs /oin/ on and to id$nti 2 ,hat is i'%ortant. This 1$)$1 o dis%1a2 is s!ita"1$ i ,$ ,ant to ta1# a"o!t d$tai1s and d$)$1o% a data"as$ ro' o!r data 'od$1.

Williams | Learn Data Modeling by Example - Part 1 )/

".21 )tarbuc0s
@To"2A: *i'%1$, I<)$ /ot so'$ ,ond$r !1 n$,s or 2o!.

Williams | Learn Data Modeling by Example - Part 1 )*


@*i'%1$A: I<' /1ad to h$ar it, To"2 - ,hat is itC @To"2A: I ha)$ o!nd Star"!&#s h$r$ in T!r#$2, so 2o! &an ha)$ 2o!r a)orit$ thin/s to $at or drin# IJ @*i'%1$A: To"2, ar$ 2o! t$asin/ '$C @To"2A: No, *i'%1$ - 1oo#, th$r$ it is a&ross th$ road ro' th$ B1!$ 0os(!$G @*i'%1$A: -o, - that<s /r$at, so I &an ha)$ '2 a)orit$ '! in.

".22 What ha'e ;e learned?


In this &ha%t$r, ,$ ha)$ 1$arn$d ho, to thin# 1i#$ a data 'od$1$r and ho, to /rad!a112 %!t to/$th$r a data 'od$1 in o!r h$ads. -$ #no, that i ,$ /$t in th$ ha"it o doin/ this r$/!1ar12 it /$ts $asi$r and 'or$ nat!ra1 and soon ,$ ,i11 "$ s$$in/ th$ ,or1d aro!nd !s as %i$&$s o a data 'od$1 that ,$ &an it to/$th$r 1i#$ a 7i/sa, %!BB1$.

%. )ome :asic Conce!ts


%.1 Introduction
This &ha%t$r dis&!ss$s th$ "asi& &on&$%ts in data 'od$1in/. It "!i1ds thro!/h a s$ri$s o str!&t!r$d st$%s in th$ d$)$1o%'$nt o a data 'od$1. This &ha%t$r &o)$rs th$ "asi& &on&$%t that %ro)id$ th$ o!ndation or th$ data 'od$1 that ,$ d$si/n$d in si'i1ar 'at$ria1 to 9ha%t$r 1 "!t it is 'or$ s$rio!s and 'or$ &o'%r$h$nsi)$.

Williams | Learn Data Modeling by Example - Part 1 )$

This 'at$ria1 is a1so a)ai1a"1$ as a t!toria1 or +'aBon and Star"!&#s on th$ *ata"as$ +ns,$rs -$" sit$ O

htt%:44,,,.data"as$ans,$rs.or/4t!toria145data5'od$1in/4ind$6.ht'

-$ ,i11 &o)$r th$s$ "asi& &on&$%ts: a. 9r$atin/ Entiti$s ". Pri'ar2 and For$i/n >$2s &. ;n$-to-0an2 and 0an2-to-0an2 ?$1ationshi%s d. =i$rar&hi$s $. Inh$ritan&$ . ?$ $r$n&$ *ata

+t th$ $nd o this t!toria1, ,$ ,i11 ha)$ %rod!&$d a data 'od$1, ,hi&h is &o''on12 r$ $rr$d as an Entit2-?$1ationshi% *ia/ra', or <E?*<. %.1.1 What is this? This &ha%t$r is a d$s&ri%tion o th$ r$1ationa1 th$or2 as ori/ina112 $sta"1ish$d "2 T$d 9odd, ,ho, at th$ ti'$, ,as a r$s$ar&h s&i$ntist ,ith IB0. %.1.2 Wh is it im!ortant? Th$ "asi& &on&$%ts ar$ i'%ortant "$&a!s$ th$ r$1ationa1 th$or2 is )$r2 %o,$r !1 and %ro)id$s a so!nd th$or$ti&a1 o!ndation or data"as$s that ha)$ "$&o'$ $ss$ntia1 sin&$ th$ir irst a%%$aran&$ in th$ $ar12 1970s. Th$2 ,$r$ th$ &r$ation o a "ri11iant r$s$ar&h s&i$ntist &a11$d T$d 9odd, ,ho ,as ,or#in/ or an IB0 ?$s$ar&h La" at th$ ti'$. It is r$%ort$d that h$ a&$d int$rna1 &riti&is' initia112 "$&a!s$ it ,as &onsid$r$d that his n$, id$a ,o!1d a $&t sa1$s o $sta"1ish$d IB0 data"as$ %rod!&ts.

It is th$ o!ndation or so 'an2 a&ti)iti$s:

It %ro)id$s a )$hi&1$ or &o''!ni&ation a'on/ a ,id$ )ari$t2 o int$r$st$d %arti$s, in&1!din/ 'ana/$'$nt, d$)$1o%$rs, data ana12sts, *B+s and 'or$. + %h2si&a1 data"as$ &an $asi12 "$ /$n$rat$d ro' a data 'od$1 !sin/ a &o''$r&ia1 data 'od$1in/ too1.

Williams | Learn Data Modeling by Example - Part 1 .&

%.1." What Will I #earn? :o! ,i11 1$arn:

=o, to &r$at$ a data 'od$1, startin/ ro' s&rat&h. -hat a t2%i&a1 data 'od$1 1oo#s 1i#$.

%.2 What is the )co!e?


;!r %hoto sho,s a t2%i&a1 Star"!&#s. I ,$ 1oo# &1os$12, ,$ &an s$$ %$o%1$ $atin/, drin#in/ and %1a&in/ ord$rs. -hat Star"!&#s s$$s ar$ &!sto'$rs, %rod!&ts and ord$rs "$in/ '$t.

*!rin/ th$ &o!rs$ o this "oo# ,$ ,i11 s$$ ho, data 'od$1s &an h$1% to "rid/$ this /a% in %$r&$%tion and &o''!ni&ation.

>etting )tarted9 Th$ ar$a ,$ ha)$ &hos$n or this t!toria1 is a data 'od$1 or a si'%1$ =rder Processing ) stem or Star"!&#s. -$ ha)$ don$ it this ,a2 "$&a!s$ 'an2 %$o%1$ ar$ a'i1iar ,ith Star"!&#s and it %ro)id$s an a%%1i&ation that is $as2 to r$1at$ to.

Williams | Learn Data Modeling by Example - Part 1 .1


-$ thin# a"o!t th$ ar$a ,$ ar$ /oin/ to 'od$1. -$ &an s$$ &!sto'$rs ord$rin/ %rod!&ts L ood, drin#s and so onJ. ;!r a%%roa&h has thr$$ st$%s:

1 2 "

Esta"1ish th$ s&o%$ o th$ data 'od$1. Id$nti 2 th$ <thin/s o int$r$st< that ar$ ,ithin th$ s&o%$, Th$s$ ,i11 "$ &a11$d $ntiti$s. *$t$r'in$ th$ relationshi!s "$t,$$n th$'.

Deciding the )co!e of =ur Data Model -h$n ,$ st$% insid$, ,$ s$$ that Star"!&#s s$11s a ,id$ ran/$ o %rod!&ts, so o!r irst tas# is to d$&id$ ,hi&h o th$' sho!1d "$ in&1!d$d in o!r data 'od$1. ?i/ht no,, ,$ ar$ int$r$st$d on12 in so'$thin/ to $at and so'$thin/ to drin#. Th$r$ or$, a11 th$ '!/s and oth$r it$'s sho,n in this %i&t!r$ on th$ 1$ t, ar$ o!tsid$ th$ sco!e o o!r data 'od$1, and ar$ not <Thin/s o Int$r$st<.

%." What are the @Things of Interest$?


;!r irst st$% is to d$&id$ ,hat thin/s ar$ ,$ int$r$st$d in. In oth$r ,ords, ,hat is th$ s&o%$ o o!r data 'od$1C

Th$s$ thin/s ,i11 "$ &a11$d KEntiti$s in a *ata 0od$1H and KTa"1$s in a *ata"as$H.

%.% Creating Entities


Dezign is a data 'od$1in/ too1 that I !s$ $6t$nsi)$12 "$&a!s$ it is )$r2 /ood and )$r2 a orda"1$. :o! &an do,n1oad a r$$ tria1 ro' this -$" sit$: htt%:44,,,.datana'i&.&o'

Williams | Learn Data Modeling by Example - Part 1 .2

=$r$ is a 1ist o 'od$1in/ too1s on th$ *ata"as$ +ns,$rs -$" sit$: htt%:44,,,.data"as$ans,$rs.or/4'od$11in/5too1s.ht' This is ho, 2o! &r$at$ an $ntit2 in th$ *$Bi/n data 'od$1in/ too1: 1. ?i/ht-&1i&# on a "1an# ar$a in th$ dia/ra' 4. Fro' th$ dro%-do,n 1ist, &hoos$ nsert and !ntity 3. 9h$&# th$ PK "o6 or th$ %ri'ar2 #$2 attri"!t$, ,hi&h ,i11 !s!a112 "$ th$ irst on$ on th$ $ntit2. 7. 91i&# on "lose to sa)$ th$ r$s!1ts.

%.( Primar +e s
-$ d$&id$ that th$ thin/s ,$ ar$ int$r$st$d in ar$ &!sto'$rs, ord$rs and %rod!&ts. :o! &an "!2 a ran/$ o %rod!&ts in Star"!&#s, in&1!din/ so!)$nir '!/s, &o $$ and n$,s%a%$rs.

For th$ %!r%os$ o o!r irst 'od$1, ,$ r$stri&t o!r %rod!&ts to ood and drin#.

This dia/ra' sho,s th$ &orr$s%ondin/ $ntiti$s ,ith %ri'ar2 #$2s.

Williams | Learn Data Modeling by Example - Part 1 ." 1. +t this sta/$, ,$ sho, on12 th$ $ntiti$s ,ith no r$1ationshi%s and 'ini'!'

attri"!t$s and s%$&i 2 on12 th$ %ri'ar2 #$2 and on$ details i$1d that ,i11 "$ r$%1a&$d 1at$r on.

2. Th$ Primary Key i$1dLsJ sho!1d a1,a2s "$ irst. 3. :o! ,i11 noti&$ that th$ irst i$1d in th$ 9!sto'$rs5)$rsion2 Ta"1$ is th$
9!sto'$r5I*. ta"1$.

4. It has a PK s2'"o1 "$sid$ it, ,hi&h indi&at$s that it is th$ %ri'ar2 #$2 or th$ 3. Th$ %ri'ar2 #$2 is )$r2 i'%ortant and is th$ ,a2 that ,$ &an r$&o/niB$ $a&h
indi)id!a1 r$&ord in th$ ta"1$.

9r$atin/ a %ri'ar2 #$2 in th$ *$Bi/n too1: 1. ?i/ht-&1i&# on th$ !ntity 3. 9hoos$ #ttri$utes 6. 9h$&# th$ PK "o6 or th$ %ri'ar2 #$2 attri"!t$, ,hi&h ,i11 !s!a112 "$ th$ irst on$ on th$ $ntit2. 7. 91i&# on "lose to sa)$ th$ r$s!1ts.

%.* /oreign +e s
This dia/ra' sho,s $ntiti$s ,ith or$i/n #$2s. 9!sto'$r5I* is a or$i/n #$2 that 1in#s ord$rs to &!sto'$rs.

Williams | Learn Data Modeling by Example - Part 1 .'

=$r$ ,$ ha)$ add$d th$ relationshi!s "$t,$$n th$ $ntiti$s. -h$n this %ri'ar2 #$2 is !s$d in anoth$r ta"1$, it is r$ $rr$d to as a foreign key. -$ &an s$$ a /ood $6a'%1$ in this dia/ra', ,h$r$ th$ 9!sto'$r5I* a%%$ars in th$ ;rd$rs Ta"1$ as a or$i/n #$2. This is sho,n ,ith an <F>< s2'"o1 "$sid$ it. Mandator +e /ields + or$i/n #$2 is !s!a112 mandator . For $6a'%1$, a )a1!$ or a 9!sto'$r5I* in th$ 9!sto'$rs5Pa2'$nt50$thods Ta"1$ '!st &orr$s%ond to an a&t!a1 )a1!$ o th$ 9!sto'$r5I* in th$ 9!sto'$rs5M$rsion51 Ta"1$. This is sho,n in th$ dia/ra' "2 th$ short strai/ht 1in$ at th$ $nd o th$ dott$d 1in$ &1os$ to th$ 9!sto'$rs Ta"1$. /oreign +e s in the DeAign Tool For$i/n #$2s ar$ &r$at$d a!to'ati&a112 ,h$n 2o! 'a#$ a r$1ationshi% "$t,$$n t,o $ntiti$s. -$ r$&o''$nd that 2o! 'o)$ th$ i$1d !% in th$ $ntit2 so that it ta#$s it %1a&$ a1%ha"$ti&a112 a'on/ th$ #$2 i$1ds.

To do this, ri/ht-&1i&# on th$ $ntit2, &hoos$ th$ #ttri$utes o%tion, th$n &1i&# on th$ !% or do,n arro, on th$ ri/ht-hand sid$.

%.- =ne-to-Man .elationshi!s

Williams | Learn Data Modeling by Example - Part 1 .)

In this dia/ra', a &!sto'$r &an %1a&$ B$ro, on$ or 'an2 ord$rs. This d$ in$s a on$-to-'an2 r$1ationshi%.

This is sho,n "2 th$ s2'"o1 that has thr$$ s'a11 1in$s at that $nd o th$ r$1ationshi% dott$d 1in$, ,hi&h is r$ $rr$d to as crow%s feet. =!tional +e /ields Stri&t12 s%$a#in/, a &!sto'$r do$s not ha)$ to %1a&$ an ord$r. =$ or sh$ &o!1d &han/$ th$ir 'ind and ,a1# o!t ,itho!t ord$rin/ an2thin/. In oth$r ,ords, ,$ ,o!1d sa2 that th$ r$1ationshi% is o!tional at th$ ord$rs $nd. This is sho,n "2 th$ 1itt1$ & at that $nd o th$ r$1ationshi% dott$d 1in$.

+ data 'od$1$r ,o!1d sa2 QFor $)$r2 &!sto'$r, th$r$ &an "$ B$ro, on$ or 'an2 ord$rsR.

TE.M

DE/I<ITI=<

Williams | Learn Data Modeling by Example - Part 1 ..

9!sto'$r *$'and

+n2 !nit that &an rais$ a d$'and. + r$(!$st or ass$ts to "$ s!%%1i$d. Th$ or'at o a r$(!$st &an "$ an $1$&troni& '$ssa/$, a %a%$r or' and so on.

B!sin$ss ?!1$s: + &!sto'$r &an rais$ B$ro, on$ or 'an2 d$'ands. : + d$'and '!st "$ asso&iat$d ,ith a )a1id &!sto'$r.

%.2 Man -to-Man .elationshi!s


This dia/ra' sho,s a 'an2-to-'an2 r$1ationshi% "$t,$$n ord$rs and %rod!&ts. +n ord$r &an in&1!d$ 'an2 %rod!&ts and a %rod!&t &an a%%$ar on 'an2 ord$rs.

This d$ in$s a 'an2-to-'an2 r$1ationshi% and is sho,n in a data 'od$1 as o11o,s:

+ 'an2-to-'an2 r$1ationshi% &annot "$ i'%1$'$nt$d in r$1ationa1 data"as$s. Th$r$ or$ ,$ r$so1)$ this 'an2-to-'an2 into t,o on$-to-'an2 r$1ationshi%s, ,hi&h ,$ sho, in a data 'od$1 as o11o,s:

So'$ti'$s it is !s$ !1 to s$$ th$ #$2 i$1ds to $ns!r$ that $)$r2thin/ 1oo#s a1ri/ht.

Williams | Learn Data Modeling by Example - Part 1 ./

-h$n ,$ 1oo# &1os$12 at this data 'od$1, ,$ &an s$$ that th$ %ri'ar2 #$2 is &o'%os$d o th$ ;rd$r5I* and Prod!&t5I* i$1ds.

This r$ 1$&ts th$ !nd$r12in/ 1o/i&, ,hi&h stat$s that $)$r2 &o'"ination o ord$r and %rod!&t is !ni(!$.

In th$ data"as$, this ,i11 d$ in$ a n$, r$&ord.

-h$n ,$ s$$ this sit!ation in a data"as$, ,$ &an sa2 that this r$ 1$&ts a 'an2-to-'an2 r$1ationshi%.

=o,$)$r, ,$ &an a1so sho, th$ sa'$ sit!ation in a s1i/ht12 di $r$nt ,a2, ,hi&h r$ 1$&ts th$ standard d$si/n a%%roa&h o !sin/ a s!rro/at$ #$2 as th$ %ri'ar2 #$2 and sho,in/ th$ d$'and and %rod!&t I*s si'%12 as or$i/n #$2s.

Williams | Learn Data Modeling by Example - Part 1 .*


+ s!rro/at$ #$2 is si'%12 a #$2 that stands or so'$thin/ $1s$. -$ !s$ on$ ,h$n it is a "$tt$r d$si/n or is si'%12 'or$ &on)$ni$nt. It is a '$anin/1$ss int$/$r that is /$n$rat$d a!to'ati&a112 "2 th$ data"as$ 'ana/$'$nt so t,ar$, s!&h as ;ra&1$ or SDL S$r)$r, Th$ )a1!$s ar$ !s!a112 &ons$&!ti)$ int$/$rs, startin/ ,ith 1,2,3,4 and so on.

Th$ "$n$ it o this a%%roa&h is that it a)oids th$ o&&!rr$n&$ o %ri'ar2 #$2s ,ith too 'an2 i$1ds i 'or$ d$%$nd$nt ta"1$s o&&!r ,h$r$ th$2 &as&ad$ do,n,ards.

Th$ "$n$ it o th$ %r$)io!s a%%roa&h is that it a)oids th$ %ossi"i1it2 o orphan r$&ords in th$ Prod!&ts in a *$'and Ta"1$.

In oth$r ,ords, in)a1id r$&ords that ha)$ in)a1id d$'and I* and4or %rod!&t I* )a1!$s.

Williams | Learn Data Modeling by Example - Part 1 .$

TE.M
;rd$r

DE/I<ITI=<
+ r$(!$st or %rod!&ts to "$ s!%%1i$d. Th$ or'at o a r$(!$st &an "$ )$r"a1, an $1$&troni& '$ssa/$, a %a%$r For', $t&.

Prod!&t

+n It$' that &an "$ s!%%1i$d on r$(!$st. It &an "$ so'$thin/ s'a11, 1i#$ a '! in, or so'$thin/ that &ontains oth$r %rod!&ts, 1i#$ a sand,i&h ,ith '!1ti%1$ i11in/s.

B!sin$ss ?!1$s: +n ord$r &an r$ $r to B$ro or 'an2 %rod!&ts. : + %rod!&t &an a%%$ar in B$ro, on$ or 'an2 ord$rs. : -$ &an a1so sa2 Q+n ord$r &an r$ $r to 'an2 %rod!&ts and a %rod!&t &an a%%$ar in 'an2 ord$rsR. : In oth$r ,ords, th$r$ is a 'an2-to-'an2 r$1ationshi% "$t,$$n ord$rs and %rod!&ts.

%.4 6ierarchies and .abbit Ears


=i$rar&hi$s ar$ )$r2 &o''on and ,$ &an s$$ th$' a11 aro!nd !s. Fort!nat$12, ,$ &an hand1$ th$' $)$r2 $asi12 in data 'od$1s.

Williams | Learn Data Modeling by Example - Part 1 /&

This dia/ra' sho,s ho, th$ hi$rar&hi$s o %rod!&ts and %rod!&t t2%$s that ,$ ha)$ 7!st dis&!ss$d ar$ sho,n in o!r Entit -.elationshi! Diagram.

:o! ,i11 noti&$ that th$ ta"1$ &a11$d <Prod!&t5T2%$s< has a dott$d 1in$ &o'in/ o!t on th$ ri/ht-hand sid$ and /oin/ "a&# in a/ain on th$ to%-ri/ht &orn$r. *ata ana12sts &a11 this a recursive or reflexive r$1ationshi%, or in or'a112, si'%12 ra$$it ears. In %1ain En/1ish, ,$ ,o!1d sa2 that th$ ta"1$ is 7oin$d to its$1 and it '$ans that a r$&ord in this ta"1$ &an "$ r$1at$d to anoth$r r$&ord in th$ ta"1$. This a%%roa&h is ho, ,$ hand1$ th$ sit!ation ,h$r$ $a&h %rod!&t &an "$ in a hi$rar&h2 and r$1at$d to anoth$r Prod!&t. For $6a'%1$, a %rod!&t &a11$d Panini &o!1d "$ in a %rod!&t s!"-&at$/or2 &a11$d <0is&$11an$o!s Sand,i&h$s< ,hi&h &o!1d "$ a hi/h$r %rod!&t &at$/or2 &a11$d <9o1d Food,H ,hi&h its$1 &o!1d "$ in a hi/h$r %rod!&t s!%$r-&at$/or2 &a11$d si'%12 <Food<. N$6t ti'$ 2o! /o into Star"!&#s, ta#$ a 1oo# at th$ "oard "$hind th$ &o!nt$r and tr2 to d$&id$ ho, 2o! ,o!1d d$si/n th$ %rod!&ts ar$a o th$ data 'od$1. :o! sho!1d !a s!ecial attention to th$ 1itt1$ <B$ros< at $a&h $nd o th$ dott$d 1in$. Th$s$ ar$ ho, ,$ i'%1$'$nt th$ a&t that th$ Par$nt Prod!&t T2%$ 9od$ is o%tiona1, "$&a!s$ th$ hi/h$st 1$)$1 ,i11 not ha)$ a %ar$nt.

This t!toria1 is a1so a)ai1a"1$ on th$ *ata"as$ +ns,$rs -$" sit$:

htt%:44,,,.data"as$ans,$rs.or/4t!toria145data5'od$1in/4ind$6.ht'

+ n!'"$r o data 'od$1s sho, $6a'%1$s o inh$ritan&$, in&1!din/:

9hariti$s 9it2 To!rist P!id$ 90*B - 9on i/!ration 0/t *B 9!sto'$rs 9o''$r&ia1 and P$rsona1 E)$nt ?$/istrations Pa'$s Stor$ Ins!ran&$ Bro#$rs Li"rari$s or La,2$rs Nationa1 Tr!st LE>J N$, E// Photo 9ata1o/s

Williams | Learn Data Modeling by Example - Part 1 /1


S&hoo1 0ana/$'$nt S2st$'s Shr$# 2 0o)i$ Tra&#in/ 0an! a&t!r$d It$'s Tra)$1 S To!ris' -or1d,id$ M$hi&1$ I'%orts

&n EBam!le in the Militar


-$ start ,ith th$ d$ inition o a Enit, ,hi&h at its si'%1$st, 1oo#s 1i#$ this:

In this &as$, ,$ !s$ a '$anin/1$ss I* or th$ !nit I* ,hi&h is si'%12 a !ni(!$ n!'"$r.

Th$n ,$ thin# a"o!t th$ a&t that $)$r2 !nit is %art o a 1ar/$r or/aniBation.

In oth$r ,ords, $)$r2 !nit r$%orts to a hi/h$r 1$)$1 ,ithin th$ o)$ra11 or/aniBation.

Fort!nat$12, ,$ &an sho, this in a )$r2 si'%1$ and $&ono'i&a1 ashion "2 &r$atin/ a r$1ationshi% that adds a %ar$nt I* to $)$r2 !nit.

This is a&&o'%1ish$d "2 addin/ a r$1ationshi% that 7oins th$ ta"1$ to its$1 .

This is or'a112 &a11$d a reflexive or recursive r$1ationshi%, and in or'a112 &a11$d ra$$it ears, and 1oo#s 1i#$ this:

Williams | Learn Data Modeling by Example - Part 1 /2

Th$ !nit at th$ )$r2 to% o or/aniBation has no on$ to r$%ort to, and a !nit at th$ 1o,$st 1$)$1 do$s not ha)$ an2 oth$r !nit r$%ortin/ to it.

In oth$r ,ords, this r$1ationshi% is o!tional at th$ to% and "otto' 1$)$1s. -$ sho, this "2 th$ s'a11 1$tt$r & at $a&h $nd o th$ 1in$ that 'ar#s th$ r$1ationshi%.

Williams | Learn Data Modeling by Example - Part 1 /"

%.17 Inheritance
Inh$ritan&$ is a )$r2 %o,$r !1 t$&hni(!$. It a11o,s !s to 'od$1 &o'%1$6 sit!ations in a 'ann$r and st21$ that is )$r2 si'%1$.

In this sit!ation, ,$ ar$ thin#in/ a"o!t KFood and *rin#H. KFood and *rin#H ar$ s%$&i i& $6a'%1$s o th$ 'or$ /$n$ra1 thin/ &a11$d a product. Th$2 inh$rit &o''on attri"!t$s ro' th$ %rod!&t, and a1so ha)$ so'$ o th$ir o,n. For $6a'%1$, KFoodH &an &ontain KN!tsH "!t K*rin#H 'a2 not &ontain KN!ts,H "!t "oth ha)$ a %rod!&t na'$. Th$ !n!s!a1 s2'"o1 in th$ 'idd1$ o th$ dia/ra', &o'%os$d o a &ir&1$ ,ith t,o s'a11 1in$s !nd$rn$ath it is ho, inheritance is sho,n !sin/ th$ *$Bi/n data 'od$1in/ too1. Inh$ritan&$ is a )$r2 i'%ortant to%i& ,h$n 2o! ar$ &r$atin/ a data 'od$1. In %1ain En/1ish, ,$ ,o!1d sa2 that inh$ritan&$ o&&!rs ,h$r$ a Par$nt-9hi1d r$1ationshi% $6ists "$t,$$n thin/s o int$r$st Lor $ntiti$sJ.

Williams | Learn Data Modeling by Example - Part 1 /'


:o! &an as# th$ si'%1$ 1Is-a1 (!$stion - in this &as$, i ,$ as# <Is a '! in a %rod!&t< th$n &1$ar12 th$ ans,$r is <2$s< so ,$ ha)$ $sta"1ish$d that th$r$ is an inh$ritan&$ r$1ationshi% "$t,$$n th$'. In th$ $6a'%1$ o inh$ritan&$ sho,n in this dia/ra', ,$ &an s$$ that a11 %rod!&ts ha)$ na'$s and d$s&ri%tions. Th$r$ or$, KFood and *rin#H ,i11 inh$rit th$s$ &hara&t$risti&s ro' th$ %ar$nt %rod!&t. -$ &a11 th$ %rod!&t th$ )u!er-T !e and KFood and *rin#H ar$ )ub-T !es. =o,$)$r, $a&h s!"-t2%$ o %rod!&t ,i11 ha)$ s%$&i i& &hara&t$risti&s that it do$s not shar$ ,ith oth$r s!"-t2%$s. For $6a'%1$, a K*rin#H has a 1a)or "!t KFoodH do$s not. ;n$ o th$ i'%ortant thin/s in 2o!r data 'od$1 is to "$ s!r$ 2o! ha)$ id$nti i$d a11 th$ inh$ritan&$ r$1ationshi%s. =o,$)$r, an inh$ritan&$ r$1ationshi% is o t$n "1!rr$d in a r$a1 %h2si&a1 data"as$ "$&a!s$ it &an "$ &1!'s2 to i'%1$'$nt and has to "$ r$so1)$d ,ith th$ addition o a ta"1$ that is o t$n &a11$d an asso&iati)$ ta"1$. This asso&iati)$ ta"1$ has a on$to-'an2 r$1ationshi% ,ith $a&h o th$ ori/ina1 ta"1$s that ,$r$ in th$ 'an2-to-'an2. Th$r$ ar$ "road12 t,o t2%$s o data 'od$1: 9on&$%t!a1 or Lo/i&a1

This o&!s$s on a "!sin$ss-ori$nt$d s%$&i i& o a sit!ation that id$nti i$s th$ Kthin/s o int$r$stH and ho, th$2 ar$ r$1at$d.

Ph2si&a1

This introd!&$s as%$&ts that r$1at$ to i'%1$'$ntation in a s%$&i i& data"as$

Inh$ritan&$ &an a%%$ar in a 1o/i&a1 data 'od$1 "!t it disa%%$ars in th$ %h2si&a1 data"as$, ,hi&h is ,hat !1ti'at$12 "$&o'$s th$ data"as$.

?$1ationa1 data"as$s do not s!%%ort inh$ritan&$. Th$r$ or$ o!r thin#in/ '!st in&1!d$ th$ (!$stion o ,h$n ,$ sto% sho,in/ th$ inh$ritan&$ r$1ationshi% and r$%1a&$ it ,ith t,o on$to-'an2 r$1ationshi%s. B!sin$ss !s$rs t$nd to "$ &o' orta"1$ ,ith 'an2-to-'an2 "!t or data 'od$1$rs, *B+s and d$)$1o%$rs it is !s!a112 "$tt$r to r$%1a&$ th$'. Inh$ritan&$ is a )$r2 si'%1$ and )$r2 %o,$r !1 &on&$%t. -$ &an s$$ $6a'%1$s o inh$ritan&$ in %ra&ti&$ ,h$n ,$ 1oo# aro!nd !s $)$r2 da2. For $6a'%1$, ,h$n ,$ thin# a"o!t K=o!s$s,H ,$ i'%1i&it12 in&1!d$ "!n/a1o,s and s#i 1od/$s, and 'a2"$ $)$n a%art'$nts, "$a&h h!ts and ho!s$ "oats.

Williams | Learn Data Modeling by Example - Part 1 /)


In a si'i1ar ,a2, ,h$n ,$ dis&!ss air&ra t ,$ 'i/ht "$ ta1#in/ a"o!t rotar2 air&ra t, i6$d ,in/ air&ra t and !n'ann$d air&ra t.

=o,$)$r, ,h$n ,$ ,ant to d$si/n or r$)i$, a data 'od$1 that in&1!d$s air&ra t, th$n ,$ n$$d to ana12B$ ho, di $r$nt #inds o air&ra t ar$ sho,n in th$ d$si/n o th$ data 'od$1.

-$ !s$ th$ &on&$%t o KInh$ritan&$H to a&hi$)$ this. Inh$ritan&$ in data 'od$1in/ is 7!st th$ sa'$ as th$ /$n$ra1 '$anin/ o th$ ,ord. It '$ans that at a hi/h 1$)$1, ,$ id$nti 2 th$ /$n$ra1 na'$ o th$ KThin/ o Int$r$stH and th$ &hara&t$risti&s that a11 o th$s$ thin/s shar$. For $6a'%1$, an air&ra t ,i11 ha)$ a na'$ or th$ t2%$ o air&ra t, s!&h as Tornado and it ,i11 "$ o a &$rtain t2%$, s!&h as i6$d-,in/ or rotar2.

+t th$ 1o,$r 1$)$1 o i6$d-,in/ air&ra t, an air&ra t ,i11 ha)$ a 'ini'!' 1$n/th or th$ r!n,a2 that th$ air&ra t n$$ds in ord$r to ta#$ o .

This sit!ation is sho,n in th$ o11o,in/ dia/ra':

Williams | Learn Data Modeling by Example - Part 1 /.

%.11 .eference Data


?$ $r$n&$ data is )$r2 i'%ortant. -h$r$)$r %ossi"1$, it sho!1d &on or' to a%%ro%riat$ $6t$rna1 standards, %arti&!1ar12 nationa1 or int$rnationa1 standards. For $6a'%1$, th$ Int$rnationa1 Standards ;r/aniBation LIS;J %!"1ish$s standards or &o!ntr2 &od$, &!rr$n&2 &od$s, 1an/!a/$s &od$s and so on.

For addr$ss$s, th$ E> Post ; i&$ +ddr$ss Fi1$ LP+F i1$J, is th$ standard !s$d to )a1idat$ addr$ss$s ,ithin th$ E>.

%.11.1 &ddress T !es eBam!le +ddr$ss t2%$s ar$ anoth$r $6a'%1$ o r$ $r$n&$ data.

Williams | Learn Data Modeling by Example - Part 1 //


Th$r$ ar$ t,o d$si/n %ossi"i1iti$s. Th$ irst is /ood "$&a!s$ it sho,s &1$ar12 th$ 1o/i&a1 r$1ationshi% ,h$r$ a &!sto'$r addr$ss &an "$ id$nti i$d !ni(!$12 "2 a &o'"ination o th$ &!sto'$r I*, th$ addr$ss I* and th$ dat$ ro' ,h$n th$ addr$ss ,as )a1id or th$ &!sto'$r.

; &o!rs$, it is not a1,a2s %ossi"1$ to d$t$r'in$ th$ K*at$ Fro'H )a1!$, and it is not a1,a2s so'$thin/ that it is a%%ro%riat$ to as# $)$r2 &!sto'$r.

Th$r$ or$, a "$tt$r and 'or$ /$n$ra1 a%%roa&h is to !s$ a #$2 Lthat ,$ dis&!ss$d in S$&tion 3.3J or a r$&ord and 1$a)$ th$ K*at$ Fro'H i$1d o%tiona1.

Williams | Learn Data Modeling by Example - Part 1 /*

%.11.2 Customer &ddresses This is a /$n$ra1 and 1$6i"1$ a%%roa&h to hand1in/ addr$ss$s in o!r data 'od$1. -$ ha)$ a s$%arat$ +ddr$ss Ta"1$, ,hi&h a11o,s !s to ha)$ 'or$ than on$ addr$ss or an2 &!sto'$r )$r2 $asi12. This d$si/n a1so has oth$r "$n$ its:

-$ &an a&&o''odat$ 'or$ than on$ %$rson at th$ sa'$ addr$ss. -$ n$$d to do this "$&a!s$ di $r$nt '$'"$rs o a a'i12 'a2 si/n !% s$%arat$12 ,ith +'aBon. -ith a s$%arat$ ta"1$ o addr$ss$s, ,$ &an $asi12 !s$ &o''$r&ia1 so t,ar$ to )a1idat$ o!r addr$ss$s. To ind this #ind o so t,ar$, si'%12 Poo/1$ H+ddr$ss Ma1idation So t,ar$H. -$ ha)$ !s$d D+S ,ith /r$at s!&&$ss in th$ %ast. -ith this a%%roa&h, ,$ &an a1,a2s "$ s!r$ that ,$ ha)$ 100T /ood addr$ss data in o!r data"as$.

%.11." .eference Data ?$ $r$n&$ data has th$ o11o,in/ &hara&t$risti&s:

It do$s not &han/$ )$r2 '!&h. It has a r$1ati)$12 s'a11 n!'"$r o )a1!$s, !s!a112 1$ss than a $, doB$n and n$)$r 'or$ than a $, h!ndr$d. Th$r$ or$ ,$ &an sho, it ,ith a &od$ as a %ri'ar2 #$2. *ata in ?$ $r$n&$ *ata Ta"1$s &an "$ !s$d to %o%!1at$ dro%-do,n 1ists or !s$rs. In this ,a2, it is !s$d to $ns!r$ that a11 n$, data is )a1id.

Williams | Learn Data Modeling by Example - Part 1 /$


%.11.% )tandards In th$ +ddr$ss Ta"1$, 2o! ,i11 s$$ a i$1d &a11$d <IS;59o!ntr259od$s<. IS; stands or th$ <Int$rnationa1 Standards ;r/aniBation<. It is a1,a2s /ood to !s$ nationa1 or int$rnationa1 standards.

Williams | Learn Data Modeling by Example - Part 1 *&

%.11.( &ircraft eBam!le This dia/ra' sho,s t,o "asi& $6a'%1$s o ?$ $r$n&$ data that 'i/ht a%%12 to o!r si'%1$ air&ra t data 'od$1.

%.12 What ha'e ;e learned?


In this &ha%t$r, ,$ ha)$ &o)$r$d th$ "asi& &on&$%ts in data 'od$1in/, in&1!din/: Pri'ar2 and For$i/n >$2s ;n$-to-0an2 and 0an2-to-0an2 ?$1ationshi%s ?a""it Ears or ?$ 1$6i)$ ?$1ationshi%s Inh$ritan&$

Williams | Learn Data Modeling by Example - Part 1 *1


?$ $r$n&$ *ata

That ,i11 /i)$ !s th$ "asi&s o th$ 1an/!a/$ in ,hi&h ,$ &an ta1# a"o!t and d$s&ri"$ data 'od$1s.

Williams | Learn Data Modeling by Example - Part 1 *2

(. & Database for a 8ideo >ame


(.1 &!!roach
Th$ irst st$% is to d$&id$ on th$ th$'$ o th$ Pa'$. For this T!toria1, ,$ ha)$ &hos$n a KShoot K$' E%H ,hi&h is "as$d on a )$r2 %o%!1ar Pa'$ or th$ 0i&roso t U"o6 &a11$d P$ars o -ar. =$r$ is th$ %a/$ on th$ *ata"as$ +ns,$rs -$" Sit$ that sho,s th$ *ata 0od$1 :-

htt%:44,,,.data"as$ans,$rs.or/4data5'od$1s4/a'in/5/$ars5o 5,ar4ind$6.ht' $at!r$s :-

This >i&#-Start *ata 0od$1

th$ Pood P!2s, ,ho ar$ So1di$rs th$ -$a%ons th$ Bad P!2s, ,ho ar$ Lo&!sts th$ ?!1$s o En/a/$'$nt "$t,$$n th$ Pood P!2s and th$ Bad P!2s

(.2 The >ood >u s


Th$r$ ar$ s$)$n So1di$rs in th$ Pa'$, ,ith di $r$nt ?an#s and di $r$nt "a&#/ro!nds (.2.1 Colonel 8ictor 6offman

Williams | Learn Data Modeling by Example - Part 1 *"

=is Pro i1$ r$ads :+ 'i1itar2 'an to th$ &or$, 9o1on$1 Mi&tor =o 'an d$'ands dis&i%1in$ and sa&ri i&$ ro' thos$ !nd$r his &o''and.

(.2.2 )ergeant Marcus /eniB

Williams | Learn Data Modeling by Example - Part 1 *'

=is Pro i1$ r$ads :F$, ha)$ /i)$n 'or$ and 1ost as '!&h as 0ar&!s F$ni6.

+ %ro'isin/ so1di$r d!rin/ th$ P$nd!1!' -ars, 0ar&!s sa, $)$r2thin/ &han/$ on E'$r/$n&$ *a2.

0ar&!s "ra)$12 o!/ht th$ Lo&!st or t$n 2$ars, th$n, d!rin/ an int$ns$ "att1$, h$ a"andon$d his %ost to r$s&!$ his ath$r, Pro $ssor +da' F$ni6.

B!t h$ arri)$d too 1at$.

0ar&!s ,as tri$d or d$r$1i&tion o d!t2 and s$nt$n&$d to 40 2$ars in Va&into 0a6i'!' S$&!rit2 Prison. In&ar&$rat$d or o!r 2$ars "$ or$ "$in/ r$1$as$d to i/ht Lo&!st a/ain, 0ar&!s ,as 1at$r %ro'ot$d to s$r/$ant.

Williams | Learn Data Modeling by Example - Part 1 *)

(.2." Pri'ate Damian :aird

=is Pro i1$ r$ads :Pri)at$ *a'on Baird is a d$di&at$d t$&h-h$ad and %ro $ssiona1 s#$%ti&. In Baird<s ,or1d, i so'$thin/ &an /o ,ron/, it %ro"a"12 a1r$ad2 has. =is sar&as' &an #$$% %$o%1$ at a distan&$, ,hi&h is ,h2 Baird %r$ $rs th$ &o'%an2 o 'a&hin$s. =$ "$1i$)$s in th$ 9oa1ition<s &a!s$, "!t h$<s o t$n r!strat$d ,ith &o''and d$&isions, and too# o $ns$ ,h$n =o 'an %ro'ot$d 0ar&!s F$ni6 to 1$ad *$1ta S(!ad inst$ad o hi'.

Williams | Learn Data Modeling by Example - Part 1 *.

(.2.% Pri'ate &nthon

Carmine

=is Pro i1$ r$ads :+s th$ 2o!n/$st '$'"$r o *$1ta S(!ad d!rin/ th$ Li/ht'ass ; $nsi)$, ,hat Pri)at$ +nthon2 9ar'in$ 1a&#$d in &o'"at $6%$ri$n&$, h$ 'ad$ !% or in !n"rid1$d $nth!sias'.

Williams | Learn Data Modeling by Example - Part 1 */

(.2.( Pri'ate Dominic )antiago

=is Pro i1$ r$ads :+ s$ason$d i/ht$r ,hoHs %ositi)$ $)$n in th$ dar#$st o ho!rs, *o'ini& Santia/o r$$d his "$st ri$nd 0ar&!s F$ni6 ro' Va&into 0a6i'!' S$&!rit2 Prison and r$&r!it$d hi' into *$1ta S(!ad.

=is "att1$ i$1d int$nsit2 is ri)a11$d on12 "2 his 1o2a1t2 to 0ar&!s--and his ,i $, 0aria.

*o'ini&<s r$1$nt1$ss s$ar&h or his ,i $ ina112 $nd$d d!rin/ ;%$ration: =o11o, Stor', ,h$n h$ and 0ar&!s o!nd h$r in a Lo&!st %ro&$ssin/ a&i1it2, "ar$12 a1i)$ and irr$)o&a"12 t,ist$d.

0ar&!s 1$ t his sid$ to a11o, *o' a ina1 'o'$nt ,ith his "$1o)$d 0aria "$ or$ $ndin/ h$r s! $rin/.

Williams | Learn Data Modeling by Example - Part 1 **

(.2.* #ieutenant &n a )troud

=$r Pro i1$ r$ads :+s *$1taHs 9ontro1 &onta&t, +n2a Stro!d /!id$d *$1ta S(!ad on th$ir 'ission to d$stro2 th$ Lo&!st, %ro)idin/ )ita1 int$1 and strat$/i& ad)i&$ to th$ s(!ad in th$ i$1d.

Williams | Learn Data Modeling by Example - Part 1 *$

(.2.- )amantha @)am$ : rne

=$r Pro i1$ r$ads :Sa'antha NSa'N B2rn$<s ath$r, S/t. Sa'!$1 B2rn$, $11 in "att1$ at th$ si$/$ o +n)i1 Pat$ in +n)$/ad, >ash#!r "$ or$ th$ "irth o his da!/ht$r.

(.2.2 )ummar +t this %oint, ,$ &an s$$ that a11 So1di$rs ha)$ P$nd$r, Na'$s, ?an#s and a 'i1itar2 "a&#/ro!nd. Th$r$ or$, o!r So1di$rs Ta"1$ 1oo#s 1i#$ this :-

Williams | Learn Data Modeling by Example - Part 1 $&

(." Choosing the Wea!ons


No, ,$ &an &hoos$ th$ -$a%ons to 'at&h th$ So1di$rHs !ni(!$ (!a1iti$s. Th$s$ ar$ o!r o%tions that ar$ d$s&ri"$d h$r$. (.".1 :oomshot >renade #ocust

Descri!tion of the :oomshot >renade #ocust is 9-

Williams | Learn Data Modeling by Example - Part 1 $1


+ Boo'shot Pr$nad$ Lo&!st is a short- to 'id-ran/$ /r$nad$ 1a!n&h$r that &an $asi12 ta#$ do,n a tar/$t in a sin/1$ shot

Williams | Learn Data Modeling by Example - Part 1 $2

(.".2 6ammer of Da;n

Descri!tion of the 6ammer of Da;n is 9Th$ =a''$r o *a,n is +n I'!1sion-%o,$r$d sat$11it$ that rains do,n a d$)astatin/ %arti&1$ $n$r/2 str$a'. It &an ,i%$ o!t an2thin/ ro' s'a11 Lo&!st s(!ads to $ntir$ &it2 "1o&#s.

Williams | Learn Data Modeling by Example - Part 1 $"

(."." #ong )hot )ni!er .ifle

Descri!tion of the #ongshot is 9Th$ Lon/shot Sni%$r ?i 1$ is a hi/h-%o,$r$d, "o1t-a&tion sni%$r ri 1$ ,ith a %o,$r !1 Boo' si/ht.

Williams | Learn Data Modeling by Example - Part 1 $'

(.".% =ne )hot

Descri!tion of the =ne)hot is 9Th$ ;n$Shot is an inti'idatin/ and o"s&$n$12 %o,$r !1 1on/-ran/$ sni%$r ri 1$ &a%a"1$ o d$stro2in/ 'ost o$s in a sin/1$ shot

Williams | Learn Data Modeling by Example - Part 1 $)

(.".( )corcher /lamethro;er

Descri!tion of the /lamethro;er is 9Th$ S&or&h$r F1a'$thro,$r is a short- to 'id-ran/$ ,$a%on that $'its a &on&$ntrat$d str$a' o ir$ that &hars 2o!r $n$'i$s.

Williams | Learn Data Modeling by Example - Part 1 $.

(.".* Troi0a

Descri!tion of the Turret is 9Th$ Troi#a T!rr$t is a hi/h-%o,$r$d, t!rr$t-'o!nt$d Lo&!st 'a&hin$ /!n that ir$s &ontin!o!s ro!nds a&ross th$ "att1$ i$1d.

Williams | Learn Data Modeling by Example - Part 1 $/

(.".- )ummar Th$ d$s&ri%tions o a11 th$ -$a%ons 1oo#s 1i#$ this :-

1J + Boo'shot Pr$nad$ Lo&!st is a short- to 'id-ran/$ grenade launcher that &an


$asi12 ta#$ do,n a tar/$t in a sin/1$ shot.

2J Th$ =a''$r o *a,n is +n I'!1sion-%o,$r$d satellite that rains do,n a


d$)astatin/ %arti&1$ $n$r/2 str$a'. It &an ,i%$ o!t an2thin/ ro' s'a11 Lo&!st s(!ads to $ntir$ &it2 "1o&#s.

3J Th$ Lon/shot Sni%$r ?i 1$ is a hi/h-%o,$r$d, "o1t-a&tion sni%$r rifle ,ith a %o,$r !1


Boo' si/ht.

4J Th$ ;n$Shot is an inti'idatin/ and o"s&$n$12 %o,$r !1 1on/-ran/$ sni%$r rifle


&a%a"1$ o d$stro2in/ 'ost o$s in a sin/1$ shot

3J Th$ S&or&h$r /lamethro;er is a short- to 'id-ran/$ ,$a%on that $'its a


&on&$ntrat$d str$a' o ir$ that &hars 2o!r $n$'i$s.

6J Th$ Troi#a T!rr$t is a hi/h-%o,$r$d, t!rr$t-'o!nt$d Lo&!st machine gun that ir$s
&ontin!o!s ro!nds a&ross th$ "att1$ i$1d. +n ana12sis o th$s$ ,$a%on id$nti i$s that ,$ ha)$ on$ F1a'$thro,$r, thr$$ P!ns and a Sat$11it$.

Williams | Learn Data Modeling by Example - Part 1 $*


Th$r$ or$, th$ ra/'$nt o o!r *ata 0od$1 or -$a%ons 1oo#s 1i#$ this :-

Williams | Learn Data Modeling by Example - Part 1 $$

(.% The :ad >u s


In this /a'$, th$ Bad P!2s ar$ a11 Lo&!sts. =o,$)$r, th$2 &o'$ in di $r$nt sha%$s and siB$s, and o $r di $r$nt thr$ats. (.(.1 :erser0ers

The :erser0ers Profile reads 9B$rs$r#$rs ar$ $'a1$ Lo&!sts. Th$2 !s$ th$ir #$$n h$arin/ and s$ns$ o s'$11 to s$$# o!t th$ir %r$2 and "1!d/$on it to d$ath ,ith th$ir ha''$r-1i#$ ists.

Williams | Learn Data Modeling by Example - Part 1 1&&

(.(.2 :ruma0s

The :ruma0s Profile reads 9To stand in th$ Br!'a#Hs shado, is to star$ d$ath in th$ a&$. Th$s$ h!1#in/ ,ar 'a&hin$s %oss$ss a d$ad12 assort'$nt o ,$a%ons, ro' ,rist-'o!nt$d 'a&hin$ /!ns to o)$r-th$-sho!1d$r ro&#$t 1a!n&h$rs. For an2 &han&$ o s!r)i)a1 a/ainst a Br!'a#, "1ast a,a2 "its o its ar'or to r$)$a1 th$ so t, ,$a# s%ots !nd$rn$ath.

Williams | Learn Data Modeling by Example - Part 1 1&1

(.(." >renadier

The >renadiers Profile reads 9Lo&!st Pr$nadi$rs ar$ n$)$r a raid to /$t !% &1os$ and %$rsona1. Th$2 ha)$ a hard-&har/in/ #a'i#aB$ atta&# and r!sh th$ir $n$'2 ,ith 1itt1$ &on&$rn or th$ir o,n ,$1 ar$.

Th$2 s%$&ia1iB$ in "oth /r$nad$s and th$ Pnash$r Shot/!n, dra,in/ th$ir tar/$ts o!t o &o)$r ,ith on$ "$ or$ "1astin/ th$' to %i$&$s ,ith th$ oth$r.

Williams | Learn Data Modeling by Example - Part 1 1&2

(.(.% .&&M

The .&&M Profile reads 9+n i'%osin/ i/!r$, ?++0 to,$rs o)$r a11 h!'ans, his si1$nt d$'$anor &on&$a1in/ a )io1$nt and '$r&i1$ss nat!r$. In "att1$, ?++0 is a or'ida"1$ o%%on$nt ,ho ,i$1ds a Troi#a 0a&hin$ P!n ,hi1$ &ontro11in/ th$ >r211 that h$ so'$ti'$s $'%1o2s as a shi$1d. ?++0 '$t his d$'is$ at th$ hands o 0ar&!s F$ni6 a"oard th$ T2ro Pi11ar, ,h$r$ his r$i/n o t$rror &a'$ to an a"r!%t and ,$1&o'$ $nd.

Williams | Learn Data Modeling by Example - Part 1 1&"

(.(.( )ummar ;n$ o th$ Lo&!sts is id$nti i$d as "$in/ $'a1$. Th$r$ or$, ,$ ha)$ to ass!'$ that a11 Lo&!sts ha)$ a /$nd$r, ,hi&h ,i11 "$ 0a1$, F$'a1$ or En#no,n. Lo&!sts ha)$ a d$s&ri%tion o th$ir str$n/ths and ,$a#n$ss$s. Th$ %hotos o th$ Lo&!sts sho, th$' ha)in/ ar's and 1$/s. Th$r$ or$ ,$ in&1!d$ an +r' 9o!nt and L$/ 9o!nt i$1ds, ,hi&h ,$ d$ a!1t to t,o o $a&h. P$nd$r is a &od$ that has on12 thr$$ )a1!$s O 0a1$, F$'a1$ and E or En#no,n. So ,$ &an in&1!d$ th$' in a i$1d &a11$d KP$nd$r50FEH. Th$r$ or$, o!r Lo&!sts Ta"1$ 1oo#s 1i#$ this :-

Williams | Learn Data Modeling by Example - Part 1 1&'

(.( Thin0ing in >eneral Terms


(.(.1 )oldiers5 #ocusts and Inheritance In !nd$rstandin/ th$ Pa'$, ,$ n$$d to &onsid$r ho, to si'%1i 2 th$ ,a2 ,$ d$ in$ So1di$rs and Lo&!sts. This ,i11 h$1% !s to d$ in$ th$ Pa'$ at a hi/h$r 1$)$1 and thin# a"o!t it in a 'or$ /$n$ra1 ,a2. ;!r irst st$% is to &onsid$r So1di$rs and Lo&!sts as Parti&i%ants in th$ Pa'$. -$ &o!1d &a11 th$' B$in/s or +&tors or ?o1$s "!t or si'%1i&it2 at this "asi& 1$)$1 ,$ &a11 th$' si'%12 KParti&i%antsH. Th$2 "oth ha)$ Na'$s, and a P$nd$r. Th$r$ or$, ,$ 'o)$ th$ P$nd$r50FE to th$ Parti&i%ants $ntit2. So1di$rs ha)$ a 0i1itar2 Ba&#/ro!nd and Lo&!sts ha)$ a Str$nths5and5-$a#n$ss$s i$1d. -$ &an r$%1a&$ th$s$ t,o "2 on$ i$1d in th$ hi/h$r KParti&i%antsH Ta"1$. -$ ,i11 &a11 this i$1d KPro i1$H. Th$r$ or$, ,$ sho, o!r n$, KParti&i%antsH ta"1$ as th$ Par$nt or KS!%$r-T2%$. -ith So1di$rs and Lo&!sts as 9hi1dr$n or S!"-T2%$s.

Williams | Learn Data Modeling by Example - Part 1 1&)


Th$ *ata 0od$1 ra/'$nt ,i11 1oo# 1i#$ this :-

Williams | Learn Data Modeling by Example - Part 1 1&.

(.(.2 /a'ourite Wea!ons and Man -to-Man .elationshi!s It t!rns o!t that "oth So1di$rs and Lo&!sts ha)$ a)o!rit$ -$a%ons and no, that ,$ ha)$ $sta"1ish$d a Parti&i%ants $ntit2, ,$ &an a)o!rit$ -$a%ons as an attri"!t$ o th$ Parti&i%ants $ntit2. Ea&h Parti&i%ant &an ha)$ 'an2 a)o!rit$ ,$a%ons, and $a&h %arti&!1ar t2%$ o -$a%on &an "$ th$ a)o!rit$ o 'an2 Parti&i%ant. In *ata 0od$11in/ t$r's, ,$ &a11 this as a K0an2-to-0an2 ?$1ationshi%H "$t,$$n Parti&i%ants and -$a%ons. -$ ha)$ 'o)$d th$ Fa)o!rit$5-$a%ons attri"!t$ ro' th$ Lo&!st $ntit2 to th$ n$, Fa)o!rit$5-$a%ons $ntit2. Th$r$ or$, th$ *ata 0od$1 ra/'$nt So1di$rs and Lo&!sts 1oo# 1i#$ this, ,h$r$ th$ KFa)o!rit$5-$a%onsH $ntit2 sho,s that $a&h Parti&i%ant &an ha)$ 'an2 a)o!rit$ -$a%ons and )i&$ )$rsa. :-

Williams | Learn Data Modeling by Example - Part 1 1&/

(.* .ules of Engagement


In /$n$ra1 t$r's , th$ So1di$rs ,i11 ha)$ a n!'"$r o ;"7$&ti)$s and ,i11 ha)$ to $n/a/$ ,ith th$ Lo&!sts to a&hi$)$ th$s$ ;"7$&ti)$s. -$ ,i11 &onsid$r th$s$ $n/a/$'$nt as a s$ri$s o E)$nts in)o1)in/ a11 Parti&i%ants L"it not $)$r2 ti'$J. Ea&h E)$nt ,i11 ha)$ an o!t&o'$ L1i#$ Mi&tor2 or *$ $atJ and !s$ ?$so!r&$s, s!&h as B!11$ts, that 'i/ht "$ in 1i'it$d s!%%12.

Williams | Learn Data Modeling by Example - Part 1 1&*

(.- Design Patterns


(.2.1 Introduction *$si/n Patt$rns ar$ )$r2 %o,$r !1 "$&a!s$ th$2 h$1% !s to r$&o/nis$ si'i1ar sit!ations that o&&!r )$r2 r$(!$nt12 in r$a1 1i $. Th$n ,$ start thin#in/ 1i#$ a *ata"as$ *$si/n$r or *ata 0od$11$r and s!dd$n12, it "$&o'$s a 1ot $asi$r. T0e ob1io%s !andidate for a Design Patter in o%r simplified ,ideo -ame is E1ents (.2.2 Com!lete Design Pattern

T0is Model s0o2s all t0e !omponents in t0e Complete Design Pattern 3-

T0e logi! be0ind different 1ariations says t0at 3 T0ere 2ill al2ays be an E1ent T0ere 2ill al2ays be at least one Parti!ipant Weapons 2ill be in1ol1ed for an E1ent t0at is a fig0t bet2een (oldiers and Lo!%sts

Williams | Learn Data Modeling by Example - Part 1 1&$

(.2." Partici!ants and E'ents T0is is t0e smallest 1ersion of t0e Pattern4 be!a%se an E1ent 2ill al2ays be in1ol1ed and Parti!ipants 2ill al2ays be in1ol1ed 5f 2e t0in# abo%t an E1ent t0at does not %se Weapons4 for example4 retreating or ad1an!ing 2it0o%t engaging 2it0 t0e Lo!%sts4 t0en 2e 0a1e a simpler Data Model t0at does not in1ol1e Weapons and loo#s li#e t0is 3-

(.2.% With Wea!ons 5f t0e (oldiers meet Lo!%sts 20ile t0ey are on t0e mo1e4 t0en 2e add Weapons and t0e Data Model t0at loo#s li#e t0is 3-

Williams | Learn Data Modeling by Example - Part 1 11&

(.2.( With Wea!ons and .esources 5f t0e (oldiers meet Lo!%sts 20ile t0ey are on t0e mo1e4 t0en 2e add Weapons and t0e Data Model t0at loo#s li#e t0is4 20i!0 is t0e f%ll Design Pattern t0at 2e started 2it0 3-

Williams | Learn Data Modeling by Example - Part 1 111

Williams | Learn Data Modeling by Example - Part 1 112

(.2 The Com!lete Data Model


-h$n ,$ &o'"in$ th$ So1di$rs, Lo&!sts and -$a%ons, this is ,hat o!r 9o'%1$t$ *ata 0od$1 1oo#s 1i#$. -$ ha)$ 1$ t o!t th$ ?$ $r$n&$ *ata ta"1$s to #$$% th$ 0od$1 si'%1$ and $asi$r to r$ad. For th$ sa'$ r$ason, ,$ ha)$ in&1!d$d on12 th$ Pri'ar2 and For$i/n >$2s and a1so o'itt$d th$ +ttri"!t$s.

You might also like