Presentation is loading. Please wait.

Presentation is loading. Please wait.

ERWin Template Overview By: Dave Wentzel. Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u.

Similar presentations


Presentation on theme: "ERWin Template Overview By: Dave Wentzel. Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u."— Presentation transcript:

1 ERWin Template Overview By: Dave Wentzel

2 Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u Forward engineering process u Trouble shooting

3 What is a template ? u ERWin contains a macro language u Used for the creation of: –Stored Procedure Templates –Trigger Templates –Table script template (pre & post) u Based on type of template, will automatically generate SP, trigger, or script based on table/relationship information when the model is forward engineered

4 Why are we using templates? u Provide turn-key approach to data model creation u Reduce the number of triggers and stored procedures which need to be written u Can more easily make model changes without having to ‘re-write’ triggers and SPs

5 A little on the Macro Language... u ERWin contains a Template Toolbox which is used to create the templates

6 Types of Macros u Entity –Applied to tables in the diagram –Can be used to act as a loop - ‘For Each Entity’ –Can be used to reference qualities of an entity - ‘For Each (Attribute/Index/Key…)’ u Relationship –Applied to relationship information between entities –Can reference PK, FK, Parent/Child entities

7 Types of Macros Continued u Attribute –References ‘attributes’ of attributes such as length, field type, FK/PK, etc. u Constraint –References database constraint information u Miscellaneous –Arithmetic operators –Comparison operators –System Information

8 Stored Procedure Templates u Generates a stored procedure for WRITING / UPDATING a record in a table u Based on primary key attributes u If the key values are equal to an existing record, the record will be updated u If no matching record is found, a new record will be inserted u To be used as low level write routine called from higher level SPs.

9 Accessing the SP Templates u Right mouse click on a table u Select Table Editor / Stored Procedure option u Attach the appropriate template to the table u One must be attached for each table

10 Available Templates u Write Template u Stand Alone Table Triggers u Write Dimension Template u Write Fact Template

11 Write Template u Creates spWriteTableName u Assumes PK is an IDENTITY column u Assumes PK is FieldNameInst u Assumes columns: –Create Date / Create User –Modify Date / Modify User –If PK provided, updates record otherwise inserts new record

12 Standalone Table Triggers u Generates the insert/update triggers for standalone tables u Standalone tables may occur if created as a reference table u Generated through the SP template instead of the Trigger template because the trigger template assumed relationships

13 Write Dimension Template u Found in Datamart diagrams u Assumes a PK of identity u Assumes PK is FieldNameInst u Assumes no updates u If PK does not exist, will write new record

14 Write Fact Template u Found in Datamart diagrams u Inserts new records into fact tables

15 Trigger Templates u Generates Update/Delete/Insert triggers for a table and it associated tables u Helps maintain RI and date validations between related tables

16 Triggers and Relationships u Triggers are generated based on relationships between two entities u Double click on a relationship line –Child Delete / Insert / Update –Parent Delete / Insert / Update u Options: –Restrict - prevent –Cascade - propagate change –None - no trigger relationship

17 Accessing the Trigger Templates u Left mouse click on a table u Select SQL Server Trigger u Select SQL Server Trigger Template to attach Triggers

18 Available Trigger Templates u Approach Child Delete Restrict u Approach Child Delete Cascade u Approach Child Insert Restrict u Approach Child Update Restrict u Approach Parent Delete Cascade u Approach Parent Delete Restrict u Approach Parent Insert Restrict u Approach Parent Update Restrict

19 Available Trigger Templates u Approach Delete Footer u Approach Delete Header u Approach Insert Footer u Approach Insert Header u Approach Update Footer u Approach Update Header

20 Parent / Child Templates u On restrict, provides Raise Error message when a parent / child relationship exists u On cascade, will delete all associated tables with the same primary key u Verifies records do not overlap based on from and thru dates u Requires fields either FromDate / ThruDate or BeginDate / EndDate u Assumes domain type of ID in some models

21 Header / Footer Templates u Header creates the ‘Create Trigger’ code, parameters, and initial date checks against the table u Footer templates update the ModifyDate/User in the update triggers u Assume ModifyDate/ ModifyUser fields

22 Standard selections for RI Actions

23 Table Templates u Pre / post scripts generated during table creation u Used to generate print statement before table creation so implementation script is easier to read u Used for the OLAP fact tables to generate update triggers

24 Accessing Table Templates u Left click on table u Select Table Editor / Pre & Post Script

25 Independent Column Browser u Provides method of creating standard fields for use in current data model u Example: Used for standard fields applied to all tables u Domain type of ID exists which is referenced by some templates and must be assigned PK identity columns

26 Accessing the Independent Column Browser u Under Window select Independent Column Browser Option

27 Forward Engineering the Model u Triggers, stored procedures, and table scripts will be generated when you forward engineer the data model - based on the options you select u To forward engineer the model, select: Tasks \ Forward Engineer/Schema Generation

28 Schema Generation

29 Schema Options to Select u Table –Create Table –Drop Table –Pre-Script –Post-Script –Create Procedure –Drop Procedure

30 Options continued u Column –Validation –Default u Index –Create Index »Alternate Key »Foreign Key »Inversion Entry »CLUSTERED »Physical Storage

31 Options Continued u Referential Integrity –Primary Key »Alter (PK) –Foreign Key »Alter (FK) u Trigger –User Defined »RI Type Override »Relationship Override

32 Forward Engineer u Select PREVIEW u Cut / paste into SQL query window to run u Do not directly forward engineer into the database –Could delete items you did not anticipate –May be connected to a production server

33 Troubleshooting u Execute script u Review error statements u Review script code with error u Access the template to see what it is expecting u Verify correct relationships, triggers, SPs, etc. are associated with the table u Verify required fields are assigned to the table


Download ppt "ERWin Template Overview By: Dave Wentzel. Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u."

Similar presentations


Ads by Google