dbh user guide

Upload: cicakkampret

Post on 05-Apr-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 DBH User Guide

    1/40

    Database Helper

    Users Guide

    September 20, 2006

  • 7/31/2019 DBH User Guide

    2/40

    DBH User's Guide

    Disclaimer

    Trademark Notices: All product names mentioned in this document are trademarks or registeredtrademarks of their respective companies.

    The information contained herein is confidential and proprietary information ofThomas Maloney andAssociates. The materials are copyrighted and protected by worldwide copyright laws and treaty provisions,and may not be reproduced, modified, published, posted, transmitted, or distributed in any way without priorwritten permission from Thomas Maloney and Associates. The materials are provided as is without any

    express or implied warranties of any kind. Any warranties of merchantability, non-infringement ofintellectual property, and fitness for any particular purpose are expressly disclaimed. While Thomas Maloneyand Associates make every effort to ensure the accuracy of the information presented, in no event shallThomas Maloney and Associates or others be liable for any damages whatsoever (including, withoutlimitation, damages for loss of profits, business interruption, loss of information and other consequentialdamages) arising out of the use of or reliance upon the materials.

    Copyright 2006. All rights reserved.

    Thomas Maloney and AssociatesPortland, OregonDatabase Architects Internet website is http:\www.TheDatabaseArchitect.com

    To purchase additional copies of this product, contact Thomas Maloney and Associates, Portland, Oregon byemail at [email protected].

    Page ii Copyright 2006, Database Associates 9/20/2006

    http://www.xxx.com/xxxxhttp://www.xxx.com/xxxx
  • 7/31/2019 DBH User Guide

    3/40

    Contents

    1. Product Overview......................................................................................................................1

    Primitive Stored Procedures...................................................................................................................... 1

    Base Table Views......................................................................................................................................1

    Auditing Scripts.........................................................................................................................................2

    Table Row Versioning...............................................................................................................................2

    Summary ...................................................................................................................................................3

    2. Working with DBH ....................................................................................................................5

    Running the Program.................................................................................................................................5

    Generating Output Files with DBH ............................................................................................................5

    Explanation of the Output Files...........................................................................................................7

    Whats in the Generated Files?..................................................................................................................8

    Insert Primitive Stored Procedures ......................................................................................................8

    Delete Primitive Stored Procedures.....................................................................................................9

    Select Primitive Stored Procedures....................................................................................................10

    Update Primitive Stored Procedures..................................................................................................11

    Base Table Views .............................................................................................................................. 12

    Table Row Version Stamps ............................................................................................................... 13

    Table Row Audits .............................................................................................................................. 14

    DOS Command Files.........................................................................................................................14

    Script Viewer .....................................................................................................................................15

    Installing the Generated SQL Files .........................................................................................................15

    The View Script.................................................................................................................................17

    The Version Stamp File.....................................................................................................................18DOS Command File ..........................................................................................................................18

    Setting Up to Generate Scripts ................................................................................................................19

    Generating Primitive Stored Procedures Files and Installing Them .......... ........... ........... ........... ....... 19

    Setting Options Before Generating Stored Procedure Files...............................................................20

    Explanation of the DBH Options........................................................................................................20

    Set Options Section............................................................................................................................22

    Alter Table Scripts.............................................................................................................................22

    Target of the Generated SQL Scripts.................................................................................................23

    Appendix A. Installing DBH ..........................................................................................................25

    Appendix B. Registering DBH .......................................................................................................30Trial Period ........................................................................................................................................30

    Registering DBH Before the Grace Period Expires............................................................................31

    Registering DBH After the Grace Period Expires ..............................................................................34

    Index.................................................................................................................................................37

    9/20/2006 Copyright 2006, Database Associates Page iii

  • 7/31/2019 DBH User Guide

    4/40

    DBH User's Guide

    This page intentionally left blank.

    Page iv Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    5/40

    1. Product Overview

    DBH is an application that generates up to four types of SQL scripts depending upon the optionsselected. The primary script generated contains primitive stored procedures for each table in a

    database in either SQL Server 2000 and below syntax or SQL Server 2005 syntax. It also generates ascript of base table views for each table, script containing tables alter statement to add auditingcolumns to each table, and final script containing tables alter statements to add a row version columnto each table.

    Primitive Stored Procedures

    Many companies and database administrators have policies against directly access tables. In additiondatabase architectural design concepts calls for a transactional and business layers below thepresentation layer. Either or both of these layers may be composed of application code or SQL code.Determining which coding technique to use depends on many factors: performance, scalability,flexibility, security, and ease of maintenance.

    Numerous design architects prefer to employ a layer of abstraction between database tables and theuser. The user could be application code or a store procedure supporting transaction logic. This layerof abstraction is usually referred to as primitives. Most organizations prefer to create primitives asstored procedure while others create primitives in code as a method.

    Primitives are designed to accomplish a single purpose and operate against a single table. For eachtable there would be Insert, Delete, and Select primitive; for tables that have non key columns therewould also be an Update primitive. Many associate tables contain only key columns therefore anUpdate primitive would not be created.

    For organizations that use stored procedures for primitives, DBH will generate Insert, Update, Delete,and Select stored procedures, based on the target platform, SQL Server 2000 and below or SQLServer 2005, DBH generates coded using the syntax for the target platform. Each syntax version ofthe primitive script is fully documented, contains error handling, and returns as output parameters:

    Identity value for Insert procedures

    Timestamp value (row versioning) for Insert and Update procedures

    Depending upon the option selected for primitive generation, the procedures allow for input auditingvalues (e.g., created by, updated by, date created and last updated date). If user input for auditingvalues are not selected and either DBH option to generate audition rows is selected, or auditing rowshave been applied previously, then the procedures will updated these column automatically fromsystem values.

    Base Table ViewsTo complete this layer of abstraction, the concept of SQL views are used. DBH generates a base tableview for each table in the database. Views should be granted only select permission allow thetransactional layer access to the data stored within the tables. The Select stored procedures may beuse for some queries, but most data selection is accomplished via the views. For data selection, viewsprovide the same properties as selecting directly from a table.

    The transactional layer then used views to obtain the data and Insert, Update, and Delete proceduresto modify data. Using this layering concept ensures that only way data is modified is through the

    9/20/2006 Copyright 2006, Database Associates Page 1

  • 7/31/2019 DBH User Guide

    6/40

    DBH User's Guide

    primitives. Permission is not granted to any user account for any of these objects, instead the accountthat owns the transaction logic owns these object. Then permission is granted to the transactionalstored procedure for any role or users account. Because the transactional stored procedures areowned by the same account as the primitives, any primitive called by the transactional storedprocedure is carried out. If an account granted permission to run a transactional procedure tries to runany of the primitives, the account will be denied access.

    Auditing Scripts

    To provide auditing capability for any database, DBH generates a script that will provide ALTERTABLE statement for each table (except table that already have auditing column generated by DBH)adding auditing columns: _CreatedBy, _CreatedDate, _UpdatedDate, and _UpdatedBy. Theunderscore is added in front of each new auditing column to indicated that it was added by DBH.

    If the option to generate auditing columns is selected or DBH auditing columns have already beenapplied to the database tables, the selection of SQL Views and Primitive procedures will includethem when generated. The Primitive procedures can optionally allow for user provided inputauditing data or get auditing data for the SQL Server environment.

    Data modelers can leave auditing columns from the model providing for a cleaner and easier to readmodel. Then after generating a schema and applying it to a database, DBH can be used to providestandard auditing columns to each table. The data modeler can then synchronize the database to thephysical model to reflect the auditing columns. This will save a lot of modeling time.

    Table Row Versioning

    DBH can also generate a script containing ALTER TABLE statement to add a row versioningcolumn to each table that does not have a column of data type timestamp. Books on Line for SQLServer provide the following about locking:

    Optimistic Concurrency

    Optimistic concurrency control works on the assumption that resource conflicts betweenmultiple users are unlikely (but not impossible), and allows transactions to execute withoutlocking any resources. Only when attempting to change data are resources checked to determineif any conflicts have occurred. If a conflict occurs, the application must read the data and attemptthe change again.

    Pessimistic Concurrency

    Pessimistic concurrency control locks resources as they are required, for the duration of atransaction. Unless deadlocks occur, a transaction is assured of successful completion.

    For database developers, especially when designing database for the internet Optimistic Concurrencycontrol is usually the chosen method. DBH provides the ability to generate a script contain for each

    table in the database an alter statement to add a row version column. The row versioning column isnamed _RowVersion using the timestamp data type.

    Only a single timestamp data type can exist in any table and cannot be modified by a user. Each timeany column in a table is updated or inserted, SQL Server automatically changes the value in thetimestamp data type column. Using Optimistic Concurrency, the user must first save off the originalvalue stored in the timestamp column (binary (8)). Then before deleting or updating a row in a table,compare the stored timestamp value to the row being affected. If the values are the same thencarryout the action, else use some programmatic logic to handle the situation.

    Page 2 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    7/40

    DRAFT Working with DBH

    If DBH is used to generate the _RowVersion column or the table already has a column with a datatype of timestamp, when the primitive stored procedures are generated a timestamp parameter is usedto both pass in the stored timestamp value and return the new timestamp value for Updates. TheInsert primitive returns the timestamp value and the Delete primitive has an input timestampparameter. Each primitive stored procedure then uses the timestamp value to validate against thetables row before carrying out the activity.

    Summary

    By using DBH to generate Primitives, Views, Auditing columns, and table row versioning scripts thedatabase programmer can save days, weeks, and even months off the project. DBH provides aconsistent and straight forward mechanism for developing SQL Server database applications. Justselect a SQL Server, database on that server, location for the scripts files, and options to accomplishthen allow DBH to do all of the work for you.

    9/20/2006 Copyright 2006, Database Associates Page 3

  • 7/31/2019 DBH User Guide

    8/40

  • 7/31/2019 DBH User Guide

    9/40

    DRAFT Working with DBH

    2. Working with DBH

    DBH will save the database programmer days of TSQL coding to create Input, Update, Delete, andSelect primitive stored procedures for each database table. In addition to generating stored

    procedures, DBH

    can be used to generate base table Views, Audit columns, and row version stamps.DBH then allows you to interactively apply the generated scripts to the selected database, apply thescripts through a DOS command prompt cmd file, or manually through a SQL Editor (i.e., QueryAnalyzer, SQL Server Management Studio, etc.).

    Running the Program

    Follow these steps to run DBH:1. Click on Database Helper from the desktop of Start\Programs menu.

    2. Connect to a SQL Server.

    3. Chose the database for which you are building the scripts.

    4. Chose a file location where you want to send the output generated by DBH.

    5. Indicate to the DBH program the owner/schemathat will be own the Stored Proceduresand Views generated.

    Note: The assignment is called owner in SQL 2000, schema in SQL 2005.

    6. Select the options for generating primitive stored procedures (Insert, Update, Delete,and Select) for each table, base table Views, table Alter scripts to add Auditing and/orrow version columns.

    7. Press the Generate button (depending on the number of tables in the database thegeneration of scripts may take five minutes or more.)

    8. Apply the scripts to the database.

    Note: Generation of the scripts will not modify or alter the database in any way. Notuntil the scripts are applied via the Install button, DOS command file, ormanually installing each script individually.

    Generating Output Files with DBH

    1. Set DBH to generate the stored procedure.

    The stored procedures can be generated to allow the user to provide auditing values(user providing who made the change and the date of the change) or have the system

    collect data and enter the auditing values automatically.

    Up to four primitives are generated for each table in the database:

    a. Input stored procedure

    b. Update stored procedure (not generated for Associate tables with only key columns)

    c. Delete stored procedure

    d. Select stored procedure

    9/20/2006 Copyright 2006, Database Associates Page 5

  • 7/31/2019 DBH User Guide

    10/40

    DBH User's Guide

    2. Set DBH to generate base table Views for each table

    3. Set to generate a script to alter tables adding Auditing columns.

    a. _CreatedBy (sysname data type)

    b. _CreatedDate (smalldatetime data type)

    c. _UpdatedDate (smalldatetime data type)

    d. _UpdatedBy (sysname data type)

    4. Set to generate a script to add a Row Versioning column (timestamp data type) to eachtable.

    a. RowVersion (SQL timestamp data type)

    Figure 1

    Page 6 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    11/40

    DRAFT Working with DBH

    Explanation of the Output Files

    The output consists of four scripts four scripts, Audit.sql, Primitive.sql , View.sql , and VersionStamp.sql , plus a

    DOS command file, Control._cmd. The topics that follow explain these files whichare shown here:

    Figure 2

    Database Helper will overwrite any files with the same name of the generated files in the directory

    identified as the destination location.

    9/20/2006 Copyright 2006, Database Associates Page 7

  • 7/31/2019 DBH User Guide

    12/40

    DBH User's Guide

    Whats in the Generated Files?

    To see all the content of a sample script go tohttp://www.thedatabasearchitect.com/Product%20Tour.htmweb page and click on the generated fileyou wish to view. You will be able to scroll through an example of each SQL file generated by DBH.

    Insert Primitive Stored Procedures

    Figure 3

    Page 8 Copyright 2006, Database Associates 9/20/2006

    http://www.thedatabasearchitect.com/Product%20Tour.htmhttp://www.thedatabasearchitect.com/Product%20Tour.htm
  • 7/31/2019 DBH User Guide

    13/40

    DRAFT Working with DBH

    Delete Primitive Stored Procedures

    Figure 4

    9/20/2006 Copyright 2006, Database Associates Page 9

  • 7/31/2019 DBH User Guide

    14/40

    DBH User's Guide

    Select Primitive Stored Procedures

    Figure 5

    Page 10 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    15/40

    DRAFT Working with DBH

    Update Primitive Stored Procedures

    Figure 6

    9/20/2006 Copyright 2006, Database Associates Page 11

  • 7/31/2019 DBH User Guide

    16/40

    DBH User's Guide

    Base Table Views

    Figure 7

    Page 12 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    17/40

    DRAFT Working with DBH

    Table Row Version Stamps

    Figure 8

    9/20/2006 Copyright 2006, Database Associates Page 13

  • 7/31/2019 DBH User Guide

    18/40

    DBH User's Guide

    Table Row Audits

    Figure 9

    DOS Command Files

    Figure 10

    Page 14 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    19/40

    DRAFT Working with DBH

    Script Viewer

    ClickView Code and the viewer will display the stored procedures generated.

    Figure 11

    Installing the Generated SQL Files

    There are three ways to get the generated SQL files into the database:

    1. Let the system install the files. Simply click the Install button and the program willinstall the files in the database to which you are connected.

    2. Use the DOS command script which runs a series of commands to install the DDL SQLinto the database.

    3. Install the scripts one at a time through a SQL editor, e.g., Microsoft SQL ServiceManagement Studio, Query Analyzer, etc. It is necessary to follow a set order ofinstallation manually:

    Audit script

    Version Control script

    View script

    Primitive stored procedures script

    Depending on the combination of options selected will determine the scripts generated. DBH doesnot delete any previously generated script, it will overwrite an existing script. Open the DOScommand file with the DBH viewer or any text editor to verify the order and correct scripts to run.

    Note: Do not use the Open command if you right click on the DO S command file, this willrun the command file, use the EDIT option.

    9/20/2006 Copyright 2006, Database Associates Page 15

  • 7/31/2019 DBH User Guide

    20/40

    DBH User's Guide

    Open the audit file with the database editor, of your choice of editor. The audit and version scriptalters the table by inserting new columns into the table.

    When DBH alters the table, it adds _CreatedBy, _ CreatedDate, _UpdatedDate, and _UpdatedBy forauditing and _RowVersion for versioning as new columns into each of your tables. If you selectedthe option to Allow SP User Input, parameters are provided in each stored procedure allowing the

    user to provide the auditing values. If the Allow SP User Input option was not checked, theprocedure will provide the audition values.

    Notes: DBH will detect of any table already has a column with a timestamp data type and notgenerate a table alter statement for that table. The stored procedures when generatedwill use the provided timestamp data type column for the parameter instead of thecolumn name generated by DBH.

    DBH cannot detect Audit columns previously created for a table, except audit columnsgenerated by DBH, and will place a comment within each stored procedure when theAllow SP User Input option is checked and the Generate Audit Columns option is notchecked.

    You can view the generated scripts with an editor or open them with the DBH View option.

    Open the audit file with the database editor, of your choice. This is a script that is created for each ofthe tables in the database. The audit file alters the table by inserting new columns into the table tohold audit information.

    When DBH alters the file, it adds _CreatedBy, _ CreatedDate, _UpdatedDate, and _UpdatedBy asnew columns into each of your tables. Each time a new row is added to your table, if you, via anapplication or a business logic stored procedure, dont supply a date, the program uses the systemdate to set the update date, update time, and created by information.

    Note: This is based on the options selected during generation.

    The Audit File

    (Audit.sql)

    If theAllow SP User Inputoption is not checked and the Generate Audit Columns option is checked(or DBH -generated audit columns have been applied to a table previously), the generated storedprocedure automatically collect system information and updates the auditing columns.

    When theAllow User Inputoption is checked, the DBH generates stored procedures with inputparameters allowing the user to provide auditing values. Each auditing input parameter is validatedwithin the stored procedure to ensure that the input value is not null. Null input values are flaggedand raised as an error back to the user.

    The Primitives Script

    (Primitive.sql)

    A primitive stored procedure performs a single action (insert, update, delete, or select). Up to fourprimitives are generated for each table (Insert, Update, Delete, and Select). Update stored proceduresare only generated for Associate tables having non key columns.

    Each primitive stored procedure has an error routine built within it. If an error occurs duringprocessing, the procedure raises an error message back to the user. The user will need to check boththe error code and severity level after executing the stored procedure. If the error code returned is notequal to zero, then the user will need to take corrective action. If an error is returned, the user needsto check the severity, severity less than or equal to 10 are warnings, values greater that 10 are errors.

    Page 16 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    21/40

    DRAFT Working with DBH

    When a warning is returned it can be ignored without causing a problem. Warnings are returnedwhen the user requests an action for a query and the key values are not found. For example, a requestwas sent to delete a row given a primary key that does not exist no row was deleted. The callingprocess determines the logic to handle this condition.

    By default each object a database is assigned to an Owner (SQL Server 2000 and below)/Schema

    (SQL Server 2005 and above). The default is set to dbo (database owner). The dbo Owner is a goodchoice to SQL Server 2000 and below where all objects belong to the database owner. For SQLServer 2005 and above most developers prefer to assign object to a different Schema than dbo (whenno schema is provided for an object, SQL Server 2005 defaults to dbo).

    Note: If the user sets the Schema to another schema, it must exist in the database beforeinstalling the stored procedures or views.

    When a version stamps (timestamp data type) column exists in a table or the Generate VersionStamp option is checked, each Insert and Update stored procedure returns the value of the currentversion stamp as an output parameter. The value contained in the version stamp is a required inputparameter for the Update and Delete stored procedure (the same parameter is use for both input andoutput on the Update stored procedure).

    When a database is selected to generate stored procedures for, its version is identified and the Optionfor the SQL Version is set by default. The user may change this option and DBH will generate storedprocedures for the new version of the target database. The user may change the version of the targetdatabase to see the difference between the versions.

    The View Script

    (View.sql)

    This script is used to install a base level view for each table. When views are generated they arenamed using the tables name with a v prefix.

    For example, the view for the authors table in the pubs database with the Audit and Row Version

    option checked would look like:CREATE View [dbo].[vauthors]

    (

    [au_id]

    ,[au_lname]

    ,[au_fname]

    ,[phone]

    ,[address]

    ,[city]

    ,[state]

    ,[zip]

    ,[contract]

    ,[_CreatedBy]

    ,[_CreatedDate]

    ,[_UpdatedDate]

    ,[_UpdatedBy]

    ,[_RowVersion]

    )

    AS

    SELECT

    [x].[au_id]

    ,[x].[au_lname]

    9/20/2006 Copyright 2006, Database Associates Page 17

  • 7/31/2019 DBH User Guide

    22/40

    DBH User's Guide

    ,[x].[au_fname]

    ,[x].[phone]

    ,[x].[address]

    ,[x].[city]

    ,[x].[state]

    ,[x].[zip]

    ,[x].[contract]

    ,[x].[_CreatedBy]

    ,[x].[_CreatedDate]

    ,[x].[_UpdatedDate]

    ,[x].[_UpdatedBy]

    ,[x].[_RowVersion]

    FROM [dbo].[authors] [x]

    The Version Stamp File

    (VersionStamp.sql)

    Timestamp is a data type that exposes automatically generated (for both insert and updateoperations), unique binary numbers within a database. The timestamp is generally used as amechanism for version-stamping table rows. The storage size is 8 bytes.

    This tracks a relative time within a database, not an actual time that can be associated with a clock. Atable can have only one timestamp column. Every time that a row with a timestamp column ismodified or inserted, the incremented database timestamp value is inserted in the timestamp column.You can use the timestamp column of a row to easily determine whether any value in the row haschanged since the last time it was read. If any change is made to the row, the timestamp value isupdated. If no change is made to the row, the timestamp value is the same as when it was previouslyread.

    Many database developers use the timestamp data type column to manage contention within awebsites database instead of row locking. The timestamp data type provides the database developeran optimistic principal for handling contention within a database.

    DOS Command File

    (Controlcmd.cmd)

    The DOS command file may be used to apply the generated scripts to the database. For SQL Server2000 and below the SQL Server utility OSQL is used to apply the scripts. For SQL Server 2005 andabove the SQL Server utility SQLCMD is used to apply the scripts.

    The Command File

    You can run this using a DOS command. Simply click the Open and run it install it, or do a Runcommand. Go to the directory and type the file name to run it.

    Figure 12

    Page 18 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    23/40

    DRAFT Working with DBH

    The command file will then install each SQL file last generated by Database Helper into the databaseselect for file generation.

    Setting Up to Generate Scripts

    Figure 13

    Generating Primitive Stored Procedures Files and Installing Them

    The following topics describe how to use the Generate, ViewCode, and Install controls provided onthe DBH Display.

    Generate

    After setting up DBH, use this control to generate the DBH script files. When you complete the set upprocess, and are ready to generate these files, click the Generate button.

    Install

    To install the generated file automatically, select the Install button on the main screen. Each SQLfile generated is installed into the selected database. The account used to connect to the databasemust have the appropriate permission to install the files.

    9/20/2006 Copyright 2006, Database Associates Page 19

  • 7/31/2019 DBH User Guide

    24/40

    DBH User's Guide

    Setting Options Before Generating Stored Procedure Files

    All DBH options are listed in the File section (panel) on the right side of the DBH display screen asshown here:

    Figure 14

    Explanation of the DBH Options

    If no options are selected in the Set Options section (on the right side) the Generate button isinactivated.

    Select Server

    In the Select Server section, the first field presents a drop-down list where you can connect to theserver where the database resides. If you want to disconnect from the server displayed in the field,clickDisconnect, then click the down-drop arrow to select another server.

    If you have a Windows account set up on the selected server, simply select the WindowsAuthentication button to connect to the server.

    If you have an SQL account set up on the selected server, select the SQL Server Authenticationbutton and then enter your User ID and Password in the fields provided to connect to the server.

    Page 20 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    25/40

    DRAFT Working with DBH

    Select Database

    The drop-down list box in this section displays all the databases available on the selected server.Select the database for which you want to generate script files. Click the down-drop button and thelist shown and highlight the database.

    Figure 15

    Generated Code Path

    This field provides the path name and filename that will be used to store the script files generated in.You can use the button to the right of the text box to navigate and select a directory.

    9/20/2006 Copyright 2006, Database Associates Page 21

  • 7/31/2019 DBH User Guide

    26/40

    DBH User's Guide

    Figure 16

    Set Options Section

    In this section you are given the opportunity to select the type of scripts to generate and theconfiguration of the scripts.

    Schema/Owner

    SQL Server 2005 database uses schema instead of owner to collectively group objects. The labeljust below Generate Options will be either Schema or Owner, depending on the type of database towhich you connect DBH. The SQL Version control will default to the version of SQL Server (2000or 2005) connected to. If the SQL Version control option is changed the label for Generate Optiontext field will change appropriately.

    The text box defaults to dbo, which is Microsofts default for both Owners and Schemas. If youwant the Primitives and Views assigned to a different Owner/Schema type it into the text box. Each

    object in the Primitive and view scripts will then be prefixed with the content of the text box. Forexample if App is entered: CREATE PROCEDURE [App].[EmployeeInsert].

    Generate Primitive Stored Procedures

    Next, choose what you want to generate. You can set up DBH to generate primitive procedures withor without encryption by selecting the appropriate checkboxes. If you select With Encryption, thecode that encrypts and decrypts the stored procedure is written into the generated files.

    Also, if you want to generate views, select the Generate Views checkbox. You can generate viewsonly, with generating primitive procedures.

    Alter Table Scripts

    The Safety Prefix

    For safety, DBH places an underscore in front of the row version for the VersionStamp, CreatedBy,CreatedDate, UpdateDate, and UpdatedBy. So, for example, the name of the CreatedBy columngenerated by DBH is _CreatedBy. In this way, DBH avoids overwriting the names of the existingcolumns.

    Note: A future version of DBH may allow the user to set the safety prefix.

    Page 22 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    27/40

    DRAFT Working with DBH

    Generate Version Stamp

    If you want to generate a version stamp, select this checkbox. You can only have one version stampfor each table. DBH will generate an alter command for each table that contains a data type. It adds anew Row Version column and give it a data type of TimeStamp. You can only have one TimeStampin a single table. If a TimeStamp already exists in the table, DBH does not generate another timestamp data type column. It will not change or replace it. A message appears to warn that the tablealready has a time stamp. If the table does not have a TimeStamp, DBH adds it.

    Table Audit

    DBH is not able to detect who created, who updated the table, and the date. If you have thesecolumns in your table, DO NOT select the Generate Audit Columns checkbox; otherwise DBHcreates them and adds them to your table making it rather messy.

    Generate Audit Columns

    Select this checkbox if you want DBH to generate audit columns.

    Allow SP User Input

    In the primitive(s) DB

    H

    identifies, ifAllow SP User Input is selected, then DB

    H

    will automaticallyadd (install) them in the input parameters. IfAllow SP User Input is not selected and these primitivesdo not exist on the input parameters, the system creates a trigger that will update the columns in thetable. So instead of passing the data in, the trigger will cause the DBH program to add and to indicate the user and system. is the account name of the person who haslogged in to the database and is the name of the database server.

    Try and Catch

    SQL 2005 uses the coding constructs referred to as Try and Catch blocks used in the ISO standardsfor error trapping. Primitive stored procedures generated in the SQL Server 2005 mode will utilizethis form of error trapping.

    Target of the Generated SQL ScriptsDatabase Helper defaults to the version of SQL Server you are connected to. If you wish to generatethe scripts in a different version simply select the version of the target SQL Server. For example, ifyou are connected to a SQL Server 2000 Server and the pubs database, the version in the SQLVersion frame will be set to 2000. If you are planning on migration the pubs database to a SQLServer 2005, and then simply select the 2005 version in the frame.

    9/20/2006 Copyright 2006, Database Associates Page 23

  • 7/31/2019 DBH User Guide

    28/40

    DBH User's Guide

    View Code

    A lot of programmers like to look at the generated files, and then manually install the filesthemselves. DBH lets you view the files in a separate viewer, shown below.

    Figure 17

    To use the View Code feature to look at generated files:

    1. Click the View Code button on the main screen. The DBH viewer, shown here, showsthe content of the files.

    2. Review the as desired

    Page 24 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    29/40

    Appendix A. Installing DBH

    During the installation of DBH, the .NET Framework 2.0 is installed on the hosting machine. This isa required element for the installation.

    The installation of the .NET Framework 2.0 will require several minutes; you can install the .NETFramework 2.0 separately before hand. This reduces the amount of time required for the installationDBH.

    You can find the .NET Framework 2.0 installation routine at:

    http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-

    8EDD-AAB15C5E04F5&displaylang=en.

    1. To install DBH, download the installation program from thehttp:\www.TheDatabaseArchitect.com website or order a CD from the same website.

    2. The installation will start automatically. This dialog appears:

    Figure 18

    9/20/2006 Copyright 2006, Database Associates Page 25

    http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=en
  • 7/31/2019 DBH User Guide

    30/40

    DBH User's Guide

    When installation of the required files finishes, this dialog appears to show the progressof the DBH installation: When this process is completed, the Installer Setup Wizardappears:

    Figure 19

    1. ClickNext. The License Agreement dialog appears:

    Figure 20

    2. Select I Agree by selecting this button.

    Page 26 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    31/40

    DRAFT Installing DBH

    3. ClickNext. The Select Installation Folder dialog appears:

    Figure 21

    ClickBrowse to install the program in a location other than the default location shownas C:\Program Files\CSD\Installer\.

    ClickDisk Cost if you want to check for installation space on your drives:

    Figure 22

    ClickOK to proceed when finished. The software returns you to the Select InstallationFolder dialog.

    9/20/2006 Copyright 2006, Database Associates Page 27

  • 7/31/2019 DBH User Guide

    32/40

    DBH User's Guide

    4. ClickNext. The Confirm Installation dialog is displayed:

    Figure 23

    5. ClickNext. The Installing DBH Components dialog is presented:

    Figure 24

    Page 28 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    33/40

    DRAFT Installing DBH

    When the installation finishes, the Installation Complete dialog appears:

    Figure 25

    6. Click the Start button, then clickAll Programs and Windows presents a menu showingall installed programs, select DatabaseHelper (e.g., DBH).

    9/20/2006 Copyright 2006, Database Associates Page 29

  • 7/31/2019 DBH User Guide

    34/40

    DBH User's Guide

    Appendix B. Registering DBH

    Trial Period

    You have a 10 day free trial period that starts the first time you run the application. During startup,the first time DBH is run; DBH registers itself as a trial version. The second time DBH is run aninformation screen appears showing the number of days left. This popup message appears each timeyou use DBH until you license the product, until the 10 day trial period is over. You can register DBHanytime during the trial period by going to Help>Licensing and entering the Product Code and yourname or organization. The product code can be obtained by going to the DBH websitehttp://TheDatabaseArchitect.com and ordering the product or emailing the sales department [email protected]. You must provide the Processor ID found on the Licensingscreen.

    Figure 26

    After the 10 day period expires, a screen appears asking you to register the product, then theapplication closes. If you have not registered DBH by the end of the trial period, the program displaysthis screen:

    Figure 27To license the product, send the Processor ID number or a copy of this screen to DBH. After ThomasMaloney and Associates receives proof of payment, the Product Key is sent to you by email or USMail based on your preference.

    Page 30 Copyright 2006, Database Associates 9/20/2006

    http://thedatabasearchitect.com/mailto:[email protected]:[email protected]://thedatabasearchitect.com/
  • 7/31/2019 DBH User Guide

    35/40

    DRAFT Installing DBH

    Registering DBH Before the Grace Period Expires

    To register the product before the trial period ends:

    1. Select Help > Licensing from the menu bar. The DBH Licensing screen appears as shownhere:

    Figure 28

    9/20/2006 Copyright 2006, Database Associates Page 31

  • 7/31/2019 DBH User Guide

    36/40

    DBH User's Guide

    The Empty licensing screen appears, except for the Processor ID. Send the Processor ID back to DBHalong with your payment of $129.00 and your Product Key will be returned to you. (If you downloadthe program and paid over the internet, you only need to send the Product ID to DBH to get yourProduct Key.

    Figure 29

    2. Enter the product key and the owners or Companys name as shown:

    Figure 30

    Page 32 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    37/40

    DRAFT Installing DBH

    3. ClickRegister. The next time you press Help > Licensing, the licensing screen will containthe Processor ID, Product Key, and Owner/Company data.

    Figure 31

    9/20/2006 Copyright 2006, Database Associates Page 33

  • 7/31/2019 DBH User Guide

    38/40

    DBH User's Guide

    Registering DBH After the Grace Period Expires

    1. Start DBH.

    2. When the Registration screen above appears, click the YES button. The Registration screen

    appears.3. Enter the 16 digit Product Key and the Owner/Company.

    4. ClickRegister.

    Figure 32

    Page 34 Copyright 2006, Database Associates 9/20/2006

  • 7/31/2019 DBH User Guide

    39/40

    DRAFT

    Index

    DBH installation .............................................8

    DBH output files...........................................18

    Generating primitive script files .................. 17

    Installing output files in database................ 27

    Output files.................................................. 18

    9/20/2006 Copyright 2006, Database Associates Page 37

  • 7/31/2019 DBH User Guide

    40/40

    DBH User's Guide

    This page intentionally left blank.