Dimensional Modeling By Sathish Yellanki

38
Friday, April 22, 2022 Introduction To DWH by Satish Kumar Yellanki Slide No 1 Let us Start With CA-Erwin

description

Dimensional Modeling Presentation

Transcript of Dimensional Modeling By Sathish Yellanki

Page 1: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 1

Let us Start With CA-Erwin

Page 2: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 2

• Erwin Supports A Variety of Aspects of Database Design, Including Data Modeling.

• Erwin Supports Data Modeling in Two FlavorsForward EngineeringThe Creation of A Database Schema And Physical Database on The Basis of A Data Model.Reverse EngineeringThe Creation of A Data Model on The Basis of An Existing Database.

• Erwin Supports Data Modeling For A Wide Variety of Relational DBMS Software.

Main Areas of Erwin Workplace Logical• In This View, Data Model Represents Business

Requirements Like Entities, Attributes Etc.Physical• In This View, Data Model Represents Physical Structures

Like Tables, Columns, Data Types Etc.Modelmart• Many Users Can Work With A Same Data Model

Concurrently.

Page 3: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 3

What Can Be Done With Erwin?• Logical, Physical And Dimensional Data Models Can Be

Created.• Data Models Can Be Created From Existing Systems Like

RDBMS, DBMS, Script Files.• Different Versions of A Data Model Can Be Compared.• Data Model And Database Can Be Compared.• SQL Scripts Can Be Generated To Create Databases From

Data Model.• Reports Can Be Generated in Different File Formats. • By Using Modelmart, Concurrent Users Can Work on The

Same Data Model.Starting CA-Erwin• Start Programs Computer Associates All Fusion

Erwin Data Modeler Erwin Data Modeler.Step1 Creation of A Basic Data Model• Click The Create New Button OR File New OR CTRL +

N.• In The Create Model Dialog Box Select Logical/Physical

Option, And Any Template if Available.• Select The Target Database As Oracle And Version As

10.x And Click OK.

Page 4: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 4

Screen Shot 1 : Create Model – Select Template

• The Logical Model Does Not Allow The Target Database Selection.• The Physical Model Provides A List of Different Databases That Are

Supported By Erwin.• We Can Select Predefined Templates By Browsing The System if

Available.

Page 5: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 5

Screen Shot 2 : Main Window

• The Erwin Workplace Consists of Two Main Parts.  • The Model Navigator It Displays A Hierarchy of Items.• The Display Window It Will Show The ER Diagram Itself.  

Display Window

Action Log Window Advisories Window

Tool Bars

Mod

el

Navig

ato

r

Page 6: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 6

Setting Preferences • Erwin Accommodates A Number of Data Modeling

Notations And Conventions.• To Set The Preferences, Click Model Model Properties

 

Screen Shot 3 : Model Properties Window

Few Options That Are Very Regular For Setting…• From The Format Entity Display Menu, Make Sure That

Primary Key Designator is Checked

Page 7: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 7

• From The Format Entity Display Menu, Make Sure That Foreign Key Designator (FK) is Unchecked.

• From The Format Entity Display Menu, Make Sure That Show Migrated Attributes is Unchecked.

• From The Format relationship Display, Make Sure That Verb Phrase is Checked.

• We Can Choose Between Two Different ER Diagramming Notations From The Model Properties Window• Information Engineering Notation (IE)• Integration DEFinition For Information Modeling

IDEF1X.• Erwin Also Provides The Dimensional Modeling Notation.Steps To Create an Entity • To Create A New Entity, Click on The Entity Icon on The

Erwin Toolbar And Click in The Display Area, OR Right-Click on The Entities Node in The Model Navigator.

New Entity Button

New Entity Creation

Page 8: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 8

• Notice That The Default Name For The New Entity is E/x, Where ‘x’ is Sequence Number of The Entity.

• Select The Entity in The Display Area And Click on The Tab Key To Focus The Cycle Between The Three Main Parts of The Entity…• The Name of The Entity• The Primary Key Attribute(s)• The Non-Primary Key Attribute(s).

• To Modify One of These Three Parts of The Entity, We Have To Press The Tab Key To Cycle To The Appropriate Part of The Entity, Then Type To Add OR Modify That Part of The Entity.

Steps To Add Primary Key Columns• Once The Entity Name is Changed, Then Press The Tab

Key Again To Move The Focus To The Next Part of The Entity, To Add A Primary Key Attribute.

• Type The Name of The Primary Key Attribute As Per The Requirement of The System Being Designed.

• To Add Multiple Columns For A Primary Key, To Recognize As A Composite Primary Key State, Press Enter Key After Adding The First Column For Primary Key.

Page 9: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 9

Steps To Add Non Key Attributes• Press The Tab Key After Adding The Primary Key

Attribute, Which Will Help To Add A Number of Non-Primary Key Attributes.  

• After Adding The Required Non-Primary Key Attribute Press The Enter Key, To Add The Remaining Non Key Attributes.

System For DesignEntity Attributes

Employee

Emp_Num (PK)Emp_FnameEmp_LnameEmp_SSNEmp_StreetEmp_CityEmp_StateEmp_ZipcodeEmp_Phone

Emp_Fax

Entity Attributes

Office

Office_Num (PK)Office_StreetOffice_CityOffice_StateOffice_ZipcodeOffice_NameOffice_PhoneOffice_Fax

Entity Attributes

Property

Prop_ID (PK)Prop_StreetProp_CityProp_StateProp_ZipCodeProp_TypeProp_BathsProp_RoomsProp_MonthlyRent

Entity Attributes

InspectionInsp_Date (PK)Insp_CommentsEntity Attributes

Manager

Man_SalaryMan_Car_Allowance

Entity Attributes

Associate

Assoc_Hourly_Rate

Page 10: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 10

Screen Shot 4 : First Level Model Entities

Page 11: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 11

Creating Relationships in Erwin• Erwin Supports Three Basic Kinds of Relationship Types

• Identifying Relationship.• Non-Identifying Relationship.• Many-To-Many Relationship.

• Erwin Supports Three Basic Kinds of Cardinality Types• One-To-One• One-To-Many• Many-To-Many

• Within The One-To-Many Category, Erwin Allows To Distinguish Between Identifying And Non-Identifying One-To-Many Relationships.

Identifying Relationship• An Identifying Relationship is A Relationship Between

Two Entities in Which An Instance of A Child Entity is Identified Through its Association With A Parent Entity.

• In Identifying Relationship The Child Entity is Dependent on The Parent Entity For its Identity And Cannot Exist Without The Parent Entity.

• In An Identifying Relationship, One Instance of The Parent Entity is Related To Multiple Instances of The Child.

Page 12: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 12

Screen Shot 5 : First Level Model Relationships

Page 13: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 13

Notation Style in ErwinIDEF1X Notation• A Solid Line With A Diamond OR A Filled Circle At Either

End of The Line. IE Notation• A Solid Line With Crows Feet.     Steps To Create Identifying Relationship• To Create An Identifying Relationship, Click First on The

Identifying Relationship Icon. • Click on The Parent Entity, Generally on The One Side of

The Relationship Entity And Then Click on The Child Entity on The Many Side of The Relationship Entity.

Note • Erwin Provides A Label "R/x" For Every Relationship That

is Created.• This Default Label Can Be Changed As Per Our

Requirement in A Meaningful Way.Defining Customized Labels For Relationships• Double-Click on The Relationship To Open The

Relationship Dialog Box.• The Relationship Dialog Box Has Features To Refine The

Properties of The Relationship.

Page 14: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 14

Screen Shot 6 : Refining Relationships Dialog Box

• In The Relationship Text Box The Relationship is Presented From Parent Entity R/1 Child Entity.  

• The Verb Phrase Portion of This Box Allows To Define The Label To Place on The Relationship in Place of R/1.  

Page 15: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 15

• In The Relationship Cardinality Portion, We Can Determine How Many Child Entity Occurrences May Be Associated With Each Parent Entity Occurrence.  

• We Can Define Participation As Mandatory OR Optional in The Database.

Note• When An Entity Participates As The Child in An

Identifying Relationship it is Modeled With Rounded Corners.  

• This Notation is Useful To Understand The “Weak Entity” Concept in RDBMS.  

Creating Non-Identifying Relationship• Click on The Non-Identifying Relationship Icon Which

Uses A Dashed Line Instead of A Solid Line. • Click On The Parent Entity, Then The Child Entity.• In Non-Identifying Relationship Type, We Have The

Option of Indicating Whether NULLS Are Permitted OR Not.

• This Decision Regards The Participation of The Parent Entity in A Relationship With The Child Entity.

• We Have A Choice of Mandatory OR Optional State in Non-Identifying Relationship.

Page 16: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 16

Screen Shot 7 : Second Level Model Relationships

Page 17: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 17

Screen Shot 8 : Third Level Model Relationships

Page 18: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 18

Creating Subtypes And Supertypes • Some Entities May Have Sub-Category Classifications.• Each of The Sub-Category Classifications Has All of The

Properties of The Main Category, But in Addition Have A Small Number of Specific Extra Attributes.  

• In Many Situations The Subtype Entities Do Not Contain Any Key Attributes.

• The Attributes Registered in The Subtypes Are Only Registered To That Subtype Entity And Should Not Be Part of The Main Type.

• Subtype / Supertype Representation is For Clarity on The Overall System, But Not Mandatory.

Steps in Erwin• To Specify The Sub Types Erwin Provides The Subtype

Tool.• To Indicate A Subtype of Main Type, Select The Subtype

Icon, Click on The Super Type Entity, Then on The Subtype Entity.

• To Represent The Additional Subtypes of The Same Maintype, Click on The Subtype Icon That is Created And Then Click The Mouse on The Subtype Entity.

Page 19: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 19

Screen Shot 9 : Fourth Level Model Relationships

Page 20: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 20

Creation of A Database Schema • Before A Database Schema is Created We Must Ensure

That All Fundamental OR Strong Entities Have A Primary Key.  

• Once The Primary Keys Are Identified, We Should Define The Domain For Each Attribute.  

• We Can Leave The Responsibility To Erwin For Converting The ER Diagram into A Relational Schema.

Assigning Primary Keys • Fundamental OR Strong Entities Are Those That Do Not

Depend on Any Other Entity For Their Primary Key.  • Fundamental Entities Are Not…

• Subtypes • Associative OR Composite Entities • Weak OR Attributive Entities.   • Entities At The 'Many' End of An Identifying One-To-

Many Relationship.• The Sub-Types Do Not Contain Their Own Primary Keys,

But They Inherit The Primary Key From The Main Type.• Once The Primary Keys Are Identified For All The Strong

Entities The Database Schema Creation Can Be Commenced.

Page 21: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 21Screen Shot 10 : Fifth Level Model Relationships

Page 22: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 22

Defining Domains in Erwin• The Domain of An Attribute is The Set of Values That

Attribute is Permitted To Have.  • To Define A Domain We Have To Define Two Components

Datatype • Datatype is A Mandatory Property Applied For Every

Attribute.   Constraints • Constraints Are Optional Specifications Applied As

Business Rules Upon The Attributes.  • Constraint Can Set The Permitted Values Which Can

Be Narrower Than Defined By The Data Type Alone.  • Domains Can Be Shared By More Than One Attribute.   • In An ER Diagram, We Can Define The Domain Once, And

Apply it to Multiple Attributes.  • Domains Provide The Benefit of Consistence Across

Attributes And Ease of Maintenance.   Steps To Create Domains • Click The Model Menu Domain Dictionary.• Specify The Required Options For Each Domain That Has

To Be Created.

Page 23: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 23

Screen Shot 11 : Domain Dictionary Window

Steps To Create A Identifier Domain • To Create A New Domain Click on New

Button.• Type The Logical Name of The Domain

As Identifier And Click OK.• Click on The Data Type Tab, And

Choose The INTEGER Datatype For This Domain.

Page 24: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 24

Domain Name Data Type Validation Rule

Name VARCHAR(50) Check For Upper Case

Street VARCHAR(100) Check For Upper Case

City VARCHAR(50) Check For Upper Case

State VARCHAR(25) Check For Upper Case

Zipcode VARCHAR(10) Only Numerical Symbols Are Accepted

Phone VARCHAR(15) Only Numerical Symbols Are Accepted

Currency DECIMAL(9,2)Create A New Validation Rule Called Currency With A Minimum Value = 0

SSN VARCHAR(11) Only Numerical Symbols Are Accepted

Comment VARCHAR(255) Check For Upper Case

Property Type VARCHAR(25)Create A New Validation Rule Called Property Type With A List of Valid Values Consisting of {HOME, APARTMENT, CONDO, COMMERCIAL}

Date DATE

Non negative Integer INTEGERCreate A New Validate Rule Called Non Negative Integer With A Minimum Value = 0

Domains Identified For The Current Schema

• After All The Required Domains Are Created, The Domains Are Individually Attached To The Attributes.

Page 25: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 25

Applying Domains To Attributes • The Final Step of Working With Domains is To Associate

A Domain With Each Attribute.  • To Attach The Domain, Double-Click on One of The

Entities in The E-R Diagram.  • To Associated A Domain With An Attribute, Click First on

The Attribute, Then Click on The Associated Domain.

Converting An E-R Diagram into A Relational Schema • The First Stop in Converting An ER Diagram into A

Relational Schema is To Transform Each Entity And Each Relationship into its Counterpart in A Relational Schema Consisting of Relational Tables.

• Click Format Entity Display in Menu And Check The Following Properties• Primary Key Designator• Foreign Key Designator• Show Migrated Attributes

• To Transform The Logical ER Diagram into Physical Relational Schema Click And Select The Physical Option.

• In Physical Model The Relational Schema Will Be Looking Exactly As it is Expected By The DBMS Software.

Page 26: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 26

Screen Shot 12 : Model in Physical Model View

Page 27: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 27

Enhancing The Data Model• We Can Use The Drawing Features To Enhance The Data

Model Appearance And Make it Easier To View And Understand.

• The Drawing And Appearance Features Provided Are…• Enlarge The Font Size For All Entity Names.• Change The Color of All Foreign Keys To Red.• Use Different Fonts And Colors To Identify New

Objects From Old Objects in The Model.• Resize And Align One OR More Entity Boxes.

Changing Font and Color For Individual Objects• Select The Object For Which The Font And Color Has To

Be Changed And Use Object Font And Color Property…

OR

Page 28: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 28

Inheriting Objects With Color • In Erwin The Color of An Object Can Be Related To The

Color it Inherits From Other Objects in The Diagram.• Select The Relation Line And Click Secondary Mouse

Button And Choose Object Font And Color.

Page 29: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 29

Create Stored Displays• A Stored Display Helps in Having Different Views For The

Data Model Very Quickly.Steps To Create Stored Display• Format Stored Display• In The Stored Displays Dialog Box Click New.• Type A Name For The Stored Display, And Click OK.• The New Stored Display Dialog Closes.• Select The Display Option Settings By Clicking The

Property Tabs. Click OK To Save.

Page 30: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 30

Creating Subject Areas• A Subject Area is A Subset of Objects Taken From The

Whole Pool of Objects in The Model Diagram. • A New Data Model Includes One Subject Area Called The

Main Subject Area, Which Includes All of The Objects in The Data Model.

• The Subject Areas Are Not Copies of The Data Model, But Are Dynamic Subsets of The Data Model.

• When A Members is Added To A Subject Area The Objects Are Added To The Current Subject Area And The Main Subject Area.

• When An Attribute OR Column is Added To An Existing Entity OR Table, The New Object is Added To Every Subject Area in Which The Entity OR Table is A Member.

Steps To Create A New Subject Area• Model Subject Areas OR Click The Subject Areas

Button on The Toolbar.• In The Subject Area Editor, Click New.• Type A Name For The New Subject Area, And Click OK.• Click The Members Tab And Use The Arrows To Include

The Objects in The New Subject Area, Click OK.

Page 31: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 31

Selecting The Subject Area

Page 32: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 32

Creating An Index in The Index Editor • Right-Click A Table in The Diagram And Select Indexes

(OR)• Right-Click An Index Located Under A Table in The Model

Explorer And Select Properties (OR) • Click An Index Located Under A Table in The Model

Explorer, And Then Click The Property Editor Button. • Click New, In The New Index Dialog Assign An Index

Name.• Check The Unique Option To Create An AK Index OR

Uncheck The Unique Option To Create An Inversion Entry (IE) Index. Click OK.

• In The Index Editor, Select The Index Columns From The Available Columns List. Click OK.

Creating An Index in The Model Explorer• Click Tables To Expand The Folder, Right-Click The

Indexes Folder.• Select Either New AK OR New IE, A New Folder With A

Default Name is Added To The Indexes List.• Right-Click The New Index Folder, Select Properties.• Select The Index Columns From The Available Columns

List, Click Close.

Page 33: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 33

Page 34: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 34

Creating Views in Erwin• We Can Create Views in Physical Model.• A View is A SQL Query Which is Permanently Stored In

The Database Under Assigned Names. • A View is Used To Present Specific Database Information

For A Target Audience.• In AllFusion ERwin Data Modeler, A View Table And

Relationship Line Are Both Drawn With Dashed-Lines.Adding a View To A Model• Different Ways To Create A View in Erwin

• Click The Entity Button on The Allfusion Erwin DM Toolbox. Then Click in The Diagram Window.

• Reverse Engineer An Existing Database.• Copy A View From One Model And Paste it into

Another Model.• Right-Click The Views Folder in The Model Explorer

And Choose New.• A View is A Logical Representation of The Data, That is

Accessed From The Database Table OR Tables.• A View Provides Restricted Access To The Data From The

Actual Database Table OR Tables.

Page 35: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 35

OR

Page 36: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 36

Forward Engineering • Forward Engineering is A Process That Generates The

Physical Database Schema From The Data Model. • Forward Engineering Process Can Generate A Schema

• Tables • Triggers • Stored Procedures • Indexes • Constraints • Physical Storage Objects • Other Database Features Supported By The Target

DBMS.• Through Forward Engineering A Data Model, We Can

Choose To Generate A Script File, Which We Can Use To Update The Database Using A Database Administration Tool.

• Using Forward Engineering We Can Directly Connect To The Database Catalog And Generate The Database.

• Before We Forward Engineer, We Can View The Schema, Which is A Text-Based Representation of The Database Objects.

Page 37: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 37

Preview Schema Generation • Select Open From The File Menu, And Open The Required

Model For Schema Generation.• Use The Model Type Indicator And Switch To The

Physical Model. • Choose Forward Engineer, Schema Generation From The

Tools Menu And Click The Preview Button.Change Schema Generation Options• We Can Set Schema Generation Options By Category.• The Target Server We Select Determines The Options

That Appear in The Editor.• Tools Forward Engineer Schema Generator…• Make The Necessary Selections As Per The Requirement.

Page 38: Dimensional Modeling By Sathish Yellanki

Saturday, April 8, 2023 Introduction To DWH by Satish Kumar Yellanki Slide No 38

Generate The Schema• From The Preview Dialog, Click Generate (OR)• From The Main Schema Generation Dialog, Click

Generate.• In The Oracle Connection Dialog Box Enter A User Name,

Password, And Connect String.