Professional Documents
Culture Documents
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Data Modeling
Page:#
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
$a%le of &ontents
INTRODUCTION....................................................................................................................................3 MODELIN ! FROM CONCE"T TO STRUCTURE.........................................................................3 'EVE'S () A*S$+A&$,(- ,- DA$A M(DE',-. ................................................................................................/ 1.Conceptual Model..........................................................................................................................5 2.Lo ical Model................................................................................................................................! ".#$ysical Model..............................................................................................................................% 0(+1,-. 0,$2 DD' S&+,P$S....................................................................................................................3 A4$(MA$,-. '(.,&A' $( P25S,&A' 6M(DE' $+A-S)(+MA$,(-S7................................................................#" +E'A$,-. DA$A*ASE S&2EMAS $( $2E M(DE'...........................................................................................## RE#ERSE EN INEERIN ! $E#OL#IN % & STRUCTURE........................................................'3 &elatin to &e'erse()n ineered Code............................................................................................1" A*stractin to Lo ical Le'el...........................................................................................................1" Comparin +e, and -ld Structures...............................................................................................1. CONCLUSION.......................................................................................................................................'( D*MS DA$A $5PES:...............................................................................................................................#8 D,A.+AM +EP+ESE-$A$,(-S.....................................................................................................................#8 DA$A D,&$,(-A+5..................................................................................................................................#9 LOSS&R)............................................................................................................................................'*
Page:!
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Introduction
Enterprise Architect supports comprehensi:e functionality for modeling data%ase structures. $his paper co:ers the core features for data modeling o:er the full lifecycle of an application. ,nitially; we discuss the %asic modeling process < that is outlining a conceptual model and then wor=ing through the steps to form a concrete data%ase schema. 0e will then loo= at re> engineering or ?e:ol:ing@ an existing data%ase schema for software :ersion updates or porting to a new D*MS. Data%ase modeling can %e performed using different notations. $he notations Enterprise Architect supports includeA a 4M' Profile for DD'; Entity +elationship Diagrams 6E+D7; ,DE)#B and C,nformation EngineeringD. )or the purpose of this document we will focus on the 4M' profile for DD'; %ut include examples using the E+D notation. -ote: )or a clearer o:er:iew on how to use the 4M' Profile for DD' modeling in Enterprise Architect; see the Data%ase Modeling in 4M' paper.
Page:/
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Conceptual
Version 1
Version 2
Logical
DBMS
DBMS 1
DBMS 2
-ote: 0hen wor=ing with a 4M' modeling tool there are strong parallels to defining the &lass structure and the Data model. $he 4M' concept of &lasses with Attri%utes relates directly to Entities and their Attri%utes at the &onceptual le:el; and to $a%les containing )ields on the Physical le:el.
Page:G
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
*elow is a summary of the data modeling aspects addressed at the &onceptual; 'ogical and Physical le:els. $he ta%le also indicates which parts of the model can %e deri:ed %y an MDA $ransformation from the 'ogical model to Physical model. Conceptual Entities Entity +elations Attri%utes &lass -ames &lass Attri%utes &lass &onnectors $a%le -ames &olumn -ames &olumn $ypes Primary 1eys )oreign 1eys Stored Procedures Views $riggers H &onstraints
4n>typed
Logical
",3.ical
MDA $ransform
4M' $yped
D*MS $yped
#. &onceptual Model
$he purpose of a &onceptual model is to simply esta%lish the Entities; their Attri%utes and their ?high>le:el@ relationships. 0hen modeling using 4M'; the Domain Model is used to define the initial structural layout 6later to %e used for &lasses7. 0here the &lass design is parallel to the data structure design; it is sensi%le to use the Domain model as a seed for the &onceptual model. At the conceptual le:el there is little detail. $he diagrams consist %asically of Entities and their simple relationships. ,f there are Attri%utes defined; these are loosely typed 6for example > no length settings7; and connectors %etween Entities do not define relationships to specific Attri%utes. )igure / %elow is an example of a simple &onceptual diagram for an (nline *oo=store.
e nti ty Transaction ! ""# 1 e nti ty Account en ti ty Order 1
1 ""# !""#
1""#
Figure 3! Conceptual Model Diagram. u.ing UML to model t,e Online Boo4.tore
Page:8
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Enterprise Architect supports two different approaches for data models: 4M' &lass diagram 6DD'7 Entity +elationship Diagram 6E+D7 4sing 4M' &lass modeling; the &onceptual model consists of defining the data entities as an Element of type C&lassD. $hese &lasses can later include internal Attri%utes; whereas with E+D %ased modeling Attri%utes are defined as related Elements 6the Attri%utes are external to the Entities7. )igure G shows the (nline *oo=store &onceptual model in E+D notation.
T ran sactio n
! ""#
% r&e r
S toc'$te m
!""#
! ""#
1 ""#
! ""#
A cco un t
! ""#
S ho pp in gB as'et
1 ""#
L in e$tem
!. 'ogical Model
$he 'ogical model includes more detail; specifically Attri%utes; %ut the modeling is still generic as it is not %ound to a specific D*MS. $he process of creating a 'ogical model %ased on a &onceptual model in:ol:es: > Setting t,e &ttri0ute. At the 'ogical le:el; the attri%utes 6which later %ecome $a%le &olumns7; are modeled independently of any D*MS product. $hey are typed using primiti:e 4M' data types; such as integer; %oolean and string.I7. Setting t,e Relation.,ip. At the 'ogical le:el we do not yet set the Primary 1eys H )oreign 1eys etc. At this le:el it is %est to :erify and adJust the &onnector ?multiplicity@ 6also =nown as ?cardinality@ in data%ase terminology7 details that were set earlier for relationships in the &onceptual model.
>
)igure 8 is a diagram of the 'ogical model deri:ed from the &onceptual model in )igure /.
Page:9
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Transaction ( ( &ate )&ate am o untPai & )integer (history ! ""# 1 !""# (account 1 (a ccount !""# ( ( ( ( Order &a te )&ate &e li*ery$n structio ns )string or&er+um ,er )in tege r status )inte ger ( ( ( ( (
StockItem author )string catal og+um ,e r )char costPrice )n um ,e r l istPrice )num ,er title )string 1 !""1 1 1""# ( LineItem -uantity )integer 1 ""# (,as'et !""# ShoppingBasket ( shoppingB as'et+um ,e r )string 1
Account ( ( ( ( ,i ll in gA&&re ss )stri ng &el i*eryA&&ress )stri ng em ailA&&ress )strin g nam e )string 1
)igure 9 shows an eEui:alent model of the Account and $ransaction elements using an Entity +elationship Diagrams 6E+D7. $he Entities do not contain attri%utes; rather the ?ta%le> columns@ are represented as ellipses connected to the Entity. $he Entity relationships are represented as diamond>shape connectors.
nam e
, il li ng A & & re ss
T ra n sa ctio n
cl o se &
/. Physical Model
Modeling on the Physical le:el in:ol:es adding Cplatform specificD detail to the model. $hat is; detail specific to the D*MS where the data%ase is to %e deployed. )or more detail on manually setting the definition of the Physical data%ase model using DD' diagramming see the paper on Data%ase Modeling in 4M'. Sparx Systems !"## Page:K
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
$o set up the Physical model you can create a copy of the 'ogical Model and start the process of adding the Physical definitions to this model. $he =ey aspects of this are: . )or each ?&lass@: o $he Stereotype must %e set to ?$a%le@. o $he Data%ase setting must %e set to a specific D*MS. )or more information see: 0or=ing with $a%les. o 4pdate the Attri%utes to reflect &olumns ?$yped@ to the specific D*MS )ield types. )or more information see: &reate &olumns. . Add more detail to the &onnectors 6relationships7; to define the Primary 1ey 6H )oreign 1ey7 lin=ing. )or more information see: Data%ase 1ey. -ote: All of the a%o:e Physical le:el additions and alterations can %e automated using an MDA transformation from a 'ogical model. See ?Automating 'ogical to Physical 6MDA transforms7@ %elow.
)igure K shows the Physical model deri:ed from the a%o:e 'ogical model for a specific D*MS. ,t uses the 4M' Profile for DD' modeling to represent MySL' specific details:
Transaction col u m n & a te )DAT 5 a m o un tPa i& )$+T 56 5 / #P4 tra n sa ctio n$D )$+T 5 6 5/ 84 a cco u n t )$+T 5 65/ P4 ( P4 7T ra n sa ctio n1$+T 565 /3 84 ( 84 7a ccou nt1$+T 5 65/3 (84 7a cco u n t ! ""# Order col u m n &a te )DAT 5 &e li*ery$n stru ctio n s )V A/C0A /12! 3 (P47 T ra nsa ctio n or& e r+u m , e r )$+T 5 6 5/ 1tran sa cti o n $D 9 tra n sa cti on $D3 sta tu s )% r& e rStatu s 84 acco u n t )$+T 5 6 5/ 84 1 ! ""# #P4 or& e r$D )$+T 5 65 / (84 7% r& er7 T ra nsa cti on 84 tra nsa ctio n$D )$+T 5 6 5/ P 4 ( P4 7% r& e r1$+T 56 5/3 84 ( 84 7 a ccou nt1$+T 5 65/3 ( 84 7 %r& er7T ra n sa cti o n 1$+T 56 5/3 (847 a cco u n t StockItem col u m n au th or )V A/C0A /12 ! 3 ca ta l og +u m ,e r )C0A /11! 3 co stPri ce )n um , er li stP rice )n u m , e r ti tl e )V A/C0A /12 ! 3 #P 4 stoc'$te m $D )$+T 56 5 / P4 ( P47 Sto c'$te m 1$+T 56 5/3 (P 47S to c'$te m 1
! ""#
(P47 % r&e r
Account co l u m n , il l in gA && re ss )VA/C0A /12! 3 & e l i*e ryA& & re ss )VA /C0A/12 ! 3 e m ai l A&& ress )VA/C0A/12 !3 n a m e )VA /C0A/12 !3 #P4 a cco un t$D )$+T 565 / P 4 ( P4 7 A ccou nt1$+T 56 5/3 1 (P47 Acco un t ShoppingBasket co lu m n sh op pi n g Ba s'e t+u m ,e r )VA/C0A /12! 3 #P 4 sh op pi n g Ba s'e t$D )$+T 5 6 5/ 84 acco un t$D )$+T 5 6 5/ P 4 ( P47 Sh op pi n gBa s'e t1$+T 56 5 /3 ! ""# 84 ( 84 7 Sh o p p i n gB as'e t7A cco u n t1$+T 56 5/3 1or& er$D 9 o r& er$D3 (P 47A ccou nt 1 1a ccou nt 9 a ccou nt$D3 84 1 ""# (84 7 L in e $te m 7 %r& e r
! ""1 LineItem co lu m n -u an tity )$+T 5 6 5/ lin e$tem $D )$+T 5 6 5/ or&e r$D )$+T 565 / sh op pi n g B as'e t$D )$+T 5 6 5/ sto c'$te m $D )$+T 565 /
84
#P 4 #84 #84 84
P 4 ( P47 L i n e $te m 1$+T 5 65 /3 84 ( 84 7 L in e$tem 7 %r& er1$+T 56 5/3 ( 84 7 L in e$tem 7 Sh o p p in gB as'e t1$+T 565 /3 ( 84 7 L in e$tem 7 Sto c'$te m 1$+T 5 6 5/3 1 ""#
)urther details can %e added to the deri:ed physical model. $hese include setting: > Stored Procedures: see Stored Procedures > Views: see > Views Sparx Systems !"## Page:M
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
>
&onstraints; $riggers: see < ,ndexes; $riggers and &hec= &onstraints. -ote: $hese three features are outside the MDA transform co:ered in the section %elow: Automating 'ogical to Physical 6Model $ransformations7.
Figure ;! Data0a.e model +it, t,e DDL .cript /or t,e ta0le .elected in t,e diagram
Page:3
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
$here is also support for a re:erse transform from DD' to E+D. )or more details on this; see %elow: Data Model to E+D $ransformation A point to note is; that where there are ?many>to>many@ relationships in the logical model; the DD' transformation generates a Join>ta%le to accommodate the relationship. +eturning to the (nline *oo=store example 6see )igure 87; we could re>model IStoc=,temI as two separate ta%les; Pu%lication and Author; related using a many>to>many 4M' Association. $his is shown as:
Figure *! $Stoc4item% rede/ined in t,e logical model a. &ut,or and "u0lication +it, a man3<to<man3 relation.,ip.
Page:#"
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Author col u m n a utho r+am e #P4 a utho r$D )$+T 56 5 / P 4 ( P 47 A u tho r1$+T 5 6 5/3 (P 47 Auth or
Publication co lu m n ti tl e )VA /C0A /12 ! 3 cata lo g+u m , e r )VA /C0A /12! 3 costPrice )$+T 5 6 5/ l i stP ri ce )$+T 56 5 / #P 4 p u , l icati o n $D )$+T 5 6 5/ P4 ( P 4 7 Pu, li ca ti on 1$+T 5 6 5/3 (P4 7 Pu , l i catio n
1p u, li ca ti on $D 9 p u, l ica ti on $D3 84
(Pu, l ica ti on co l um n 1 ""# 84 p u , li catio n $D )$+T 56 5 / 84 a u th o r$D )$+T 5 65 / 84 ( P u, l ica ti on 1$+T 56 5 /3 ( A uth or1$+T 5 65 /3
Page:##
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
!" Model##Account n am e )string , i ll i ng A&& re ss )string e m a il A& & ress )stri n g clo se& ), oo l & el i *e ryA& &re ss )strin g ( ( ( ( ( ( l oa& Acco u ntDeta i l s1stri n g3 )*oi & m ar'Acco un tCl ose& 13 )*oi& cre ate +e :Accoun t13 )*o i& su ,m it+e :A cco u ntDetai ls13 )*o i& retri e*eA cco un tDetai l s13 )*oi& *a li &a te ;ser1stri n g< stri ng 3
Ph$sical Model##Account co lum n n am e )VA/C0A/12! 3 , i ll i ng A&& ress )VA/C0A/12! 3 e m a il A&&ress )VA/C0A/12! 3 clo se& )B$T & el i *e ryA&& re ss )VA/C0A /12 !3 #P4 a cco un t$D )$+T 565/ #84 h i sto ry )$+T 565/ P 4 ( P47Accou nt1$+T 5 65/3 u n i -u e ( ;=7 Acco un t7 accou nt$D1$+T 565/3 ( ;=7 Acco un t7 cl ose &1B$T 3 84 ( 847h isto ry1$+T 565/3
p ro pe rty ( %r&er13 )%r& er ( , as'e t13 )Sh op pin gB as'e t ( n am e13 )strin g ( , i ll i ng A&& re ss13 )strin g ( e m a il A& & ress13 )stri n g ( clo se& 13 ),o ol ( & el i *e ryA& &re ss13 )stri ng
/. Some data%ase systems relate explicit Screen entry )ields direct to $a%le )ields 6.e.g. MS Access; Power*uilder etc.7. $o model these relationships a Screen Model can %e lin=ed using the &onnect to Element )eature connections as shown %elow.
StockItem
Sea rchA uthor StockItem col um n A utho r )*a rchar12!3 catalog+um ,er )*a rchar12 !3 costPrice )num ,er li stPri ce )nu m ,er ti tle )*a rcha r12 !3 #P 4 stoc'$tem $D )i nte ge r 84 li ne$te m $D )i nteg er P4 ( P 47Stoc'$tem 1intege r3 84 ( 847Stoc'$tem 7Li ne $tem 1i nte ger3 +e >t
SerachT itl e
8i n&
Auth or
T i tl e
=uantity
CostPrice
Li stPri ce
Ba c'
+e:
Sa *e
Page:#!
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Page:#/
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Conclu.ion
$his co:ers some of the =ey features of Enterprise Architect@s support for Data Modeling including modeling from the &onceptual to Physical le:els; )orward and +e:erse Engineering of Data%ase Schemas; and MDA transformation of the 'ogical model 6platform independent7 to Physical D*MS 6platform dependant schema7. 0hen modeling an application and the data%ase in the same en:ironment there is added %enefit of tracea%ility %etween the application modeling and the data modelingA synchroniOation %etween the design of the application; the design of the data model and the final implementation of these; along with; the added %enefits of model reuse when starting new designs. 0hether you need to model and manage complex designs and :isualiOe data structures; or %uild and deploy di:erse data systems; Enterprise Architect pro:ides interconnected modeling; de:elopment and deployment; for %oth the data%ase and the system code.
Page:#G
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
&ppendi>!
D#MS data types$
$here may %e cases where you want to create a physical data model for a D*MS product that is not yet supported nati:ely %y Enterprise Architect; or you may need to add datatypes for a more recent :ersion of a supported D*MS. $he Data%ase Datatypes screen allows adding a new Data%ase product; or customiOing the data>types associated with an existing one. $o do this; select from the main menu: Settings P Data%ase Datatypes. See the related help topic for more details.
Diagram "epresentations
Enterprise Architect supports a num%er of notations rele:ant to data modeling. $his document primarily uses &lass diagrams. (ther supported notations include: . . . ,DE)#B E+D ,nformation Engineering
$he following are examples of the ,DE)#B and ,nformation Engineering formats:
Transaction ( ( &a te )& a te am o untPa i & )integ er Order (histo ry (acco un t ( ( ( ( &ate )&a te &el i*ery$n stru ction s )strin g or& er+um ,e r )intege r statu s )inte g e r ( ( ( ( (
StockItem a utho r )strin g ca tal og+u m ,e r )ch a r co stPrice )n um ,e r l istPrice )n u m , er title )strin g
P LineItem
Account ( ( ( ( , ill ing A& &re ss )stri ng & el i*eryA& & re ss )strin g e m ail A&& ress )stri ng n am e )stri ng (a cco un t (
- u an tity )intege r
(,a s'e t (
Page:#8
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
Transaction ( ( &a te )& a te am o untPa i & )integ er Order (histo ry (acco un t ( ( ( ( &ate )&a te &el i*ery$n stru ction s )strin g or& er+um ,e r )intege r statu s )inte g e r ( ( ( ( (
StockItem a utho r )strin g ca tal og+u m ,e r )ch a r co stPrice )n um ,e r l istPrice )n u m , er title )strin g
Account ( ( ( ( , ill ing A& &re ss )stri ng & el i*eryA& & re ss )strin g e m ail A&& ress )stri ng n am e )stri ng (a cco un t (
(,a s'e t (
Figure '(! In/ormation Engineering repre.entation o/ t,e Online Boo4.tore data model
$o change the format of the diagram %etween 4M' Profile for DD'; ,DE)#B and ,nformation Engineering; select from the main menu: Diagram P Properties Q &onnectors; then using the dropdown: &onnector -otation < select the appropriate format.
Data Dictionary
A simple method to create a data dictionary is to use the Enterprise Architect Model Search facility to create a ?Data Dictionary@ Euery. $his returns results that can %e sorted %y many different fields 6e.g. %y $a%le name; )ield $ype; Primary 1ey; )oreign =ey etc.7. Enterprise Architect supports storing its model repositories using a num%er of different D*MS. As the search Euery format differs %etween each D*MS; only the simple default .eap SL' script is shown %elow. -ote this is simple to re>arrange to suite the SL' specific to the D*MS of your repository. $o create the Model Search Euery: 1. 4se &trlN) to open the Model Search :iew 2. $hen select: (ptions P Manage Searches 3. Select the -ew Search icon 4. (n the &reate -ew Search Luery dialog: o o $ype in a -ame 6CData Dictionary EAPD7 Select: SL' Editor
$he SL' search string to use is: Sparx Systems !"## Page:#9
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
SE'E&$ tRattri%ute.eaRguid AS &'ASS.4,D; FAttri%uteF AS &'ASS$5PE; tRo%Ject.-ame as $a%leR-ame; tRattri%ute.-ame; iif6tRattri%ute.,s(rdered; IP1I; II7 as Primary1ey; iif6tRattri%ute.,s&ollection; I)1I; II7 as )oreign1ey ; tRattri%ute.$ype; tRattri%ute.'ength; tRattri%ute.Precision; tRattri%ute.Scale; iif6tRattri%ute.,sStatic; I4niEueI; II7 as is4niEue; iif6tRattri%ute.AllowDuplicates; I-ot-ullI;II7 as -ot-ull )+(M tRattri%ute; tRo%Ject 02E+E tRattri%ute.o%JectR,d S tRo%Ject.(%JectR,D and tRo%Ject.Stereotype S I$a%leI $his will support cross>referencing to the $a%le )ields in the ProJect *rowser using the &ontext menu options in the result set generated 6see %elow7:
Page:#K
Enterprise Architect
Visual Modeling Platform
http://www.sparxsystems.com
lo..ar3
Attri%ute &onceptual 'e:el &onceptual Model Data%ase Schema D*MS DD' Entity E+D ,DE)#B ,nformation Engineering 'ogical 'e:el 'ogical Model MDA Physical 'e:el Physical Model P,M PSM 4M' A feature within an Entity that descri%es where a range of :alues can stored. $he initial design le:el used to esta%lish the Entities and simple relationships. Models defined at the &onceptual 'e:el. $he structure of a data%ase descri%ed in a formal language supported %y the data%ase management system 6D*MS7. Data%ase Management System; is a software system that manages data%ases on a ser:er. A Data Definition 'anguage is a language used for defining data structures. A uniEuely identifia%le o%Ject a%stracted from the complexities of some domain < fundamental element used in E+D. Entity>+elationship Diagrams: a classical data modeling notation; primarily used for conceptual modeling. C,ntegration Definition for ,nformation ModelingD is a data modeling language associated with the ,DE) group of modeling languages. C,nformation EngineeringD is a data%ase modeling notation for Entity> +elationship Modeling. $his le:el of a%straction is a simple description of data%ase structure; and what relationships exist among those data entities. Data Models defined at the logical 'e:el. Model Dri:en Architecture 6MDA7 is a software design approach for the de:elopment of software systems. See (M. > MDA $he le:el where the data%ase schema modeling has sufficient detail to facilitate implementation on a specific D*MS. Models defined at the Physical 'e:el. Platform ,ndependent Model < used in MDA transformations. Platform Specific Model <generated %y MDA transformations. 4nified Modeling 'anguage: an o%Ject modeling and specification language used in application design. See (M.>4M'.
Page:#M