Anda di halaman 1dari 60

Data Modeling Tutorial:

Data Modeling Tutorial section aims at educating the reader with the importance and necessities of data
modeling in today's Business Intelligence world. Included are the different types and representation of data
models, how to create data models and the tools used to create and manage data models, in easy-to-understand
manner.
Explanations and details are proided from a data modeler perspectie, li!e how a data modeler creates o"#ects,
relationships, sets standards, creates reports$DD% scripts, creates ersions and how the data model can "e
implemented in a data"ase "y using arious tools li!e erwin, toad, xcase and isio.
This data modeling tutorial section is grouped into different categories li!e oeriew, types, tools etc., to help
"enefit the "eginner or the experienced in exploring the topics they need the most. Browse through the arious
data modeling topics listed "elow to learn more.
Data Modeling Overview:
Data Modeling &eriew ' Data Modeling Deelopment (ycle ' )teps to (reate a Data Model ' Data Modeler
*ole ' Data Modeling )tandards ' Data Modeling &"#ects ' Data Model *epository ' Data Model +ersioning ' Data
Modeling *eports
Data Modeling Tools:
Data Modeling Tools ' DM Tools, -hat to %earn. ' DM Tools - Erwin ' DM Tools - /case ' +isio 0 Data
Modeling ' (reate Data Model in +isio
Data Modeling Relationships:
DM *elationships ' (reate o"#ects in Data Model ' Domains, Defaults 0 (hec! (onstraints ' (ardinality 0 1on-
Identifying ' Identifying *elationship ' )upertype 0 )u"type
Data Modeling Types:
(onceptual Data Modeling ' Enterprise Data Modeling ' %ogical Data Modeling ' 2hysical Data
Modeling ' *elational3&%T24 Data Modeling ' Dimensional Data Modeling
Comparison:
%ogical s 2hysical DM ' *elational3&%T24 s Dimensional ' (ompare Data Models
Physical Data Modeling:
DD% )cripts from Data Model ' *eerse Engineering a Data Model
Modeling DW and Data Mart:
Data -arehouse and Data Mart ' Dimensions ' )lowly (hanging Dimensions ' )tar )chema ' )nowfla!e
)chema ' 5act Ta"le
Data Modeling Interview Questions:
DM Interiew 6uestions
What is a Data Model
7 Data model is a conceptual representation of data structures3ta"les4 re8uired for a data"ase and is ery
powerful in expressing and communicating the "usiness re8uirements.
Data Modeling Overview:
7 data model isually represents the nature of data, "usiness rules goerning the data, and how it will "e
organi9ed in the data"ase. 7 data model is comprised of two parts logical design and physical design. Data
Models are created in either Top Down 7pproach or Bottom-:p 7pproach. In Top-Down 7pproach, data models
are created "y understanding and analy9ing the "usiness re8uirements. In Bottom :p 7pproach, data models are
created from existing data"ases, which has no data models. IDE5;/ is the common notation used in creating
data models since it is more descriptie. Data Models are created for &%T2 data"ases "y normali9ing the data
and for &%72 data"ases, data models are created "y de-normali9ing the data. Data Models cannot "e fro9en
since update will happen on data modeling "ased on "usiness re8uirements. Data Models loo!s li!e a "lue print
or li!e a map. Data Model is not an exact replica of the data"ase and it will not contain all the o"#ects or code
present in the data"ase since seeral o"#ects are aaila"le in data"ase and tonnes and tonnes of code would
hae "een deeloped "y deelopers. :sually Data Models contains the !ey data"ase o"#ects li!e ta"les,
columns, relationships, constraints etc.
Data model helps functional and technical team in designing the data"ase. 5unctional team normally refers to
one or more Business 7nalysts, Business Managers, )mart Management Experts, End :sers etc., and Technical
teams refers to one or more programmers, DB7s etc. Data modelers are responsi"le for designing the data
model and they communicate with functional team to get the "usiness re8uirements and technical teams to
implement the data"ase.
Data Modeling Concept:
The concept of data modeling can "e "etter understood if we compare the deelopment cycle of a data model to
the construction of a house. 5or example (ompany 7B( is planning to "uild a guest house3data"ase4 and it calls
the "uilding architect3data modeler4 and pro#ects its "uilding re8uirements 3"usiness re8uirements4. Building
architect3data modeler4 deelops the plan 3data model4 and gies it to company 7B(. 5inally company 7B( calls
ciil engineers3DB74 to construct the guest house3data"ase4.
Data Engineers, Data Modeler and Data 7rchitect are the common titles for those who are inoled in data
modeling. To "ecome an efficient data modeler, you should hae an oeriew a"out the data"ase o"#ects,
constraints, normali9ation and understanding the re8uirements correctly.
Why to !uild or create a data model
To aoid redundancy of data in a &%T2 data"ase.
In Data -arehousing, data from source systems can "e transformed as per the rules and loaded into
target ta"les.
In Data -arehousing, you can do data profiling "y cleaning the data from source systems and load that
into data warehouse columns. i.e. )ame column from different source system may hae different data
structure and column name. In data warehouse, we can create a column as per standards and load the
data.
In Data warehousing, seeral columns data help in predicting the future, which is a part of data mining.
In Data -arehousing or in Data Mart, you can drill down the data to a certain and you can get
consolidated information. for example, with location dimension, <ou can group the data on a state leel
"asis, county leel "asis, city leel "asis. -ith time dimension, you can drill down on a yearly "asis or
8uarterly "asis or on monthly "asis.
7 new application for &%T23&nline Transaction 2rocessing4, &D)3&perational Data )tore4, data
warehouse and data marts.
*ewriting data models from existing systems that may need to change reports.
Incorrect data modeling in the existing systems.
7 data "ase that has no data models.
"dvantages and Importance o# Data Model
The goal of a data model is to ma!e sure that all data o"#ects proided "y the functional team are
completely and accurately represented.
Data model is detailed enough to "e used "y the technical team for "uilding the physical data"ase.
The information contained in the data model will "e used to define the significance of "usiness,
relational ta"les, primary and foreign !eys, stored procedures, and triggers.
Data Model can "e used to communicate the "usiness within and across "usinesses.
Data Modeling Development Cycle
$% &athering 'usiness Re(uirements ) *irst Phase:
Data Modelers hae to interact with "usiness analysts to get the functional re8uirements and with end users to
find out the reporting needs.
+% Conceptual Data Modeling,CDM- ) .econd Phase:
This data model includes all ma#or entities, relationships and it will not contain much detail a"out attri"utes and is
often used in the I1ITI7% 2%711I1= 2>7)E.
/% 0ogical Data Modeling,0DM- ) Third Phase:
This is the actual implementation of a conceptual model in a logical data model. 7 logical data model is the
ersion of the model that represents all of the "usiness re8uirements of an organi9ation.
1% Physical Data Modeling,PDM- ) *ourth Phase:
This is a complete model that includes all re8uired ta"les, columns, relationship, data"ase properties for the
physical implementation of the data"ase.
2% Data!ase ) *i#th Phase:
DB7s instruct the data modeling tool to create )6% code from physical data model. Then the )6% code is
executed in serer to create data"ases.
.teps to create and maintain a new data model #rom
!usiness re(uirements:
These are the general guidelines to create a standard data model and in real time, a data model may not "e
created in the same se8uential manner as shown "elow. Based on the enterprise's re8uirements, some of the
steps may "e excluded or included in addition to these.
)ometimes, data modeler may "e as!ed to deelop a data model "ased on the existing data"ase. In that
situation, the data modeler has to reerse engineer the data"ase and create a data model.
.teps to create a 0ogical Data Model:
;. =et Business re8uirements.
?. 7naly9e Business re8uirements.
@. (reate >igh %eel (onceptual Data Model. =et it approed.
A. (reate a new %ogical Data Model. 7dd the following to the logical data model.
B. )elect target data"ase where data modeling tool creates the scripts for physical schema.
C. (reate standard a""reiation document for naming logical and physical o"#ects according to
"usiness$data modeling standard.
D. (reate domain.
E. (reate rule.
F. (reate default.
;G. (reate Entity and add definitions.
;;. (reate attri"ute and add definitions.
;?. 7ssign data type to attri"ute. If a domain is already present then the domain should "e attached to
attri"ute.
;@. 7dd chec! constraint$rule or default to the columns 3whereer it is re8uired4.
;A. (reate primary or uni8ue !eys to attri"ute.
;B. (reate uni8ue index or "itmap index to attri"ute.
;C. Based on the analysis, create surrogate !ey columns.
;D. If re8uired, create super types and su" types.
;E. 7naly9e the relationship "etween entities and (reate foreign !ey relationship 3one to many or many to
many4 "etween those entities.
;F. (reate su"#ect areas and add releant entities to those su"#ect areas.
?G. 7lign the o"#ects in the main su"#ect area and other su"#ect areas.
?;. +alidate the data model.
??. =enerate reports from the data model.
?@. Ta!e a print out of the data model.
?A. =et it approed.
.teps to create a Physical Data Model:
;. (reate 2hysical Data Model from the existing logical data model.
?. 7dd data"ase properties to physical data model.
@. =enerate )6% )cripts from 2hysical Data Model. Tic! or chec! the necessary parameters in the tool,
create scripts and then forward that to DB7. 3DB7 will execute those scripts in data"ase4.
A. (ompare data"ase and data model. Ma!e sure eerything is o!ay.
B. (reate a change log document for differences "etween the current ersion and preious ersion of the
data model.
Maintenance o# Data Models::
;. Maintain %ogical 0 2hysical Data Model.
?. 5or each release 3ersion of the data model4, try to compare the present ersion with the preious
ersion of the data model. )imilarly, try to compare the data model with the data"ase to find out the
differences.
Data Modeler Role
Data Modelers fall into two ma#or categories of %ogical or 2hysical Data Modelers depending upon the role they
play in deeloping %ogical or 2hysical data models. Based on organi9ation needs, data modelers only do logical
data modeling or physical data modeling or com"ination of "oth. 1owadays, organi9ations prefer to hire data
modelers, who can do logical as well as physical data modeling efficiently. %ogical data modelers interact with
sta!e holders, "usiness analysts, smart management experts 3)ME4 and deelopers. 2hysical data modelers
interact with logical data modelers and the data"ase team. 5or logical data modeling, please refer %ogical Data
Modeling and for physical data modeling, please refer 2hysical Data Modeling.
0ogical Data Modeler Role:
'usiness Re(uirement "nalysis:
Interact with Business 7nalysts to get the functional re8uirements.
Interact with end users and find out the reporting needs.
(onduct interiews, "rain storming discussions with pro#ect team to get additional re8uirements.
=ather accurate data "y data analysis and functional analysis.
Development o# data model:
H (reate standard a""reiation document for logical, physical and dimensional data models.
H (reate logical, physical and dimensional data models3data warehouse data modelling4.
H Document logical, physical and dimensional data models 3data warehouse data modelling4.
Reports:
H =enerate reports from data model.
Review:
H *eiew the data model with functional and technical team.
.upport 3 Maintenance:
H 7ssist deelopers, ET%, BI team and end users to understand the data model.
H Maintain change log for each data model.
Physical Data Modeler Role:
H (reate s8l code from data model and co-ordinate with DB7s to create deelopment, testing, regression and
production data"ase.
H (hec! to see data models and data"ases are in sync.
H 7dding data "ase o"#ects 3li!e indexes, partitions in oracle data"ase4 for performance.
H =enerating reports.
Data Modeling standardi9ation has "een in practice for many years and the following section highlight the needs
and implementation of the data modeling standards.
.tandardi4ation 5eeds 6 Modeling data:
)eeral data modelers may wor! on the different su"#ect areas of a data model and all data modelers should use
the same naming conention, writing definitions and "usiness rules.
1owadays, "usiness to "usiness transactions3B?B4 are 8uite common, and standardi9ation helps in
understanding the "usiness in a "etter way. Inconsistency across column names and definition would create a
chaos across the "usiness.
5or example, when a data warehouse is designed, it may get data from seeral source systems and each source
may hae its own names, data types etc. These anomalies can "e eliminated if a proper standardi9ation is
maintained across the organi9ation.
Ta!le 5ames .tandardi4ation:
=iing a full name to the ta"les, will gie an idea a"out data what it is a"out. =enerally, do not a""reiate the
ta"le namesI howeer this may differ according to organi9ationJs standards. If the ta"le nameJs length exceeds
the data"ase standards, then try to a""reiate the ta"le names. )ome general guidelines are listed "elow that
may "e used as a prefix or suffix for the ta"le.
78amples:
%oo!up K %L2 - :sed for (ode, Type ta"les "y which a fact ta"le can "e directly accessed.
e.g. (redit (ard Type %oo!up K (*EDITM(7*DMT<2EM%L2
5act K 5(T - :sed for transaction ta"les,
e.g. (redit (ard 5act - (*EDITM(7*DM5(T
(ross *eference - /*E5 K Ta"les that resoles many to many relationships.
e.g. (redit (ard Mem"er /*E5 K (*EDITM(7*DMMEMBE*M/*E5
>istory K >I)T - Ta"les the stores history.
e.g. (redit (ard *etired >istory K (*EDITM(7*DM*ETI*EDM>I)T
)tatistics K )T7T - Ta"les that store statistical information.
e.g. (redit (ard -e" )tatistics K (*EDITM(7*DM-EBM)T7T
Column 5ames .tandardi4ation:
)ome general guidelines are listed "elow that may "e used as a prefix or suffix for the column.
78amples:
Ley K Ley )ystem generated surrogate !ey.
e.g. (redit (ard Ley K (*DTM(7*DMLE<
Identifier K ID - (haracter column that is used as an identifier.
e.g. (redit (ard Identifier K (*DTM(7*DMID
(ode K (D - 1umeric or alphanumeric column that is used as an identifying attri"ute.
e.g. )tate (ode K )TM(D
Description K DE)( - Description for a code, identifier or a !ey.
e.g. )tate Description K )TMDE)(
Indicator K I1D K to denote indicator columns.
e.g. =ender Indicator K =1D*MI1D
Data!ase Parameters .tandardi4ation:
)ome general guidelines are listed "elow that may "e used for other physical parameters.
78amples:
Index K Index K ID/ K for index names.
e.g. (redit (ard 5act ID/G; K (*DTM(7*DM5(TMID/G;
2rimary Ley K 2L K for 2rimary !ey constraint names.
e.g. (*EDIT (ard 5act 2LG;- (*DT-(7*DM5(TM2LG;
7lternate Leys K 7L K for 7lternate !ey names.
e.g. (redit (ard 5act 7LG; K (*DTM(7*DM5(TM7LG;
5oreign Leys K 5L K for 5oreign !ey constraint names.
e.g. (redit (ard 5act 5LG; K (*DTM(7*DM5(TM5LG;
0ogical 3 Physical Data Modeling O!9ects:
To "ecome a data modeler, you need to understand the concepts of a data"ase. Before proceeding further,
please isit our topics listed under the section NData"ase and Data ModelingN to get a fair !nowledge a"out the
data"ase. The following ta"le "riefs a"out the o"#ects used in constructing the data model especially in domains,
rules, chec! constraints, and su"#ect area.
What is a 0ogical Data Model
This is a "usiness presentation of o"#ects in a data"ase which represents the "usiness re8uirements 3entire or
part4 of an organi9ation. :sually o"#ect names are ery descriptie and )upertypes$)u"types, relationships
"etween different o"#ects are shown, which is ery easy for eery one to understand the "usiness of the
organi9ation.
What is a Physical Data Model
2hysical Data Model contains most of the o"#ects present in the data"ase. 5rom Deelopers perspectie, it
shows the ta"le name, column name, data type, null, not null, uni8ue constraint, primary !ey constraints, foreign
!ey constraints, which helps them to code.
O!9ects used in a Data Model
Data
Model
Type
Data Model
&"#ects
Explanation
%ogical
)u"#ect 7rea
or -or!
)pace
In a data model, there is one main su"#ect area which comprises all o"#ects present in
all su"#ect areas and other su"#ect areas "ased on their processes or "usiness
domains. Each su"#ect area contains o"#ects, which are releant to that su"#ect area
and the su"#ect area is ery useful in understanding the data model and to generate
reports and 2*I1T &:T) "ased on main su"#ect areas or other su"#ect areas. In a
telecommunication data model, there may "e seeral su"#ect areas li!e )erice
*e8uest, )erice &rder, Tic!eting and Main )u"#ect 7rea. In a Mortgage data model,
there may "e seeral su"#ect areas li!e "orrower, loan, under writing and main su"#ect
area. :sually su"#ect areas are created on main "usiness processes. In
Telecommunication 3telephone serice su"scription "y customer4, serice re8uest is a
process to get the re8uest from the customer through phone, email, fax etc. )erice
&rder is the next process to approe the serice re8uest and proide telephone line
su"scription to customers. Tic!eting is a process "y which complaints are gathered
from the customer and pro"lems are resoled.
2hysical
)u"#ect 7rea
or -or!
)pace
It is a copy of the logical su"#ect area "ut some o"#ects li!e supertype and su" types
o"#ects may not "e 7) I) li!e the logical su"#ect area.

%ogical Entity It is the "usiness presentation of a ta"le present in a data"ase. Example, (&:1T*<
2hysical Ta"le It is comprised of rows 0 columns, which stores data in a data"ase. Example, (1T*<

%ogical 7ttri"ute
It is the "usiness presentation of a column present in a data"ase. Example, (ountry
(ode, (ountry 1ame
2hysical (olumn
It is a data item, which stores data for that particular item. Example, (1T*<M(D,
(1T*<M1M

%ogical Default )ame as 2hysical data model. &nly the name changes.
2hysical Default
-hen user input is not present, default alue attached with the particular column is
inserted into that column.
.teps:
5irst, you hae to create a default o"#ect in the data model.
<ou hae to attach the default o"#ect with the column.
-hen you generate scripts from the physical data model, automatically,
default will "e attached to the column.
78ample $: <ou may need a situation, where system date and time should "e inserted
when the record is inserted. -ith &racle, you can attach )<)D7TE to that column.
(olumn name, T&D7<I Datatype, D7TEI Default )yntax , DE57:%T I &racle Default,
)<)D7TE T&D7< D7TE DE57:%T )<)D7TE
78ample +: <ou many need to !now a"out the schema name who inserted that record,
(olumn name, )(>EM7M17MEI Datatype, +7*(>7*?3@G4I Default )yntax,
DE57:%T I &racle Default, :)E* )(>EM7M17ME +7*(>7*?3@G4 DE57:%T :)E*

%ogical Domain )ame as 2hysical data model. &nly the name changes.
2hysical Domain
-hen you create a data model, there are seeral columns in ta"les, which are code,
identifier, indicators, descriptie columns, date columns, 1&T 1:%% columns, 2rimary
!ey columns etc. To ma!e it consistent across the data model, we can use domains.
.teps:
5irst, you hae to create a domain o"#ect in the data model.
<ou hae to attach the domain o"#ect with the column.
78ample: 5or a DE)(*I2TI&1 column, you can create a domain which has the
following 31&T 1:%%, Datatype as +7*(>7*? 3?GG44. <ou can attach this domain to
all descriptie columns present in ta"les. )o eery descriptie column present in the
ta"le will hae 1&T 1:%% as the constraint and datatype as +7*(>7*? 3?GG4.

%ogical
(hec!
(onstraint
*ule
)ame as 2hysical data model. &nly the name changes.
2hysical
(hec!
(onstraint
*ule
.teps:
5irst, you hae to create a rule o"#ect in the data model.
<ou hae to attach the rule o"#ect with the column or domain.
(hec! (onstraint *ule can "e imposed on columns li!e,
78ample $: Indicator (olumns, <es or 1&
78ample +: =ender (olumns, Male or 5emale
78ample /: Marital )tatus, Married or )ingle

%ogical 1:%%
There is no name for this 1:%% either in logical or physical data model. 1:%% is an
option so that it allows 1:%% alues for that column.
2hysical 1:%% (olumn allows 1:%% +7%:E) 3+alues can "e empty4.

%ogical
1ot 1ull
(onstraint
)ame as 2hysical data model. &nly the name changes.
2hysical
1ot 1ull
(onstraint
(olumn should always contain data.

%ogical
:ni8ue
(onstraint
)ame as 2hysical data model. &nly the name changes.
2hysical
:ni8ue
(onstraint
1on 1:%% +alues should "e different from each other.

%ogical
2rimary Ley
(onstraint
)ame as 2hysical data model. &nly the name changes.
2hysical
2rimary Ley
(onstraint
:ni8ue (onstraint O 1ot 1ull (onstraint.

%ogical 5oreign Leys )ame as 2hysical data model. &nly the name changes.
2hysical 5oreign Leys This is a constraint imposed on the child ta"le. -hateer alues are present in the
child ta"le, their corresponding alues should "e present in the parent ta"le. This
constraint can "e imposed on one column or group of columns and 1:%% alues are
allowed in child ta"le.

%ogical *elationships )ame as 2hysical data model. &nly the name changes.
2hysical *elationships
Identifying, 1on-Identifying, )elf *elationship for 1on Identifying relationship, M,1
relationship.

%ogical )e8uence )ame as 2hysical data model. &nly the name changes.
2hysical )e8uence To generate a uni8ue num"er, se8uence is used.

%ogical
+iews,
)ynonyms
)ame as 2hysical data model. &nly the name changes.
2hysical
+iews,
)ynonyms
:sually deelopment team and DB7 team does that.

%ogical
2rocedure,
5unction,
2ac!ages,
Triggers,
Materiali9ed
+iews
)ame as 2hysical data model. &nly the name changes.
2hysical
2rocedure,
5unction,
2ac!ages,
Triggers,
Materiali9ed
+iews
:sually deeloper write these and some times data modelers implement that in the
new data model.

%ogical
Indexes and
:ni8ue
Indexes
)ame as 2hysical data model. &nly the name changes.
2hysical
Indexes and
:ni8ue
Indexes
Index is used for fastest retrieal of data from the data"ase. -heneer a primary !ey
constraint is created on a ta"le, index is also created. -hen we use a column in the
where clause, data modelers index it after getting guidance from the deelopment
team and DB7 team. :ni8ue Index is created when there is a need for uni8ue alues
in that column.

%ogical
)uper Type
and )u" Type
)upertype is an entity type that has got relationship 3parent to child relationship4 with
one or more su"types and it contains the attri"utes that are common to its su"types.
)u"types are su"groups of the supertype entity and hae uni8ue attri"utes, they will "e
different from each su"types. )upertypes and su"types are parent and child entities
respectiely and the primary !eys of supertype and su"type are always identical. 5or
detailed explanation, isit our we"site in )upertype 0 )u"type.
2hysical
)uper Type
and )u" Type
+isual representation of supertypes and su"types will not "e identical in logical and
physical data model. In logical data model, it explains a"out the "usiness, "ut the same
cannot "e incorporated in physical data model.
Why do we need to create Domains: De#aults 3
Chec; Constraints
-hen you create domains, defaults and attach them to the columns in a data model, you are actually speeding
up the data model creation process "y using the pre-defined datatypes for all the similar columns. Metadata$data
in the data"ase and data structures will "e consistent across the data models so that conflicts can "e reduced.
(hec! constraints enforce some rules on columns in the data model as per your instructions.
In this section, you will see how you can create domain, defaults and chec! constraints "y using T&7D Data
Modeler for the sample data shown "elow. To !now more a"out the definitions and meaning of a domain, defaults
and chec! constraints, please refer our earlier section Data Modeling &"#ects listed under the category Data
Modeling.
.ample Data:
(olumn 1ame DataType
5:%%M17ME +7*(>7*?3@G4 1&T 1:%%
)T*EETM17ME +7*(>7*?3@G4 1&T 1:%%
(IT<M17ME +7*(>7*?3@G4 1&T 1:%%
=E1DE* (>7*3;4 1&T 1:%%
))1 (>7*3F4 1&T 1:%%
*E(&*DMD7TE D7TE 1&T 1:%%
:)E*M17ME +7*(>7*?3@G4 1&T 1:%%
.ample Data O!servation:
<ou see columns 5:%%M17ME, (IT<M17ME, )T*EETM17ME, and :)E*M17ME with the same
datatype of +7*(>7*? 3@G4. )o, first create a domain with datatype as +7*(>7*? 3@G4. Then attach it
to four of these columns.
5or column =E1DE*, it can ta!e only two alues. (reate a chec! constraint.
5or column ))1, it should contain only numerical alues. )o create chec! constraint.
5or column *E(&*DMD7TE, it will store system date. )o create a default.
5or column :)E*M17ME, it will store the name of the user who inserted or updated that record. )o
create a default.
.teps to !e #ollowed in Toad:
=o to T&7D D7T7 M&DE%E* and create a ta"le ND&M7I1M*:%EMDE57:%TN as mentioned in the
section (reate Data Modeling &"#ects.
Domain:
o Creating Domain: Go to menu "MODEL/DOMAIN". In the new window, clic add. !" de#ault, a
domain i$ created %" &OAD. Change ca'tion and name to "NAME(DOMAIN" and change
datat"'e to )A*C+A*,-./0.
o Attaching Domain$: 1ou ha2e to attach domain "NAME(DOMAIN" #or 34LL(NAME,
CI&1(NAME, 5&*EE&(NAME, and 45E*(NAME. 6hile creating column$, "ou can $ee a li$t
%o7 #or attaching DOMAIN5. 5elect the domain "NAME(DOMAIN" and attach it to tho$e
column$.
De#ault:
o Creating De#ault #or column *ECO*D(DA&E: Go to menu "MODEL/DE3A4L&". In the new
window, clic add. !" de#ault a domain created %" &OAD. Edit in General ta% and Change
ca'tion and name to "&ODA1(DA&E(DE3A4L&". In 58L ta%, t"'e the $"nta7 "515DA&E".
o Creating De#ault #or column 45E*(NAME: 3or column 45E*(NAME, create another de#ault
*ECO*D(!1(45E*(DE3A4L& and in 58L ta%, t"'e the $"nta7 "45E*".
o Attaching column$ to De#ault$: 1ou ha2e to attach the De#ault "&ODA1(DA&E(DE3A4L&" to
column "*ECO*D(DA&E". 6hile creating column$, "ou will $ee a li$t %o7 #or attaching
De#ault$. 5elect the de#ault "&ODA1(DA&E(DE3A4L&" and attach it to *ECO*D(DA&E
column. Do the $ame 'rocedure #or the other column 45E*(NAME to attach it to the de#ault
"*ECO*D(!1(45E*(DE3A4L&".
C<7C= Constraint:
o Creating and attaching Chec Con$traint: 6hile creating the column gender, "ou can $ee a ta%
"chec con$traint$". Clic add. !" de#ault a chec con$traint i$ created %" &OAD. Edit in
General ta% and change ca'tion and name to "GENDE*(C+EC9". In $:l ta%, t"'e "gender in
-;M<, ;3<0".
o 5imilarl" do it #or 55N column al$o. In $:l ta%, t"'e 55N !E&6EEN ;////////=< AND
;>>>>>>>>><
This is how the ta"le loo!s in a Data Model.
(olumn 1ame Data Type
5:%%M17ME 17MEMD&M7I1 11
)T*EETM17ME 17MEMD&M7I1 11
(IT<M17ME 17MEMD&M7I1 11
=E1DE* (har3;4 11
))1 (har3F4 11
*E(&*DMD7TE Date 11
:)E*M17ME 17MEMD&M7I1 11
1ote, 11 means 1&T 1:%%.
In few columns, you see 17MEMD&M7I1. The domain that you attached is displayed here instead of data type.
DD0 .cript #or this ta!le:
(*E7TE T7B%E ND&M7I1M*:%EMDE57:%TN3
N5:%%M17MEN +archar?3@G 4 1&T 1:%%,
N)T*EETM17MEN +archar?3@G 4 1&T 1:%%,
N(IT<M17MEN +archar?3@G 4 1&T 1:%%,
N=E1DE*N (har3; 4 1&T 1:%% (&1)T*7I1T N=E1DE*M(>E(LN (>E(L 3=E1DE* I1 3PMJ, P5J44,
N))1N (har3F 4 1&T 1:%% (&1)T*7I1T N))1M(>E(LN (>E(L 3))1 BET-EE1 3PGGGGGGGG;J 71D
PFFFFFFFFFJ44,
N*E(&*DMD7TEN Date DE57:%T )ysdate 1&T 1:%%,
N:)E*M17MEN +archar?3@G 4 DE57:%T :)E* 1&T 1:%%4
Data Model Repository:
7 data modeling repository is a storage area, where metadata of a data model is stored. The data stored is
different from the software perspectie, organi9ation's perspectie and usage perspectie. *epository can "e
stored any whereI either in a data "ase or locally within any system.
Example, ET% *epository and Data Modeling *epository are different "ased on the software$usage perspectie.
In Data Modeling repository, meta data related to data modeling is stored and in ET% repository, meta data
related to ET% 3Extraction, Transformation, and %oading4 is stored. &rgani9ation will only store the meta data that
they are interested.
5rom the data modeling perspectie, data models and releant meta data are stored in repository.
-heneer there are seeral data modelers wor!ing in an organi9ation, and if they hae to access the same data
models concurrently, organi9ations "uy repository. &therwise, they store meta data in a shared networ!.
-hen data modeling software is "ought with repository tool, system administrators install repository and share
the username$password to the NData Model *epository 7dministratorN. This NData Model *epository
7dministratorN has super priileges.
The administrator creates usernames and allocates priileges on data models for "usiness analysts, )ME, data
modelers, 7pplication deelopers 3deelopment$reporting4, DB7's, Business :sers, Managers etc.
78amples o# Privileges "llocated:
(reation and :pdation of %ogical Data Model. Based on the needs, priileges will "e allocated on 7%% or
5E- or &1E data model present in the organi9ation.
(reation and :pdation of 2hysical Data Model Based on the needs, priileges will "e allocated on 7%%
or 5E- or &1E data model present in the organi9ation.
(reation and :pdation of %ogical$2hysical Data Model Based on the needs, priileges will "e allocated
on 7%% or 5E- or &1E data model present in the organi9ation.
+iew %ogical Data Model or 2hysical Data Model or "oth.
(reation and :pdation of a particular data"ase o"#ect 3ta"les, iews, indexes etc.4
7ll you hae to !now is how to login, log out, priileges allocated, different menus present in repository and how
to wor! in repository. etc.
>ses o# Repository:
>elps the data modelers to wor! on the same data model consistently$colla"oratiely and merge all
wor! actiities in the same data model itself.
(reating different +ersion of the data model to !eep trac! of changes.
=enerating *eports from the repository.
7pplying security to data model.
Bac! :p and *ecoery of the data models.
Data Model ?ersioning
DataModel +ersioning is the process of assigning either uni8ue ersion names or uni8ue ersion num"ers to
different stages of a data model. Data Modeling tools may hae this ersioning facility in their software itself and
ersions of data models may "e stored in their repository.
The following information #ust gies an idea a"out how to do ersioning manually.
78ample:
a4 Q2ro#ect 1ameRMQmmddyyyyRI Ban!ingMG;G;?G;G
"4 Q2ro#ect 1ameRMQ+ersion 1um"erRI Ban!ingM;
During the deelopment cycle of the data model, )ME's 3)mart Management Experts4 or Business 7nalysts will
re8uest the data modeling team to create a new su"#ect area for a new line of "usiness or modify the existing
su"#ect area.
In the initial stages of deelopment of a data model, wheneer a new su"#ect area is added to the data model or
changes done to the data model, immediately, data model changes will "e sent to the Npro#ect teamN "y email.
Data Models are stored in a shared networ! where Npro#ect teamN will hae priileges to iew the data model and
Ndata modelersN will hae priileges to update the data model.
Practical 78ample:
To start with, 7 "an! may hae Nsaings accountN as their line of "usiness. %ater it may add a different line of
"usiness N(redit (ardN. To start with, data model will hae only only su"#ect area N)aings 7ccountN. -hen credit
card is added to the "an!'s "usiness, )MEs or "usiness analyst will analy9e it and they will send a new
re8uirement to the data modeling team to add different entities in the logical data model. They may also send few
changes3add attri"ute$delete attri"ute4 in existing N)aings 7ccountN data model. In order to !eep trac! of these
changes, we need ersioning of the data model.
?ersioning 78ample:
7ssume that this data model wor! will "e completed within C months starting from San ?G;G and ending in Sune
?G;G.
In the shared networ! allocated for the pro#ect team, create a folder called NData ModelingN. :nder data
modeling, create su" folders li!e NSan ?G;GN, N5e" ?G;GN, NMar ?G;GN, N7pr ?G;GN, NMay ?G;GN and NSune ?G;GN.
The logic "ehind this is data model updates done in that particular month are stored under that month folder.
5or Data Models, )tart with ersion +; in Sanuary and update it to +? in 5e"ruary. -hateer other changes you
do within that particular month, suffix N+;N or N+?N "y .;, .? etc.
Date, ;st Sanuary ?G;G, 7 new re8uirement to create N)aings 7ccountN data model was gien "y )MEs
or "usiness analysts. 7ssume that the pro#ect name is NBan!ingN. (reate a data model "y name
NBan!ingM;N and add necessary entities in the data model. )ae it under NSan ?G;GN folder.
Date, ?Bth Sanuary ?G;G, 5ew changes hae "een sent "y )MEs for N)aings 7ccountN su"#ect area.
)ae the existing data model as NBan!ingM+;.;N, update the changes and store it under NSan ?G;GN
folder. 1ow you hae two ersions of the data model.
Date, ?Bth 5e"ruary ?G;G, 7 new re8uirement a"out N(redit (ardN was sent "y )MEs. )ae the the
latest model NBan!ingM;.;N as NBan!ingM?N and apply the changes. 1ow you hae three ersions of
data model. )tore it under N5e" ?G;GN folder.
"dvantages:
Data Model (hanges can "e trac!ed. -ee!ly or monthly changes can "e sent to the pro#ect team "y
email.
Data Model can "e compared with the data "ase and data models can "e "rought in )<1( with data
"ase.
(hanges can "e easily rolled "ac! 3*emoing the changes4. If )MEs or "usiness analysts are not sure,
ery often these roll "ac!s will happen.
*eports can "e generated from the data model and sent to the Ndocumentation teamN.
(larity within the pro#ect team.
)ome times the pro#ect team may "e interested in a particular ersion of the data model. Its easier to
send that particular ersion of the data model.
Interview Question:
>ow do you implement data model ersioning.
Data Modeling Report
5rom Data Modeling tools, reports can "e easily generated for technical and "usiness needs. The reports that
hae "een generated from logical data model and physical data model are called as "usiness reports and
technical reports respectiely. Most of the data modeling tools proide default reports li!e su"#ect area reports,
entity reports, attri"ute reports, ta"le reports, column reports, indexing reports, relationship reports etc. The
adantage of these reports is, whether they are technical or non-technical, eery"ody would understand what is
going on within the organi9ation.
&ther than default reports proided "y data modeling tools, a data modeler can also create customi9ed reports
as per the needs of an organi9ation. 5or example, if an expert as!s of "oth logical and physical reports of a
particular su"#ect area in one file3e.g in .xls4, logical and physical reports can "e easily merged and reports can
"e easily generated accordingly. Data Modeling tools proide the facility of sorting, filtering options and the
reports can "e exported into file formats li!e .xls, .doc, .xml etc.
0ogical Data Model Report:
%ogical Data Model *eport descri"es information a"out "usiness such as the entity names, attri"ute names,
definitions, "usiness rules, mapping information etc.
0ogical Data Model Report 78ample:
Physical Data Model Report:
2hysical Data Model *eport descri"es information such as the ownership of the data"ase, physical
characteristics of a data"ase 3in oracle, ta"le space, extents, segments, "loc!s, partitions etc4, performance
tuning 3processors, indexing4, ta"le name, column name, data type, relationship "etween the ta"les, constraints,
a""reiations, deriation rules, glossary, data dictionary, etc., and is used "y the technical team.
Physical Data Model Report 78ample:
Data Modeling Tools
There are a num"er of data modeling tools to transform "usiness re8uirements into logical data model, and
logical data model to physical data model. 5rom physical data model, these tools can "e instructed to generate
s8l code for creating data"ase.
Popular Data Modeling Tools
Tool 1ame (ompany 1ame
Erwin (omputer 7ssociates
Em"arcadero Em"arcadero Technologies
*ational *ose IBM (orporation
2ower Designer )y"ase (orporation
&racle Designer &racle (orporation
/case *E)olution %TD.
Data Modeling Tools: What to 0earn
Data modeling tools are the only way through which we can create powerful data models. 5ollowing are the
arious options that we hae to !now and learn in data modeling tools "efore start "uilding data models.
0ogical Data Model:
H >ow to create entity and add definition, "usiness rule.
H >ow to create domains.
H >ow to create an attri"ute and add definition, "usiness rule, alidation rules li!e default alues and chec!
constraint.
H >ow to create supertypes, su"types.
H >ow to create primary !eys, uni8ue constraint, foreign !ey relationships, and recursie relationships.
H >ow to create identifying and non-identifying relationship.
H >ow to assign relationship cardinality.
H >ow to phrase relationship connecting two ta"les.
H >ow to assign role names.
H >ow to create !ey groups.
H >ow to create se8uence no's.
Physical Data Model:
H >ow to rename a ta"le.
H >ow to rename a column,alidation rules li!e default and chec! constraints.
H >ow to assign 1:%% and 1&T 1:%% to columns.
H >ow to name foreign !ey constraints.
H >ow to connect to data"ases li!e M) 7ccess, &racle, )i"ase, Terradata etc.
H >ow to generate s8l code from data model to run against data"ases li!e M) 7ccess, &racle, )i"ase, Terradata
etc..
H >ow to create a data model from an existing data"ase li!e M) 7ccess, &racle, )i"ase, Terradata etc..
H >ow to add data"ase related properties to ta"les, indexes.
H >ow to chec! different ersions of the data model.
H >ow many data modelers can concurrently wor! on the same ersion of a data model.
Dimensional Data Model:
H Is there any specific notation to identify a Data -arehouse$Data mart data models.
.u!9ect "rea:
H >ow to create su"#ect area and assign releant entities to su"#ect area.
Reports:
H >ow to generate reports from data model and export to ./%), .D&(, ./M% file formats.
5aming Options:
H Is there any method to change the entity$ta"le, attri"ute$column name from upper case to lower case or lower
case to upper case.
Import 3 78port:
H >ow to create data models from .xls, .txt files etc..
H >ow to import and export meta data into ET% tools.
"!!reviation Document:
H >ow to create$attach a standard a""reiation document3for naming ta"les, columns etc.4.
Print:
H >ow to send data models to printer$plotter$7cro"at *eader.
'ac;up:
H >ow to ta!e "ac!up of data model.
Others:
H >ow to split a data model to logical and physical data model.
H >ow to copy and paste o"#ects within data model and across data models.
H >ow to search an o"#ect within a data model.
H >ow to change the font si9e and color of entities,attri"utes,relationship lines.
H >ow to create a legend.
H >ow to show a data model in different leels li!e entity leel, attri"ute leel, and definition leel.
7rwin Tutorial
7ll 5usion Erwin Data Modeler commonly !nown as 7rwin, is a powerful and leading data modeling tool from
(omputer 7ssociates. (omputer 7ssociates deliers seeral software for enterprise management, storage
management solutions, security solutions, application life cycle management, data management and "usiness
intelligence.
Erwin ma!es data"ase creation ery simple "y generating the DD%3s8l4 scripts from a data model "y using
its *orward 7ngineering techni8ue or Erwin can "e used to create data models from the existing data"ase "y
using its Reverse 7ngineering techni8ue.
7rwin wor;place consists o# the #ollowing main areas:
0ogical, In this iew, data model represents "usiness re8uirements li!e entities, attri"utes etc.
Physical, In this iew, data model represents physical structures li!e ta"les, columns, datatypes etc.
Modelmart, Many users can wor! with a same data model concurrently.
What can !e done with 7rwin
%ogical, 2hysical and dimensional data models can "e created.
Data Models can "e created from existing systems3rd"ms, d"ms, files etc.4.
Different ersions of a data model can "e compared.
Data model and data"ase can "e compared.
)6l scripts can "e generated to create data"ases from data model.
*eports can "e generated in different file formats li!e .html, .rtf, and .txt.
Data models can "e opened and saed in seeral different file types li!e .er;, .ert, ."px, .xml, .ers,
.s8l, .cmt, .df, .d"f, and .md" files.
By using ModelMart, concurrent users can wor! on the same data model.
In order to create data models in Erwin, you need to hae this 7ll 5usion Erwin Data Modeler installed in your
system. If you hae installed Modelmart, then more than one user can wor! on the same model.
<ow to create a 0ogical Data Model using C" 7rwin
Data Modeler ?ersion @
In the following section, a simple example with a step "y step procedure to create a logical data model with two
entities and their relationship are explained in detail.
&pen (7 Erwin Data Modeler +ersion F software.
=o to menu 'file' and clic! 'new'. 7 new "ox will "e displayed. (lic! the "utton logical$physical from type.
5rom the drop down list "ox, select 'oracle' as the data"ase and ersion as ';Gg$;;g'. (lic! &L "utton. 7
new wor!space is created. To select notation 'IDE5;/' or 'IE' =o to M&DE%$M&DE%
2*&2E*TIE)$=E1E*7% T7B to change.
7"oe the wor!space, you can see menus 5ile, Edit, +iew, Diagram, Model, 7ctions, Tools, -indows,
>elp. Below that you can see the following tool "ars. )tandard, Tool"ox, 5ormatting, %ayout, Toom,
Display, Mart, Data"ase, 7lignment, Drawing, Transformations, (ustomi9e. &n the display tool"ar, you
can see '%ogical' selected "y default i.e. you will "e wor!ing on creation of a logical data model.
To create an Entity, clic! the icon NEntityN from 'Tool"ox' Tool"ar and drop it on the wor!place. By default
E$; will "e displayed as the entity name and type it as '(ountry'.
To create an 7ttri"ute, 2lace the cursor on the entity '(ountry' and right clic! it. 5rom the displayed
menu, clic! attri"ute properties which will ta!e you to the attri"ute wi9ard. <ou can see a "utton 1ew.
(lic! '1ew' on the wi9ard and type attri"ute name as '(ountry (ode'. <ou can see different headers li!e
'2arent Domain', '%ogical Datatype', '2rimary Ley', '5oreign Ley, '%ogical &nly'. )elect the parent domain
as 'string' and "y default logical datatype "ecomes 'archar?3?G4'. (hange the datatype to 'archar? 3?4I
(lic! the chec! "ox near the primary !ey. )imilarly create another column (ountry 1ame with parent
domain as 'string' and datatype as 'archar? 3BG4'. )elect 1:%% &2TI&1 as '1&T 1:%%' from the 1:%%
&2TI&1 list "ox. T>E*E 7*E DI55E*E1T T7B) %ILE '=eneral', '(onstraint', '%in!', 'Ley =roups',
')tyle', 'Definition', '-here :sed', ':D2', '1otes' etc. To create constraints, you can use 'constraint' ta".
To create indexes, you can use '!ey groups' ta". 5or typing attri"ute definition ' you can use 'definition
ta"'. 5or changing font si9e, font name, font color, you can use 'style ta"'. 5or seeing the properties li!e
eent, date created, created "y, data modified, modified "y, you can use '1otes' ta". (lic! o!, and now
you will "e haing ? attri"utes (ountry (ode, and (ountry 1ame under the entity '(ountry' in the current
logical wor!place.
(reate another entity 'Ban!' with two attri"utes namely Ban! (ode and Ban! 1ame.
In order to relate these two ta"les country, "an!, a 5oreign Ley relationship must "e created. To create
a 5oreign Ley relationship, follow these steps.
o Clic the $"m%ol ?Non Identi#"ing *elation$hi'? #rom ?&ool%o7? &ool%ar.
o @lace the cur$or on the entit" ?Countr"?.
o @lace the cur$or on the entit" ?!an?. Now "ou can $ee the relation$hi' -a line drawn #rom !an
to Countr"0 %etween ?Countr"? and ?!an?. Dou%le clic on that relation$hi' line to o'en
?*elation$hi'$ wiAard? and change the o'tion #rom ?Null$ Allowed? to ?No Null$? $ince %an
$hould ha2e a countr" code.
The %ogical Data Model created "y following the a"oe steps loo!s similar to the following diagram.
)7+E, To sae the file, clic! sae "utton in the 'standard' tool "ar and sae it
as .'(7MErwinMDataMModelerMFMexample' and file type will "e .erwin.
>ow to create a 2hysical Data Model using (7 Erwin Data Modeler +ersion F.
(hange the iew from '%ogical to 2hysical' from the drop down list.
If you want to add some physical properties, you can add it here.
78planation:
In the logical iew, -hen you right clic! and iew entity properties for entity '(ountry', you can see ta"s li!e
olumetrics, definition, style, icon, where used, :D2, 1&TE) etc. The information that you fill will explain a"out
entity properties.
In the physical iew, when you right clic! and iew ta"le properties for ta"le 'country', you can see ta"s li!e ta"le
options, general, partitions, supplemental logging, alidation, materiali9ed iew log, style, icon, synonym
comment, o"#ect creation order, where used, :D2, 1otes etc. If you are an expert, then you can fill releant
details in the a"oe mentioned ta"s so that it will "e useful while creating scripts. If you are not an expert, you
can discuss with DB7s, get releant information and fill details.
<ow to generate DD0,s(l- scripts to create a
data!ase using C" 7rwin Data Modeler ?ersion
@
(lic! menu 'edit'. 1aigate to 'selection' and clic! 'select all'. &"#ects "an! and country will "e highlighted.
(lic! the 'forward engineer schema generation' icon in the 'data"ase' tool "ar. 7 new -i9ard appears.
There are two "oxes. &n the left side "ox, you can seeral data"ase o"#ects. &n the right side "ox, you can see
different options for each o"#ect.
%eft )ide Box *ight )ide Box
Data"ase Do not select anything
)chema Do not select anything
)torage Do not select anything
Ta"le ;4 (hec! ta"le under 'create' option
Materiali9ed +iew %og Do not select anything
(olumn Do not select anything
Materiali9ed +iew Do not select anything
+iew Do not select anything
Index Do not select anything
*eferential Integrity
;4 (hec! 'create$p!' under 'primary !ey$p!'I
?4 (hec! 'create$f!' under 'foreign !ey 35L4'
Trigger Do not select anything
&ther &ptions (lic! 'constraint name'
(lic! preiew. <ou can see the s8l code generated "y Erwin data modeler tool.
(*E7TE T7B%E (ountry 3 (ountryM(ode +7*(>7*?3?4 1&T 1:%% ,
(ountryM1ame +7*(>7*?3BG4 1&T 1:%% ,
(&1)T*7I1T /2L(ountry 2*IM7*< LE< 3(ountryM(ode4 4I
(*E7TE T7B%E Ban! 3 Ban!M(ode +7*(>7*?3?4 1&T 1:%% ,
Ban!M1ame +7*(>7*?3BG4 1&T 1:%% ,
(ountryM(ode +7*(>7*?3?4 1&T 1:%% ,
(&1)T*7I1T /2LBan! 2*IM7*< LE< 3Ban!M(ode4,
(&1)T*7I1T (ountryMtoMBan! 5&*EI=1 LE< 3(ountryM(ode4 *E5E*E1(E) (ountry 3(ountryM(ode4 4I
<ou are here, >ome Data Modeling >ow to create a %ogical Data Model using (7 Erwin.
<ow to create a 0ogical Data Model using 7rwin
1%$%1 version
In the following section, a simple example with a step "y step procedure to create a logical data model with two
entities and their relationship are explained in detail.
$, &pen 7ll 5usion Erwin Data Modeler software.
+, )elect the iew as N%ogicalN from the drop-down list. By default, logical will "e your wor!place.
/, (lic! 1ew from 5ile menu. )elect the option N%ogical$2hysicalN from the displayed wi9ard. (lic! &!.
1, To create an 7ntity, clic! the icon NEntityN and drop it on the wor!place. By default E$; will "e displayed as the
entity name. (hange it to N(ountryN.
2, To create an "ttri!ute, 2lace the cursor on the entity N(ountryN and right clic! it. 5rom the displayed menu,
clic! attri"utes which will ta!e you to the attri"ute wi9ard. (lic! N1ewN "utton on the wi9ard and type attri"ute
name as N(ountry (odeN. )elect the data type as N)tringN and clic! &L. )elect the option Primary =ey to identify
attri"ute N(ountry (odeN as the primary !ey. 5ollow the same approach and create another attri"ute N(ountry
1ameN without selecting the primary !ey option. (lic! o!, and now you will "e haing ? attri"utes (ountry (ode,
and (ountry 1ame under the entity N(ountryN in the current logical wor!place.
A, (reate another entity NBan!N with two attri"utes namely Ban! (ode and Ban! 1ame "y following steps A and
B.
B, In order to relate these two ta"les country, "an!, a *oreign =ey relationship must "e created. To create a
5oreign Ley relationship, follow these steps.
3a4 (lic! the sym"ol N1on Identifying *elationshipN.
3"4 2lace the cursor on the entity N(ountryN.
3c4 2lace the cursor on the entity NBan!N. 1ow you can see the relationship3a line drawn from Ban! to (ountry4
"etween N(ountryN and NBan!N. Dou"le clic! on that relationship line to open N*elationships wi9ardN and change
the option from N1ulls 7llowedN to N1o 1ullsN since "an! should hae a country code.
The %ogical Data Model created "y following the a"oe steps loo!s similar to the following diagram.
<ow to create a Physical Data Model using 7rwin
1%$%1 version
$, (hange the iew from N%ogical to 2hysicalN from the drop down list.
+, (lic! NData"aseN from main menu and then clic! N(hoose Data"aseN from the su" menu. Then select your
target data"ase serer where the data"ase has to "e created. (lic! o!.
/, 2lace the cursor on the ta"le N(ountryN and right clic! it. 5rom the displayed menu, clic! columns which will
ta!e you to the column wi9ard. (lic! the NData"ase Ta"N, which is next to N=eneral Ta"N and assign datatypes
N+7*(>7*?3;G4, +7*(>7*?3BG4 for columns (&:1T*<M(&DE and (&:1T*<M17ME respectiely. (hange
the default 1:%% to 1&T 1:%% for the column (&:1T*<M17ME. )imilarly, repeat the a"oe step for the B71L
ta"le. &nce you hae done all of these, you can see the physical ersion of the logical data model in the current
wor!place.
The 2hysical Data Model created "y following the a"oe steps loo!s similar to the following diagram.
<ow to generate DD0,s(l- scripts to create a data!ase:
$, )elect the iew as Physical from the drop down list.
+,(lic! NToolsN from main menu and then clic! N5orward Engineer$)chema =enerationN from the su" menu which
will ta!e you to the N)chema =eneration -i9ardN. )elect the appropriate properties that satisfies your data"ase
re8uirements li!e schema, ta"le, primary !ey etc. (lic! preiew to see your scripts. Either you can clic! to
generate the ta"le in a data"ase or you can store the scripts and run against the data"ase later.
The DD%3s8l4 scripts generated "y Erwin "y following the a"oe steps loo!s similar to the following script.
(*E7TE T7B%E (ountry3(ountryM(ode +7*(>7*?3;G4 1&T 1:%%,
(ountryM1ame +7*(>7*?3BG4 1&T 1:%%,
(&1)T*7I1T 2LM(ountry 2*IM7*< LE< 3(ountryM(ode44I
(*E7TE T7B%E Ban!3Ban!M(ode +7*(>7*?3;G4 1&T 1:%%,
Ban!M1ame +7*(>7*?3BG4 1&T 1:%%, (ountryM(ode +7*(>7*?3;G4 1&T 1:%%,
(&1)T*7I1T 2LMBan! 2*IM7*< LE<3Ban!M(ode4 4I
7%TE* T7B%E Ban! 7DD3 (&1)T*7I1T 5LMBan!
5&*EI=1 LE< 3(ountryM(ode4 *E5E*E1(E) (ountry 4I
1ote,This is not a complete tutorial on Erwin. -e will add more Tips and =uidelines on Erwin in near future.
2lease isit us soon to chec! "ac!. To !now more a"out Erwin, contact its official we"site www.ca.com.
Conceptual Data Modeling
(onceptual data model includes all ma#or entities and relationships and does not contain much detailed leel of
information a"out attri"utes and is often used in the I1ITI7% 2%711I1= 2>7)E.
(onceptual data model is created "y gathering "usiness re8uirements from arious sources li!e "usiness
documents, discussion with functional teams, "usiness analysts, smart management experts and end users who
do the reporting on the data"ase. Data modelers create conceptual data model and forward that model to
functional team for their reiew.
Conceptual Data Model ) <ighlights
(DM is the first step in constructing a data model in top-down approach and is a clear and accurate
isual representation of the "usiness of an organi9ation.
(DM isuali9es the oerall structure of the data"ase and proides high-leel information a"out the
su"#ect areas or data structures of an organi9ation.
(DM discussion starts with main su"#ect area of an organi9ation and then all the ma#or entities of each
su"#ect area are discussed in detail.
(DM comprises of entity types and relationships. The relationships "etween the su"#ect areas and the
relationship "etween each entity in a su"#ect area are drawn "y sym"olic notation3IDE5;/ or IE4. In a
data model, cardinality represents the relationship "etween two entities. i.e. &ne to one relationship, or
one to many relationship or many to many relationship "etween the entities.
(DM contains data structures that hae not "een implemented in the data"ase.
In (DM discussion, technical as well as non-technical team pro#ects their ideas for "uilding a sound
logical data model.
(onsider an example of a "an! that contains different line of "usinesses li!e saings, credit card, inestment,
loans and so on. In example3figure ;.;4 conceptual data model contains ma#or entities from saings, credit card,
inestment and loans. (onceptual data modeling gies an idea to the functional and technical team a"out how
"usiness re8uirements would "e pro#ected in the logical data model.
Conceptual Data Modeling ) 78ample diagram: *igure $%$
7nterprise Data Modeling
The deelopment of a common consistent iew and understanding of data elements and their relationships
across the enterprise is referred to as Enterprise Data Modeling. This type of data modeling proides access to
information scattered throughout an enterprise under the control of different diisions or departments with
different data"ases and data models.
Enterprise Data Modeling is sometimes called as glo"al "usiness model and the entire information a"out the
enterprise would "e captured in the form of entities.
Data Model <ighlights
-hen a enterprise logical data model is transformed to a physical data model, super types and su" types may
not "e as is. i.e. the logical and physical structure of super types and su" types may "e entirely different. 7 data
modeler has to change that according to the physical and reporting re8uirement.
-hen a enterprise logical data model is transformed to a physical data model, length of ta"le names, column
names etc may exceed the maximum num"er of the characters allowed "y the data"ase. )o a data modeler has
to manually edit that and change the physical names according to data"ase or organi9ationJs standards.
&ne of the important things to note is the standardi9ation of the data model. )ince a same attri"ute may "e
present in seeral entities, the attri"ute names and data types should "e standardi9ed and a conformed
dimension should "e used to connect to the same attri"ute present in seeral ta"les.
)tandard 7""reiation document is a must so that all data structure names would "e consistent across the data
model.
Enterprise Data Modeling Example, )ee 5igure ;.A "elow
(onsider an example of a "an! that contains different line of "usinesses li!e saings, credit card, inestment,
loans and so on. In example, enterprise data model contains all entities, attri"utes, relationships, from lines of
"usinesses saings, credit card, inestment and loans.
0ogical Data Modeling
This is the actual implementation and extension of a conceptual data model. 7 %ogical data model is the ersion
of a data model that represents the "usiness re8uirements3entire or part4 of an organi9ation and is deeloped
"efore the physical data model.
7s soon as the conceptual data model is accepted "y the functional team, deelopment of logical data model
gets started. &nce logical data model is completed, it is then forwarded to functional teams for reiew. 7 sound
logical design should streamline the physical design process "y clearly defining data structures and the
relationships "etween them. 7 good data model is created "y clearly thin!ing a"out the current and future
"usiness re8uirements. %ogical data model includes all re8uired entities: attri!utes: ;ey groups: and
relationshipsthat represent "usiness information and define "usiness rules.
78ample o# 0ogical Data Model: *igure $%+
In the example, we hae identified the entity names, attri"ute names, and relationship. 5or detailed explanation,
refer to relational data modeling.
Physical Data Modeling
2hysical data model includes all re8uired ta!les: columns: relationships: data!ase properties for the physical
implementation of data"ases. Data"ase performance, indexing strategy, physical storage and de-normali9ation
are important parameters of a physical model.
%ogical data model is approed "y functional team and there-after deelopment of physical data model wor! gets
started. &nce physical data model is completed, it is then forwarded to technical teams3deeloper, group lead,
DB74 for reiew. The transformations from logical model to physical model include imposing data"ase rules,
implementation of referential integrity, super types and su" types etc.
78ample o# Physical Data Model: *igure $%/
In the example, the entity names hae "een changed to ta"le names, changed attri"ute names to column names,
assigned nulls and not nulls, and datatype to each column.
Relational,O0TP- Data Modeling
*elational Data Model is a data model that iews the real world as entities and relationships. Entities are
concepts, real or a"stract a"out which information is collected. Entities are associated with each other "y
relationship and attri"utes are properties of entities. Business rules would determine the relationship "etween
each of entities in a data model.
The goal of relational data model is to normali9e 3aoid redundancy4data and to present it in a good normal form.
-hile wor!ing with relational data modeling, a data modeler has to understand ;st normal form through Bth
normal form to design a good data model.
5ollowing are some of the 8uestions that arise during the deelopment of entity relationship data model. 7
complete "usiness and data analysis would lead to design a good data model.
;H -hat will "e the future scope of the data model. >ow to normali9e the data.
?H >ow to group attri"utes in entities.
@H >ow to name entities, attri"utes, !eys groups, relationships.
AH >ow to connect one entity to other. -hat sort of relationship is that.
BH >ow to alidate the data.
CH >ow to normali9e the data.
DH >ow to present reports.
The sample source data shown in the ta"le "elow proides the information a"out employees, their residential
state, county, city and their employer names and manager names. It also descri"es employees wor!ing for an
N7merican Ban!N that has got many "ranches in seeral states. 5rom data modeler point of iew, analysis of the
source data raises following 8uestions.
>ow to group and organi9e the data.
>ow to aoid de-normali9ation since employee's residential data li!e state name, county 1ame, city
1ame are repeated in most of the records.
-hat sort of relationship is "etween employer and employee.
-hat sort of relationship is "etween the employee and state, city, county.
.ample .ource Data
)tate
1ame
(ounty
1ame
(ity 1ame
Emp
5irst
1ame
Emp %ast
1ame
Emp 5ull
1ame
Manager
1ame
Employer
1ame
DateTime
)tamp
1ew <or! )hel"y Manhattan 2aul <oung
2aul
<oung
7merican
Ban! of
1ew <or!
;$;$?GGB
;;,?@,@;
7M
5lorida Sefferson
2anama
(ity
(hris Dais
(hris
Dais
2aul
<oung
7merican
Ban! of
5lorida
;$;$?GGB
;;,?@,@;
7M
(alifornia Montgomery )an >ose %ouis Sohnson
%ouis
Sohnson
2aul
<oung
7merican
Ban! of
(alifornia
;$;$?GGB
;;,?@,@;
7M
1ew
Sersey
>udson Sersey (ity )am Mathew
)am
Mathew
2aul
<oung
7merican
Ban! of
1ew
Sersey
;$;$?GGB
;;,?@,@;
7M
1ew <or! )hel"y Manhattan 1ancy *o"inson
1ancy
*o"inson
2aul
<oung
7merican
Ban! of
1ew <or!
;$;$?GGB
;;,?@,@;
7M
5lorida Sefferson
2anama
(ity
)heela )hellum
)heela
)hellum
(hris
Dais
7merican
Ban! of
5lorida
;$;$?GGB
;;,?@,@;
7M
(alifornia Montgomery )hel"y Seff Bill Seff Bill
%ouis
Sohnson
7merican
Ban! of
(alifornia
;$;$?GGB
;;,?@,@;
7M
1ew
Sersey
>udson Sersey (ity Sohn Burrell
Sohn
Burrell
)am
Mathew
7merican
Ban! of
1ew
Sersey
;$;$?GGB
;;,?@,@;
7M
In the next page, we will discuss how to resole these pro"lems in order to design a good relational data model.
:pon discussion with "usiness analysts, data modeler can come up with the following conclusions regarding
grouping and relationship "etween the data. These conclusions play a ital role in designing the data model as
well as expanding for future scope.
Many cities can "e in one county. (ity names will "e uni8ue across the country.
Many counties can "e in one state. (ounty names will "e uni8ue across the country.
Many states can "e in :)7. )tate names will "e uni8ue across the country :)7.
&ne employee can wor! with many "ranches at same time.
5or some employees, managers may not "e there.
In order to implement the a"oe decisions, relational data modeling is done in the following manner.
To achiee normali9ation, releant attri"utes of employee, employer loo!up, state loo!up, county loo!up
and city loo!up ta"les should "e grouped and created.
In order to alidate the data of employee ta"le, employee ta"le has "een connected to state, county,
and city loo!ups. -heneer state, county, city data is entered in employee ta"le, data would "e chec!ed
against respectie loo!up ta"les and correct data is stored. >ence there is no need to carry redundant
data of state, county, city loo!up in employee ta"le.
7ll ta"les are identified "y primary !eys32L4. )o data can "e uni8uely identified from ta"les.
*ecords can "e inserted or updated directly in the respectie loo!up ta"le. 5or example if a state name
changes, then the change will "e updated only in the state loo!up, hence this change will not affect
other ta"les li!e employee.
)ince one employee can wor! in many "ranches at the same time, ta"le EmployeeEmployer/*E5 has
"een created and it resoles many to many relationships.
)ince an employee can "e a manager in many occasions, column Nmanager identifierN has "een added
and "ecomes a foreign !ey to column employee identifier. The Nmanager identifierN column would
contain the same alue as of an employee identifier. )ometimes it may contain null alues also. 5or
example, 2aul <oung is the topmost person and doesn't hae any managers.
7 new column DateTime)tamp has "een added to all ta"les. This column gies the information a"out
the date and time when the row was inserted or updated.
The completed relational data model is shown in 5igure ;.B and the corresponding data are shown in separate
ta"les in the next page.
78ample o# Relational Data Model: *igure $%2
The completed relational data model is shown in 5igure ;.B and the corresponding data stored in data"ase are
shown in separate ta"les "elow.
.tate 0oo;up
)tate (ode )tate 1ame DateTime)tamp
1< 1ew <or! ;$;$?GGB ;;,?@,@; 7M
5% 5lorida ;$;$?GGB ;;,?@,@; 7M
(7 (alifornia ;$;$?GGB ;;,?@,@; 7M
1S 1ew Sersey ;$;$?GGB ;;,?@,@; 7M
(ounty %oo!up
(ounty (ode (ounty 1ame DateTime)tamp
1<)> )hel"y ;$;$?GGB ;;,?@,@; 7M
5%SE Sefferson ;$;$?GGB ;;,?@,@; 7M
(7M& Montgomery ;$;$?GGB ;;,?@,@; 7M
1S>: >udson ;$;$?GGB ;;,?@,@; 7M
City 0oo;up
(ity (ode (ity 1ame DateTime)tamp
1<)>M7 Manhattan ;$;$?GGB ;;,?@,@; 7M
5%SE2( 2anama (ity ;$;$?GGB ;;,?@,@; 7M
(7M&)> )an >ose ;$;$?GGB ;;,?@,@; 7M
1S>:S( Sersey (ity ;$;$?GGB ;;,?@,@; 7M
7mployee
Emp
Id
)tate
(ode
(ounty
(ode
(ity (ode
Manager
Id
Emp 5irst
1ame
Emp %ast
1ame
Emp 5ull
1ame
DateTime)tamp
; 1< 1<)> 1<)>M7 2aul <oung 2aul <oung
;$;$?GGB ;;,?@,@;
7M
? 5% 5%SE 5%SE2( ; (hris Dais (hris Dais
;$;$?GGB ;;,?@,@;
7M
@ (7 (7M& (7M&)> Q;$tdR %ouis Sohnson
%ouis
Sohnson
;$;$?GGB ;;,?@,@;
7M
A 1S 1S>: 1S>:S( ; )am Mathew )am Mathew
;$;$?GGB ;;,?@,@;
7M
B 1< 1<)> 1<)>M7 ; 1ancy *o"inson
1ancy
*o"inson
;$;$?GGB ;;,?@,@;
7M
C 5% 5%SE 5%SE2( ? )heela )hellum
)heela
)hellum
;$;$?GGB ;;,?@,@;
7M
D (7 (7M& (7M&)> @ Seff Bill Seff Bill
;$;$?GGB ;;,?@,@;
7M
E 1S 1S>: 1S>:S( A Sohn Burrell Sohn Burrell
;$;$?GGB ;;,?@,@;
7M
7mployer 0oo;up
Employer Id Employer 1ame DateTime)tamp
;GG; 7merican Ban! of 1ew<or! ;$;$?GGB ;;,?@,@; 7M
;GG? 7merican Ban! of 5lorida ;$;$?GGB ;;,?@,@; 7M
;GG@ 7merican Ban! of (alifornia ;$;$?GGB ;;,?@,@; 7M
;GGA
7merican Ban! of 1ew
Sersey
;$;$?GGB ;;,?@,@; 7M
7mployee 7mployer CR7*
Employee Id Employer Id DateTime)tamp
; ;GG; ;$;$?GGB ;;,?@,@; 7M
? ;GG? ;$;$?GGB ;;,?@,@; 7M
@ ;GG@ ;$;$?GGB ;;,?@,@; 7M
A ;GGA ;$;$?GGB ;;,?@,@; 7M
B ;GG; ;$;$?GGB ;;,?@,@; 7M
C ;GG? ;$;$?GGB ;;,?@,@; 7M
D ;GG@ ;$;$?GGB ;;,?@,@; 7M
E ;GGA ;$;$?GGB ;;,?@,@; 7M
Dimensional Data Modeling
Dimensional Data Modeling comprises of one or more dimension ta"les and fact ta"les. =ood examples of
dimensions are location, product, time, promotion, organi9ation etc. Dimension ta"les store records related to
that particular dimension and no facts3measures4 are stored in these ta"les.
5or example, 2roduct dimension ta"le will store information a"out products32roduct (ategory, 2roduct )u"
(ategory, 2roduct and 2roduct 5eatures4 and location dimension ta"le will store information a"out
location3 country, state, county, city, 9ip. 7 fact3measure4 ta"le contains measures3sales gross alue, total units
sold4 and dimension columns. These dimension columns are actually foreign !eys from the respectie dimension
ta"les.
78ample o# Dimensional Data Model: *igure $%A
In the example figure ;.C, sales fact ta"le is connected to dimensions location, product, time and organi9ation. It
shows that data can "e sliced across all dimensions and again it is possi"le for the data to "e aggregated across
multiple dimensions. N)ales DollarN in sales fact ta"le can "e calculated across all dimensions independently or in
a com"ined manner which is explained "elow.
)ales Dollar alue for a particular product
)ales Dollar alue for a product in a location
)ales Dollar alue for a product in a year within a location
)ales Dollar alue for a product in a year within a location sold or sericed "y an employee
In Dimensional data modeling, hierarchies for the dimensions are stored in the dimensional ta"le itself. 5or
example, the location dimension will hae all of its hierarchies from country, state, county to city. There is no need
for the indiidual hierarchical loo!up li!e country loo!up, state loo!up, county loo!up and city loo!up to "e shown
in the model.
>ses o# Dimensional Data Modeling
Dimensional Data Modeling is used for calculating summari9ed data. 5or example, sales data could "e collected
on a daily "asis and then "e aggregated to the wee! leel, the wee! data could "e aggregated to the month
leel, and so on. The data can then "e referred to as aggregate data. 7ggregation is synonymous with
summari9ation, and aggregate data is synonymous with summary data. The performance of dimensional data
modeling can "e significantly increased when materiali9ed iews are used. Materiali9ed iew is a pre-computed
ta"le comprising aggregated or #oined data from fact and possi"ly dimension ta"les which also !nown as a
summary or aggregate ta"le.
-hen a data modeler wor!s with the client, his title may "e a logical data modeler or a physical data modeler or
com"ination of "oth. 7 logical data modeler designs the data model to suit "usiness re8uirements, creates and
maintains the loo!up data, compares the ersions of data model, maintains change log, generate reports from
data model and whereas a physical data modeler has to !now a"out the source and target data"ases properties.
7 physical data modeler should !now the technical-!now-how to create data models from existing data"ases and
to tune the data models with referential integrity, alternate !eys, indexes and how to match indexes to )6% code.
It would "e good if the physical data modeler !nows a"out replication, clustering and so on.
The differences "etween a logical data model and physical data model is shown "elow.
0ogical vs Physical Data Modeling
%ogical Data Model 2hysical Data Model
*epresents "usiness information and defines "usiness
rules
*epresents the physical implementation of the model in a
data"ase.
Entity Ta"le
7ttri"ute (olumn
2rimary Ley 2rimary Ley (onstraint
7lternate Ley :ni8ue (onstraint or :ni8ue Index
Inersion Ley Entry 1on :ni8ue Index
*ule (hec! (onstraint, Default +alue
*elationship 5oreign Ley
Definition (omment
*elational Data Modeling is used in &%T2 systems which are transaction oriented and Dimensional Data
Modeling is used in &%72 systems which are analytically "ased. In a data warehouse enironment, staging area
is designed on &%T2 concepts, since data has to "e normali9ed, cleansed and profiled "efore loaded into a data
warehouse or data mart. In &%T2 enironment, loo!ups are stored as independent ta"les in detail whereas these
independent ta"les are merged as a single dimension in an &%72 enironment li!e data warehouse.
Relational vs Dimensional
*elational Data Modeling Dimensional Data Modeling
Data is stored in *DBM) Data is stored in *DBM) or Multidimensional data"ases
Ta"les are units of storage (u"es are units of storage
Data is normali9ed and used for &%T2. &ptimi9ed
for &%T2 processing
Data is de-normali9ed and used in data warehouse and data
mart. &ptimi9ed for &%72
)eeral ta"les and chains of relationships among
them
5ew ta"les and fact ta"les are connected to dimensional ta"les
+olatile3seeral updates4 and time ariant 1on olatile and time inariant
)6% is used to manipulate data MD/ is used to manipulate data
Detailed leel of transactional data
)ummary of "ul!y transactional data37ggregates and Measures4
used in "usiness decisions
1ormal *eports :ser friendly, interactie, drag and drop multidimensional &%72
*eports
Compare Data Models and create DD0 scripts
During the deelopment cycle of data model, seeral changes$updates may ta!e place oer time depending upon
the needs and re8uirement of that pro#ect. 7s and when re8uired, different data model ersions will "e created
with little or more changes "etween them. 7t one point of time, one may re8uire to !now the exact differences
"etween different ersions3older ersion and newer ersion4 of data models. Lnowing these will help in assuring
the updates in the newer ersion are correct and staying intact with the needs of the re8uirement. 7lso you can
apply these changes to the underlying data"ase "y creating N7%TE*N scripts. In that case, data modeling tools
can help us to sort out the differences "etween data models.
-ith the help of a data modeling tool you can compare,
"etween two data models
data model with the script
data model with the underlying data"ase
.igni#icance o# comparing data models:
To !now the differences "etween them &r to !now what changes hae "een ta!en place in the latest
ersion.
-hateer differences are there, we can create scripts and the same can "e implemented on the
data"ase.
In this article, we are using Toad software to compare "etween two different data model ersions as well as to
create 7%TE* scripts for data"ase update.
5ote: In Toad Data Modeler )oftware, data models are saed with file extension of .txp.
The following ta"le represents a data model with a file name NDomainM*uleMDefaultM;.txpN in the first stage of a
deelopment of a data model.
(olumn 1ame Data Type
5:%%M17ME 17MEMD&M7I1 11
)T*EETM17ME 17MEMD&M7I1 11
(IT<M17ME 17MEMD&M7I1 11
=E1DE* (har3;4 11
))1 (har3F4 11
*E(&*DMD7TE Date 11
:)E*M17ME 17MEMD&M7I1 11
In the second stage of a deelopment of a data model, you are re8uested to add another column
N(&:1T*<M17ME +7*(>7*? 3@G4 1&T 1:%%4N. 5ollow the guidelines "elow to insert the re8uested column in
the data model using Toad )oftware.
)ae the existing data model NDomainM*uleMDefaultM;.txpN as NDomainM*uleMDefaultM?.txpN.
7dd a column N(&:1T*<M17ME +7*(>7*? 3@G4N and assign 1&T 1:%% to it.
)ae the data model.
The following ta"le represents the data model NDomainM*uleMDefaultM?.txpN created in the second stage of a
deelopment of a data model.
(olumn 1ame Data Type
5:%%M17ME 17MEMD&M7I1 11
)T*EETM17ME 17MEMD&M7I1 11
(IT<M17ME 17MEMD&M7I1 11
=E1DE* (har3;4 11
))1 (har3F4 11
*E(&*DMD7TE Date 11
:)E*M17ME 17MEMD&M7I1 11
(&:1T*<M17ME +archar?3@G4 11
*or comparing the data models:
&pen T&7D Data Modeler.
(lic! menu 5ile$)ync 0 (onert$)ync 0 (onert -i9ard.
7ction, &n the new window that is appearing, clic! the "utton N(ompare Models and =enerate 7lter
*eportN. (lic! next.
)elect %eft )ide, (lic! the "utton Model 5ile NU.txp, U.txl N. )elect NDomainM*uleMDefaultM?.txpN. (lic!
next.
)elect *ight )ide, )imilarly clic! the "utton Model 5ile NU.txp, U.txl N. )elect
NDomainM*uleMDefaultM;.txpN. (lic! next.
)ettings, <ou can select the comparison rules 3Ignore text case, Ignore Model 1ame, *esole
7pplication +aria"les, Ignore empty 2rimary Leys, etc4. (lic! next.
)elect &"#ect Types, <ou hae compare all, compare all without graphics, compare settings "uttons.
(lic! compare all and. (lic! next.
)elect Items, 7 new window appears and you can see that (&:1T*<M17ME doesn't exist in
NDomainM*uleMDefaultM;.txpN.
<ow to generate "lter .cript a#ter comparing the data models
&pen T&7D Data Modeler.
(lic! menu 5ile$)ync 0 (onert$)ync 0 (onert -i9ard.
7ction, &n the new window that is appearing, clic! the "utton N=enerate 7lter )criptN. (lic! next.
5inally, the script generated "y T&7D as follows,
7%TE* T7B%E ND&M7I1M*:%EMDE57:%TN 7DD 3N(&:1T*<M17MEN +archar?3@G4 1&T 1:%%4
<ow to create DD0 .cripts #rom Data Model
&pen the physical data model NDataMModelingM*elationship.txlN.
(lic! menu Model$+erify Model.
7 new window will "e opened.
(hec! the appropriate o"#ects li!e entities, functions, pac!ages, materiali9ed iews, relationship,
synonyms, data types etc which are listed in the new window.
(lic! N+erifyN "utton on the "ottom of the page.
It shows the errors and warning in a data model. If there are no errors and warnings.
(lic! Menu$=enerate DD% )cript.
7 new window will "e opened. It has ta"s li!e what to generate, detail settings, referential integrity,
)elect %ist.
(hec! the appropriate o"#ects li!e directories, editions, entities, functions, #aa, materiali9ed iews,
pac!ages, permissions to o"#ects, procedures, relationships, se8uences, synonyms, user data types,
user groups, iews etc which are listed in the new window.
In the "ottom of the window, you can see "uttons li!e =enerate, )how (ode, )how %og.
o (lic! the "utton '=enerate'. It will sae the DD% scripts in a file under a folder. <ou can
see the location of the file in Nwhat to generate ta"N. Example, (,V:sersVData
ModelingVDocumentsVToad Data ModelerV=enerated)criptsV=enerated.)6%
o If you hae access to the data"ases, then you can directly execute those scripts and
create data"ase o"#ects in data"ase or data"ase schema.
(lic! )how. It will retriee the information from that file N=enerated.s8lN and code is shown "elow.
-- (reate ta"les section -----------------
-- Ta"le DE27*TME1T
(*E7TE T7B%E NDE27*TME1TN3
NDE27*TME1TM1&N Integer 1&T 1:%%,
NDE27*TME1TM17MEN +archar?3@G 4 1&T 1:%%
4
$
-- 7dd !eys for ta"le DE27*TME1T
7%TE* T7B%E NDE27*TME1TN 7DD (&1)T*7I1T NDepartmentM2LN 2*IM7*< LE< 3NDE27*TME1TM1&N4
$
-- Ta"le TIT%E
(*E7TE T7B%E NTIT%EN3
NTIT%EM(&DEN Integer 1&T 1:%%,
NTIT%EMDE)(*I2TI&1N +archar?3@G 4 1&T 1:%%
4
$
-- 7dd !eys for ta"le TIT%E
7%TE* T7B%E NTIT%EN 7DD (&1)T*7I1T NTIT%EM2LN 2*IM7*< LE< 3NTIT%EM(&DEN4
$
-- Ta"le 2*&SE(T
(*E7TE T7B%E N2*&SE(TN3
N2*&SE(TM(&DEN Integer 1&T 1:%%,
N)&5T-7*EM:)EDN +archar?3@G 4 1&T 1:%%
4
$
-- 7dd !eys for ta"le 2*&SE(T
7%TE* T7B%E N2*&SE(TN 7DD (&1)T*7I1T N2*&SE(TM2LN 2*IM7*< LE< 3N2*&SE(TM(&DEN4
$
-- Ta"le EM2%&<EE
(*E7TE T7B%E NEM2%&<EEN3
NEM2%&<EEM1&N Integer 1&T 1:%%,
NDE27*TME1TM1&N Integer 1&T 1:%%,
NTIT%EM(&DEN Integer 1&T 1:%%,
NEM2%&<EEM17MEN +archar?3@G 4 1&T 1:%%,
NM717=E*M1&N Integer
4
$
-- 7dd !eys for ta"le EM2%&<EE
7%TE* T7B%E NEM2%&<EEN 7DD (&1)T*7I1T NEM2%&<EEM2LN 2*IM7*< LE< 3NEM2%&<EEM1&N4
$
-- Ta"le EM2%&<EEM2*&SE(T
(*E7TE T7B%E NEM2%&<EEM2*&SE(TN3
NEM2%&<EEM1&N Integer 1&T 1:%%,
N2*&SE(TM(&DEN Integer 1&T 1:%%
4
$
-- 7dd !eys for ta"le EM2%&<EEM2*&SE(T
7%TE* T7B%E NEM2%&<EEM2*&SE(TN 7DD (&1)T*7I1T NEM2%&<EEM2*&SE(TM5LN 2*IM7*< LE<
3N2*&SE(TM(&DEN,NEM2%&<EEM1&N4
$
-- (reate relationships section -------------------------------------------------
7%TE* T7B%E NEM2%&<EEN 7DD (&1)T*7I1T NEM2%&<EEM5LG;N 5&*EI=1 LE< 3NDE27*TME1TM1&N4
*E5E*E1(E) NDE27*TME1TN 3NDE27*TME1TM1&N4
$
7%TE* T7B%E NEM2%&<EEN 7DD (&1)T*7I1T NEM2%&<EEM5L&?N 5&*EI=1 LE< 3NTIT%EM(&DEN4
*E5E*E1(E) NTIT%EN 3NTIT%EM(&DEN4
$
7%TE* T7B%E NEM2%&<EEM2*&SE(TN 7DD (&1)T*7I1T NEM2%&<EEM2*&SE(TM5LG?N 5&*EI=1 LE<
3N2*&SE(TM(&DEN4 *E5E*E1(E) N2*&SE(TN 3N2*&SE(TM(&DEN4
$
7%TE* T7B%E NEM2%&<EEM2*&SE(TN 7DD (&1)T*7I1T NEM2%&<EEM2*&SE(TM5LG;N 5&*EI=1 LE<
3NEM2%&<EEM1&N4 *E5E*E1(E) NEM2%&<EEN 3NEM2%&<EEM1&N4
$
7%TE* T7B%E NEM2%&<EEN 7DD (&1)T*7I1T NEM2%&<EEM5LG@N 5&*EI=1 LE< 3NM717=E*M1&N4
*E5E*E1(E) NEM2%&<EEN 3NEM2%&<EEM1&N4
$
Reverse 7ngineering:
*eerse Engineering is a process or function to create a logical and physical data model "y extracting
information from an existing data source. <ou may either create a physical data model or logical data model or
com"ination of "oth. Data )ource may "e oracle data "ase or M) )6% )erer or IBM DB? or .s8l files etc.
Example, &racle data"ase may contain o"#ects li!es ta"les, iews, indexes, se8uences, triggers, rules, data
type, owner, constraints li!e primary !eys, foreign !eys, comments etc. <ou can specify the o"#ects that you are
interested to create a model. If you are not interested in triggers, then there is no need for you to chec! that
option.
7ll you hae to !now is how to connect to the data source and whether necessary priileges are allocated to you.
If you do hae any pro"lems, while connecting to the data source, please as! system administrator or data"ase
administrator to resole the issues.
Reasons #or Reverse 7ngineering:
Data "ase may "e present "ut there may "e no data models and hence no logical data model and
physical data model print outs for which pro#ect team may not "e sure a"out the o"#ects3ta"les, index,
constraints etc4 and relationships "etween them in data "ase.
Data Models may "e present "ut it may not "e in sync with data "ase.
-hen you integrate different sources3some sources may not hae data models4 into one data"ase to
create a data warehouse, then you hae to represent these sources as data models 3original 7) I)4.
During discussions within the pro#ect team, it will gie more clarity a"out the original structure 37) I)4
and future 3data warehouse4 data models.
<ou can gie logical data models to the "usiness community 3)ME, Business 7nalysts etc.4 and physical
data models to deelopment community 3deelopers and d"as4
5ote:
<ou can modify$update the reerse engineered model as per your needs. 7lignment of ta"les and relationship on
the wor! place may not "e proper and printing out the models will not "e in a presenta"le format. )o please align
it.
)ources from which data model can "e reerse engineered, &racle, M) )6%, 2ost=re)8l, DB? :DB, M<)6%,
M) 7((E)), )y"ase, xml files, s8l files etc.
The *eerse Engineering wi9ard for each data "ase modeling software may "e different. %earn how to connect to
the data"ases, how to chec! different data"ase o"#ects that you want to reerse engineer and see whether you
can sae these settings.
<ow to create a data model #rom a Data!ase
5or example, if you would li!e to reerse engineer data"ase o"#ect from &racle 2roduction )erer. To connect to
oracle, you will need user name, password, and connection string. Then you hae to chec!$clic! all different
data"ase o"#ects3ta"les, columns, indexes, iews, synonyms etc4 that your are interested to reerse. Try to find
out whether you can sae these settings with a N17MEN 32*&D:(TI&1M&*7(%EM)E*+E*4. The reason is
when you connect to the same data"ase next time, then there is no need for you to chec! all those options once
again and you can use the saed information with the name N2*&D:(TI&1M&*7(%EM)E*+E*N.
<ow to create a data model !y reverse engineering #rom scripts
In the section, we are using the DD% scripts which hae "een created earlier in the page DD% )cripts from Data
Model. =enerated.)6% is the file name that contains DD% scripts which is stored in your hard drie. 1ow we will
explain how to reerse engineer and create data model from the a"oe script.
Reverse 7ngineering: creating a data model #rom DD0 scripts using
Toad Data Modeler:
(lic! 5ile-R*eerse Engineering.(lic! 1ext "utton on the "ottom of the page.
)elect Data )ource, :nder N)elect Data )ourceN, you can see the options NData"ase *EN and NDD%
)cript *EN.
)ince we hae created this .s8l script from Noracle ;;g release ?N data"ase, highlight Noracle ;;g
release ?N and clic! next.
)elect Data 2roider, By default, NDD% script file data proiderN is chosen. (lic! next.
(onnecting,Browse file from your folder and select the file N(,V:sersVData ModelingVDocumentsVToad
Data ModelerV=enerated)criptsV=enerated.)6%N. (lic! next.
)elect Data Migrator, By default, it chooses N*eerse Engineering from oracle ;;g release ? DD% script
of data"aseN. (lic! next.
-hat to reerse, (hec! the "oxes against different o"#ects li!e ta"les, se8uences, triggers etc. (lic!
next
&ptions, (hec! different options li!e chec! constraints, indexes, uni8ue constraints etc. (lic! next
7lias, If you want to use the same !ind of settings in future, then sae your settings, clic! sae and enter
some alias name. (lic! next.
Ta"les, <ou can chec! the ta"les that are re8uired. (lic! Execute.
1ow you can see the created data model with all data"ase o"#ects, relationships, and their properties in the
wor!-space.
Data Warehouse 3 Data Mart
7 data warehouse is a relational$multidimensional data"ase that is designed for 8uery and analysis rather than
transaction processing. 7 data warehouse usually contains historical data that is deried from transaction data. It
separates analysis wor!load from transaction wor!load and ena"les a "usiness to consolidate data from seeral
sources.
In addition to a relational$multidimensional data"ase, a data warehouse enironment often consists of an ET%
solution, an &%72 engine, client analysis tools, and other applications that manage the process of gathering data
and deliering it to "usiness users.
There are three types of data warehouses,
$% 7nterprise Data Warehouse - 7n enterprise data warehouse proides a central data"ase for decision support
throughout the enterprise.
+% OD.,Operational Data .tore- - This has a "road enterprise wide scope, "ut unli!e the real Enterprise data
warehouse, data is refreshed in near real time and used for routine "usiness actiity.
/% Data Mart - Datamart is a su"set of data warehouse and it supports a particular region, "usiness unit or
"usiness function.
Data warehouses and data marts are "uilt on dimensional data modeling where fact ta"les are connected with
dimension ta"les. This is most useful for users to access data since a data"ase can "e isuali9ed as a cu"e of
seeral dimensions. 7 data warehouse proides an opportunity for slicing and dicing that cu"e along each of its
dimensions.
Data Mart:
7 data mart is a su"set of data warehouse that is designed for a particular line of "usiness, such as sales,
mar!eting, or finance. In a dependent data mart, data can "e deried from an enterprise-wide data warehouse. In
an independent data mart, data can "e collected directly from sources.
*igure $%$+ : Data Warehouse and Datamarts
Dimension Ta!le
Dimension ta"le is one that descri"e the "usiness entities of an enterprise, represented as hierarchical,
categorical information such as time, departments, locations, and products. Dimension ta"les are sometimes
called loo!up or reference ta"les.
0ocation Dimension
In a relational data modeling, for normali9ation purposes, country loo!up, state loo!up, county loo!up, and city
loo!ups are not merged as a single ta"le. In a dimensional data modeling3star schema4, these ta"les would "e
merged as a single ta"le called %&(7TI&1 DIME1)I&1 for performance and slicing data re8uirements. This
location dimension helps to compare the sales in one region with another region. -e may see good sales profit in
one region and loss in another region. If it is a loss, the reasons for that may "e a new competitor in that area, or
failure of our mar!eting strategy etc.
78ample o# 0ocation Dimension: *igure $%D
Country 0oo;up
(ountry (ode (ountry 1ame DateTime)tamp
:)7 :nited )tates &f 7merica ;$;$?GGB ;;,?@,@; 7M
.tate 0oo;up
)tate (ode )tate 1ame DateTime)tamp
1< 1ew <or! ;$;$?GGB ;;,?@,@; 7M
5% 5lorida ;$;$?GGB ;;,?@,@; 7M
(7 (alifornia ;$;$?GGB ;;,?@,@; 7M
1S 1ew Sersey ;$;$?GGB ;;,?@,@; 7M
County 0oo;up
(ounty (ode (ounty 1ame DateTime)tamp
1<)> )hel"y ;$;$?GGB ;;,?@,@; 7M
5%SE Sefferson ;$;$?GGB ;;,?@,@; 7M
(7M& Montgomery ;$;$?GGB ;;,?@,@; 7M
1S>: >udson ;$;$?GGB ;;,?@,@; 7M
City 0oo;up
(ity (ode (ity 1ame DateTime)tamp
1<)>M7 Manhattan ;$;$?GGB ;;,?@,@; 7M
5%SE2( 2anama (ity ;$;$?GGB ;;,?@,@; 7M
(7M&)> )an >ose ;$;$?GGB ;;,?@,@; 7M
1S>:S( Sersey (ity ;$;$?GGB ;;,?@,@; 7M
0ocation Dimension
%ocation
Dimension Id
(ountry
1ame
)tate
1ame
(ounty
1ame
(ity
1ame
DateTime
)tamp
; :)7 1ew <or! )hel"y Manhattan ;$;$?GGB ;;,?@,@; 7M
? :)7 5lorida Sefferson 2anama (ity ;$;$?GGB ;;,?@,@; 7M
@ :)7 (alifornia Montgomery )an >ose ;$;$?GGB ;;,?@,@; 7M
A :)7 1ew Sersey >udson Sersey (ity ;$;$?GGB ;;,?@,@; 7M
Product Dimension
In a relational data model, for normali9ation purposes, product category loo!up, product su"-category loo!up,
product loo!up, and and product feature loo!ups are are not merged as a single ta"le. In a dimensional data
modeling3star schema4, these ta"les would "e merged as a single ta"le called 2*&D:(T DIME1)I&1 for
performance and slicing data re8uirements.
78ample o# Product Dimension: *igure $%@
Product Category 0oo;up
2roduct (ategory (ode 2roduct (ategory 1ame DateTime)tamp
; 7pparel ;$;$?GGB ;;,?@,@; 7M
? )hoe ;$;$?GGB ;;,?@,@; 7M
Product .u!)Category 0oo;up
2roduct
)u"-(ategory (ode
2roduct
)u"-(ategory 1ame
DateTime
)tamp
;; )hirt ;$;$?GGB ;;,?@,@; 7M
;? Trouser ;$;$?GGB ;;,?@,@; 7M
;@ (asual ;$;$?GGB ;;,?@,@; 7M
;A 5ormal ;$;$?GGB ;;,?@,@; 7M
Product 0oo;up
2roduct (ode 2roduct 1ame DateTime)tamp
;GG; +an >eusen ;$;$?GGB ;;,?@,@; 7M
;GG? 7rrow ;$;$?GGB ;;,?@,@; 7M
;GG@ 1i!e ;$;$?GGB ;;,?@,@; 7M
;GGA 7didas ;$;$?GGB ;;,?@,@; 7M
Product *eature 0oo;up
2roduct 5eature (ode 2roduct 5eature Description DateTime)tamp
;GGG; +an-M ;$;$?GGB ;;,?@,@; 7M
;GGG? +an-% ;$;$?GGB ;;,?@,@; 7M
;GGG@ 7rr-/% ;$;$?GGB ;;,?@,@; 7M
;GGGA 7rr-//% ;$;$?GGB ;;,?@,@; 7M
;GGGB 1i!e-E ;$;$?GGB ;;,?@,@; 7M
;GGGC 1i!e-F ;$;$?GGB ;;,?@,@; 7M
;GGGD 7didas-;G ;$;$?GGB ;;,?@,@; 7M
;GGGE 7didas-;; ;$;$?GGB ;;,?@,@; 7M
Product Dimension
2roduct
Dimension Id
2roduct (ategory
1ame
2roduct )u"-
(ategory 1ame
2roduct
1ame
2roduct 5eature
Desc
DateTime
)tamp
;GGGG; 7pparel )hirt
+an
>eusen
+an-M
;$;$?GGB
;;,?@,@; 7M
;GGGG? 7pparel )hirt
+an
>eusen
+an-%
;$;$?GGB
;;,?@,@; 7M
;GGGG@ 7pparel )hirt 7rrow 7rr-/%
;$;$?GGB
;;,?@,@; 7M
;GGGGA 7pparel )hirt 7rrow 7rr-//%
;$;$?GGB
;;,?@,@; 7M
;GGGGB )hoe (asual 1i!e 1i!e-E
;$;$?GGB
;;,?@,@; 7M
;GGGGC )hoe (asual 1i!e 1i!e-F
;$;$?GGB
;;,?@,@; 7M
;GGGGD )hoe (asual 7didas 7didas-;G
;$;$?GGB
;;,?@,@; 7M
;GGGGE )hoe (asual 7didas 7didas-;; ;$;$?GGB
;;,?@,@; 7M
Organi4ation Dimension
In a relational data model, for normali9ation purposes, corporate office loo!up, region loo!up, "ranch loo!up, and
employee loo!ups are not merged as a single ta"le. In a dimensional data modeling3star schema4, these ta"les
would "e merged as a single ta"le called &*=71IT7TI&1 DIME1)I&1 for performance and slicing data.
This dimension helps us to find the products sold or sericed within the organi9ation "y the employees. In any
industry, we can calculate the sales on region "asis, "ranch "asis and employee "asis. Based on the
performance, an organi9ation can proide incenties to employees and su"sidies to the "ranches to increase
further sales.
78ample o# Organi4ation Dimension: *igure $%$E
Corporate 0oo;up
(orporate (ode (orporate 1ame DateTime)tamp
(& 7merican Ban! ;$;$?GGB ;;,?@,@; 7M
Region 0oo;up
*egion (ode *egion 1ame DateTime)tamp
)E )outh East ;$;$?GGB ;;,?@,@; 7M
M- Mid -est ;$;$?GGB ;;,?@,@; 7M
'ranch 0oo;up
Branch (ode Branch 1ame DateTime)tamp
5%TM 5lorida-Tampa ;$;$?GGB ;;,?@,@; 7M
I%(> Illinois-(hicago ;$;$?GGB ;;,?@,@; 7M
7mployee 0oo;up
Employee (ode Employee 1ame DateTime)tamp
E; 2aul <oung ;$;$?GGB ;;,?@,@; 7M
E? (hris Dais ;$;$?GGB ;;,?@,@; 7M
Organi4ation Dimension
&rgani9ation Dimension
Id
(orporate
1ame
*egion
1ame
Branch 1ame
Employee
1ame
DateTime
)tamp
; 7merican Ban! )outh East 5lorida-Tampa 2aul <oung
;$;$?GGB ;;,?@,@;
7M
? 7merican Ban! Mid -est
Illinois-
(hicago
(hris Dais
;$;$?GGB ;;,?@,@;
7M
Time Dimension
In a relational data model, for normali9ation purposes, year loo!up, 8uarter loo!up, month loo!up, and wee!
loo!ups are not merged as a single ta"le. In a dimensional data modeling3star schema4, these ta"les would "e
merged as a single ta"le called TIME DIME1)I&1 for performance and slicing data.
This dimensions helps to find the sales done on date, wee!ly, monthly and yearly "asis. -e can hae a trend
analysis "y comparing this year sales with the preious year or this wee! sales with the preious wee!.
78ample o# Time Dimension: *igure $%$$
Fear 0oo;up
<ear Id <ear 1um"er DateTime)tamp
; ?GGA ;$;$?GGB ;;,?@,@; 7M
? ?GGB ;$;$?GGB ;;,?@,@; 7M
Quarter 0oo;up
6uarter 1um"er 6uarter 1ame DateTime)tamp
; 6; ;$;$?GGB ;;,?@,@; 7M
? 6? ;$;$?GGB ;;,?@,@; 7M
@ 6@ ;$;$?GGB ;;,?@,@; 7M
A 6A ;$;$?GGB ;;,?@,@; 7M
Month 0oo;up
Month 1um"er Month 1ame DateTime)tamp
; Sanuary ;$;$?GGB ;;,?@,@; 7M
? 5e"ruary ;$;$?GGB ;;,?@,@; 7M
@ March ;$;$?GGB ;;,?@,@; 7M
A 7pril ;$;$?GGB ;;,?@,@; 7M
B May ;$;$?GGB ;;,?@,@; 7M
C Sune ;$;$?GGB ;;,?@,@; 7M
D Suly ;$;$?GGB ;;,?@,@; 7M
E 7ugust ;$;$?GGB ;;,?@,@; 7M
F )eptem"er ;$;$?GGB ;;,?@,@; 7M
;G &cto"er ;$;$?GGB ;;,?@,@; 7M
;; 1oem"er ;$;$?GGB ;;,?@,@; 7M
;? Decem"er ;$;$?GGB ;;,?@,@; 7M
Wee; 0oo;up
-ee! 1um"er Day of -ee! DateTime)tamp
; )unday ;$;$?GGB ;;,?@,@; 7M
; Monday ;$;$?GGB ;;,?@,@; 7M
; Tuesday ;$;$?GGB ;;,?@,@; 7M
; -ednesday ;$;$?GGB ;;,?@,@; 7M
; Thursday ;$;$?GGB ;;,?@,@; 7M
; 5riday ;$;$?GGB ;;,?@,@; 7M
; )aturday ;$;$?GGB ;;,?@,@; 7M
? )unday ;$;$?GGB ;;,?@,@; 7M
? Monday ;$;$?GGB ;;,?@,@; 7M
? Tuesday ;$;$?GGB ;;,?@,@; 7M
? -ednesday ;$;$?GGB ;;,?@,@; 7M
? Thursday ;$;$?GGB ;;,?@,@; 7M
? 5riday ;$;$?GGB ;;,?@,@; 7M
? )aturday ;$;$?GGB ;;,?@,@; 7M
Time Dimension
Time
Dim Id
<ear
1o
Day &f
<ear
6uarter
1o
Month
1o
Month
1ame
Month
Day 1o
-ee!
1o
Day of
-ee!
(al Date
DateTime
)tamp
; ?GGA ; 6; ; Sanuary ; ; B ;$;$?GGA
;$;$?GGB
;;,?@,@; 7M
? ?GGA @? 6; ? 5e"ruary ; B ; ?$;$?GGA
;$;$?GGB
;;,?@,@; 7M
@ ?GGB ; 6; ; Sanuary ; ; D ;$;$?GGB
;$;$?GGB
;;,?@,@; 7M
A ?GGB @? 6; ? 5e"ruary ; B @ ?$;$?GGB
;$;$?GGB
;;,?@,@; 7M
.lowly Changing Dimensions
Dimensions that change oer time are called )lowly (hanging Dimensions. 5or instance, a product price
changes oer timeI 2eople change their names for some reasonI (ountry and )tate names may change oer
time. These are a few examples of )lowly (hanging Dimensions since some changes are happening to them
oer a period of time.
)lowly (hanging Dimensions are often categori9ed into three types namely Type$, Type+ and Type/. The
following section deals with how to capture and handling these changes oer time.
The N2roductN ta"le mentioned "elow contains a product named, 2roduct; with 2roduct ID "eing the primary !ey.
In the year ?GGA, the price of 2roduct; was W;BG and oer the time, 2roduct;'s price changes from W;BG to W@BG.
-ith this information, let us explain the three types of )lowly (hanging Dimensions.
Product Price in +EE1:
2roduct ID32L4 <ear 2roduct 1ame 2roduct 2rice
; ?GGA 2roduct; W;BG
Type $: &erwriting the old alues.
In the year ?GGB, if the price of the product changes to W?BG, then the old alues of the columns N<earN and
N2roduct 2riceN hae to "e updated and replaced with the new alues. In this Type ;, there is no way to find out
the old alue of the product N2roduct;N in year ?GGA since the ta"le now contains only the new price and year
information.
Product
2roduct ID32L4 <ear 2roduct 1ame 2roduct 2rice
; ?GGB 2roduct; W?BG
Type +: (reating an another additional record.
In this Type ?, the old alues will not "e replaced "ut a new row containing the new alues will "e added to the
product ta"le. )o at any point of time, the difference "etween the old alues and new alues can "e retrieed and
easily "e compared. This would "e ery useful for reporting purposes.
Product
2roduct ID32L4 <ear 2roduct 1ame 2roduct 2rice
; ?GGA 2roduct; W;BG
; ?GGB 2roduct; W?BG
The pro"lem with the a"oe mentioned data structure is N2roduct IDN cannot store duplicate alues of 2roduct;
since N2roduct IDN is the primary !ey. 7lso, the current data structure doesn't clearly specify the effectie date and
expiry date of 2roduct; li!e when the change to its price happened. )o, it would "e "etter to change the current
data structure to oercome the a"oe primary !ey iolation.
Product
2roduct ID32L4
Effectie
DateTime32L4
<ear 2roduct 1ame 2roduct 2rice
Expiry
DateTime
; G;-G;-?GGA ;?.GG7M ?GGA 2roduct; W;BG ;?-@;-?GGA ;;.BF2M
; G;-G;-?GGB ;?.GG7M ?GGB 2roduct; W?BG
In the changed 2roduct ta"le's Data structure, N2roduct IDN and NEffectie DateTimeN are composite primary
!eys. )o there would "e no iolation of primary !ey constraint. 7ddition of new columns, NEffectie DateTimeN and
NExpiry DateTimeN proides the information a"out the product's effectie date and expiry date which adds more
clarity and enhances the scope of this ta"le. Type? approach may need additional space in the data "ase, since
for eery changed record, an additional row has to "e stored. )ince dimensions are not that "ig in the real world,
additional space is negligi"le.
Type /: (reating new fields.
In this Type @, the latest update to the changed alues can "e seen. Example mentioned "elow illustrates how to
add new columns and !eep trac! of the changes. 5rom that, we are a"le to see the current price and the
preious price of the product, 2roduct;.
Product
2roduct ID32L4
(urrent
<ear
2roduct
1ame
(urrent
2roduct 2rice
&ld 2roduct
2rice
&ld <ear
; ?GGB 2roduct; W?BG W;BG ?GGA
The pro"lem with the Type @ approach, is oer years, if the product price continuously changes, then the
complete history may not "e stored, only the latest change will "e stored. 5or example, in year ?GGC, if the
product;'s price changes to W@BG, then we would not "e a"le to see the complete history of ?GGA prices, since
the old alues would hae "een updated with ?GGB product information.
Product
2roduct ID32L4 <ear
2roduct
1ame
2roduct
2rice
&ld 2roduct
2rice
&ld <ear
; ?GGC 2roduct; W@BG W?BG ?GGB
.tar .chema: &eneral In#ormation
In general, an organi9ation is started to earn money "y selling a product or "y proiding serice to the product.
7n organi9ation may "e at one place or may hae seeral "ranches.
-hen we consider an example of an organi9ation selling products throughout the world, the main four ma#or
dimensions are product, location, time and organi9ation. Dimension ta"les hae "een explained in detail under
the section Dimensions. -ith this example, we will try to proide detailed explanation a"out )T7* )(>EM7.
What is .tar .chema
)tar )chema is a relational data"ase schema for representing multidimensional data. It is the simplest form of
data warehouse schema that contains one or more dimensions and fact ta"les. It is called a star schema
"ecause the entity-relationship diagram "etween dimensions and fact ta"les resem"les a star where one fact
ta"le is connected to multiple dimensions. The center of the star schema consists of a large fact ta"le and it
points towards the dimension ta"les. The adantage of star schema are slicing down, performance increase and
easy understanding of data.
.teps in designing .tar .chema:
Identify a "usiness process for analysis3li!e sales4.
Identify measures or facts 3sales dollar4.
Identify dimensions for facts3product dimension, location dimension, time dimension, organi9ation
dimension4.
%ist the columns that descri"e each dimension.3region name, "ranch name, region name4.
Determine the lowest leel of summary in a fact ta"le3sales dollar4.
Important aspects o# .tar .chema 3 .now *la;e .chema:
In a star schema eery dimension will hae a primary !ey.
In a star schema, a dimension ta"le will not hae any parent ta"le.
-hereas in a snow fla!e schema, a dimension ta"le will hae one or more parent ta"les.
>ierarchies for the dimensions are stored in the dimensional ta"le itself in star schema.
-hereas hierarchies are "ro!en into separate ta"les in snow fla!e schema. These hierarchies helps to
drill down the data from topmost hierarchies to the lowermost hierarchies.
&lossary:
<ierarchy
7 logical structure that uses ordered leels as a means of organi9ing data. 7 hierarchy can "e used to define data
aggregationI for example, in a time dimension, a hierarchy might "e used to aggregate data from the Month leel
to the 6uarter leel, from the 6uarter leel to the <ear leel. 7 hierarchy can also "e used to define a naigational
drill path, regardless of whether the leels in the hierarchy represent aggregated totals or not.
0evel
7 position in a hierarchy. 5or example, a time dimension might hae a hierarchy that represents data at the
Month, 6uarter, and <ear leels.
*act Ta!le
7 ta"le in a star schema that contains facts and connected to dimensions. 7 fact ta"le typically has two types of
columns, those that contain facts and those that are foreign !eys to dimension ta"les. The primary !ey of a fact
ta"le is usually a composite !ey that is made up of all of its foreign !eys.
7 fact ta"le might contain either detail leel facts or facts that hae "een aggregated 3fact ta"les that contain
aggregated facts are often instead called summary ta"les4. 7 fact ta"le usually contains facts with the same leel
of aggregation.
Example of )tar )chema, 5igure ;.C
In the example figure ;.C, sales fact ta"le is connected to dimensions location, product, time and organi9ation. It
shows that data can "e sliced across all dimensions and again it is possi"le for the data to "e aggregated across
multiple dimensions. N)ales DollarN in sales fact ta"le can "e calculated across all dimensions independently or in
a com"ined manner which is explained "elow.
)ales Dollar alue for a particular product
)ales Dollar alue for a product in a location
)ales Dollar alue for a product in a year within a location
)ales Dollar alue for a product in a year within a location sold or sericed "y an employee
.now#la;e .chema
7 snowfla!e schema is a term that descri"es a star schema structure normali9ed through the use of outrigger
ta"les. i.e dimension ta"le hierarchies are "ro!en into simpler ta"les. In star schema example we had A
dimensions li!e location, product, time, organi9ation and a fact ta"le3sales4.
In )nowfla!e schema, the example diagram shown "elow has A dimension ta"les, A loo!up ta"les and ; fact
ta"le. The reason is that hierarchies3category, "ranch, state, and month4 are "eing "ro!en out of the dimension
ta"les32*&D:(T, &*=71IT7TI&1, %&(7TI&1, and TIME4 respectiely and shown separately. In &%72, this
)nowfla!e schema approach increases the num"er of #oins and poor performance in retrieal of data. In few
organi9ations, they try to normali9e the dimension ta"les to sae space. )ince dimension ta"les hold less space,
)nowfla!e schema approach may "e aoided.
Example of )nowfla!e )chema, 5igure ;.D
*act Ta!le
The centrali9ed ta"le in a star schema is called as 57(T ta"le. 7 fact ta"le typically has two types of columns,
those that contain facts and those that are foreign !eys to dimension ta"les. The primary !ey of a fact ta"le is
usually a composite !ey that is made up of all of its foreign !eys.
In the example fig ;.C N)ales DollarN is a fact3measure4 and it can "e added across seeral dimensions. 5act
ta"les store different types of measures li!e additie, non additie and semi additie measures.
Measure Types
7dditie - Measures that can "e added across all dimensions.
1on 7dditie - Measures that cannot "e added across all dimensions.
)emi 7dditie - Measures that can "e added across few dimensions and not with others.
7 fact ta"le might contain either detail leel facts or facts that hae "een aggregated 3fact ta"les that contain
aggregated facts are often instead called summary ta"les4.
In the real world, it is possi"le to hae a fact ta"le that contains no measures or facts. These ta"les are called
as *actless *act ta"les.
.teps in designing *act Ta!le
Identify a "usiness process for analysis3li!e sales4.
Identify measures or facts 3sales dollar4.
Identify dimensions for facts3product dimension, location dimension, time dimension, organi9ation
dimension4.
%ist the columns that descri"e each dimension.3region name, "ranch name, region name4.
Determine the lowest leel of summary in a fact ta"le3sales dollar4.
78ample o# a *act Ta!le with an "dditive Measure in .tar .chema: *igure $%A
In the example figure ;.C, sales fact ta"le is connected to dimensions location, product, time and organi9ation.
Measure N)ales DollarN in sales fact ta"le can "e added across all dimensions independently or in a com"ined
manner which is explained "elow.
)ales Dollar alue for a particular product
)ales Dollar alue for a product in a location
)ales Dollar alue for a product in a year within a location
)ales Dollar alue for a product in a year within a location sold or sericed "y an employee
Data Modeling Interview Questions:
&eneral Questions:
H >ae you exported o"#ects from the data model to different data"ase. -hat is the use of it.
H -hat is aggregated data and why do you need aggregated data.
H -hat is the role of a logical data modeler and physical data modeler.
H >ow do you gather re8uirements for creating data model.
H -hat is the naming conention you follow.
H -hat are the different notations that can "e used.
H -hat is (ardinality.
H -hat is identifying and non identifying relationship.
H -hy do you need phrases in a data model.
H >ae you generated reports for data models. -hy do you need reports from data model.
H >ow you will recoer if data modeling file is corrupted.
H -hat is Meta data. -hat !ind of Meta data do you capture in a data model.
H Explain a difficult situation in data modeling and how did you resole it.
0ogical Data Modeling Questions:
H -hat is logical data modeling.
H -hat is conceptual data modeling. -hy do you need that.
H -hat is enterprise data modeling. -hy do you need that.
H -hat is relational data modeling. -hen you will use relational data modeling.
H -hen you will go for relational data modeling.
H -hat is &%T2.
H -hat is &%72 data modeling.
H -hat is dimensional data modeling.
H -hat is a dimension.
H -hat is a slowly changing dimension. -hat are the types of slowly changing dimension. -hich one you will
use it.
H -hat is super type and su" type. -here you will use in logical or physical data model. If you generate the
super type
and su" type structure it in a data"ase, what are the conse8uences.
H -hat is )tar )chema. -hen you use )tar )chema.
H -hat is )now 5la!e. -hen you will use )now 5la!e )chema.
H -hat is the difference "etween )now 5la!e and )tar )chema.
H (an you compare logical data model with data "ase. >ow.
H >ow you will find out the difference "etween the logical data models created preious month and current
month.
H -hat is Data -are >ouse.
H -hat is Data Mart.
H -hat is the difference "etween data ware house and data mart.
Physical Data Modeling Questions:
H -hat is physical data modeling.
H -hat is the difference "etween logical and physical data modeling.
H (an you compare physical data model with data "ase. >ow.
H >ow ersion controlling is done in a data model.
Data!ase Overview:
7 data"ase is a collection of organi9ed and structured data, stored in the computer as files. +arious data types
li!e numeric, textual, image, multimedia etc., can "e managed and maintained more efficiently in a data"ase.
Data!ase Types:
Data"ase Management )ystems 3DBM)4
*elational Data"ase Management )ystems 3*DBM)4
&"#ect &riented Data"ases
Multidimensional Data"ases
&ften used data"ases 3*DBM)4 in most of the practical applications are &racle, )8l )erer, Informix, Terradata,
DB? etc., and in the following pages, &racleJs data structures are used as examples to explain the relationship
"etween data modelling and data"ase. In order to design a data model in a proper manner, a data modeler has
to !now the different o"#ects 3data structures4 present in a data"ase. 7lso data modeler should hae a sound
!nowledge of the data present$to "e present in the data"ase, should "e a"le to design a data model using a data
modelling tool li!e Erwin, and to generate DD% scripts from the Data Modelling tool.
=ien "elow is the list of &racle data o"#ects and in the following pages, a "rief oeriew is gien for each of
these o"#ects.
Oracle Data!ase O!9ects:
Instance
)chema
Ta"le
(olumn
Datatype
2rimary Ley (onstraint
:ni8ue (onstraint
(hec! (onstraint
1ull
1ot 1ull
Index
)e8uence
+iew
Materiali9ed +iew
)ynonym
2rocedure
5unction
2ac!age
Trigger
Ccase ) Overview:
Ccase is a powerful and intuitie data modeling tool. It automates data"ase creation and maintenance, ma!ing
the modeling process simple and isual. The tool proides tight support for the leading DBM) and an impressie
set of capa"ilities.
:sing /case, data modelers can create data models from scratch or from existing data"ases using the Reverse
7ngineering module. &nce the model is complete, /case *orward 7ngineering module generates all the DD%
scripts necessary to create a new data"ase or update an existing one.
>sing Ccase: you can:
H Create Pro#essional Data Models from scratch
H Reverse 7ngineer existing data"ase structures
H ?iew and organi4e the data"ase structure at different leels of depth
H Communicate effectiely with clients and colleagues
H *ully control data"ase Metadata within the model and add user defined attri"utes for each o"#ect
H Manage di##erent versions of your model$data"ase using the adanced ?ersion Control module - compare a
model to the actual data"ase, to another model or to a preious ersion of the same model and generate a
detailed report of all discrepancies found.
H .ynchroni4e your model with the data"ase using the +)way synchroni9ation feature. /case proides a
detailed report on discrepancies found "etween the model and the data"ase and allows you to update the model
"ased on the actual data"ase structure or update the data"ase "ased on your model
H "utomatically generate all the code necessary to create and maintain the data"ase without #eopardi9ing
existing data
H ?alidate the data in the data"ase against the "usiness rules defined in the model
H "ccess and edit the data relationally using automatic parent$child "rowsers and loo!ups
H Migrate the data"ase metadata and data from one DBM) to another
5or more information, see the Ccase data modeling we! page.
?isio
+isio, can "e used to design complex E* diagrams and it comes in three different editions 3i.e4
+isio )tandard ?GG@, +isio 2rofessional ?GG@, and +isual )tudio .1ET ?GG@ Enterprise 7rchitect.
These editions hae different commands associated with data modeling and for differences and
features "etween these editions, please isit www.microsoft.com.
?isio 3 Data Models
Create a database model or ER diagram from scratch.
Import a database or ER model from another modeling diagram.
Import Erwin ERX file.
Import Visio Modeler .IMQ file.
Create a database model or ER diagram: You can create tables columns foreign !e" relationships
data t"pes inde#es $iews e#tended properties for tables $iews chec! clauses stored procedures
and triggers.
Re$erse engineer an e#isting database: %" using alread" installed Visio dri$ers "ou can connect to
I%M &%' (ni$ersal &atabase Informi# )nline*+E +er$er Microsoft ,ccess Microsoft +Q-
+er$er )&%C .eneric &ri$er )racle +er$er +"base ,dapti$e +er$er Enterprise etc.
/orward engineer an e#isting database.
Create a Data Model using ?isio
5ollow these simple steps to create a data model with two entities.
;. &pen +isio software.
?. &n the left hand side, under (hoose Drawing )elect Type, clic! the category NData"aseN.
(lic! the template NData"ase Model DiagramN.
@. 7lternate way of opening is to go to N5ileN menu. (lic! 1ew and then clic! N(hoose
drawing typeN. &ut of the seeral options displayed, clic! NData"ase Model DiagramN.
A. This will ta!e you to a wor!place where data model will "e created. This wor!place has
got different panes. &n the left hand side, you can see the different icons for creating
entity, relationship, iew etc. The grid is the place where you are going to drag and drop
these icons to create the data model.
B. Below that, in NData"ase 2ropertiesN ta", you can see the categories for creating Ta"les,
(olumns, 2rimary ID), Indexes, Triggers, (hec!, Extended 1otes etc. If you don't see
the Data"ase 2roperties ta" then, dou"le clic! on the ta"le. This will open the Data"ase
2roperties window. Drag that window in such a way that it positions itself at the "ottom of
the grid.
C. To create a Ta!le, clic! the icon 'Entity' and drop it on the wor!place. :nder (ategory,
place the cursor on the category 'Definition'. (hange$Type the conceptual name3logical
name4 and physical name3ta"le name4 as '(&:1T*<'. 7s per your "usiness
re8uirements, you can enter metadata in name space, owner, source data"ase and
defining type.
D. To create a Column, place the cursor on the category N(olumnsN. Type column name as
N(&:1T*<M(&DEN. )elect the data type or type your datatype as +7*(>7*3;G4.
)elect the option Primary =ey to identify attri"ute N(&:1T*<M(&DEN as the primary
!ey. If you want to edit the column or need to add more properties to the column, place
the cursor on the column '(&:1T*<M(&DE'. (lic! edit and you can edit or add more
properties li!e definition, datatype, collection, extended, chec!, extended, notes.
E. 5ollow the same approach to create another column N(&:1T*<M17MEN. Type datatype
as +7*(>7*?3BG4, chec! N*e8uiredN option and do not select the primary !ey option.
1ow you will "e haing two columns (&:1T*<M(&DE, and (&:1T*<M17ME under
the ta"le N(&:1T*<N on the grid.
F. (reate another ta"le NB71LN with two columns namely B71LM(&DE and B71LM17ME
"y following steps B through D.
;G. In order to relate these two ta"les3(&:1T*< 0 B71L4, a *oreign =ey relationship must
"e created. To create a 5oreign Ley relationship, follow these steps.
;;. Drag the N*elationshipN icon and drop it on B71LM(&DE column. 1ow you can see the
relationship i.e a line drawn from Ban!. 1ow drag that arrow until you drop it on the
(&:1T*<M(&DE column of (&:1T*< ta"le. -hen you did that, you can see a new
column N(&:1T*<M(&DEN in B71L ta"le, that has "een inherited from (&:1T*<
ta"le.
;?. 2lace the cursor on the relationship and you can edit the data"ase properties of that
relationship.
;@. <ou can gie a name, change the cardinality, identifying and non-identifying relationship,
etc.
;A. 1ow the data model is ready and if you hae a higher ersion of +isio, then you can
forward engineer the data model to create DD% scripts for creating a data"ase.

Anda mungkin juga menyukai