Followers

Monday, March 16, 2020

DRM Migration



DRM Migration steps:

1. Once we are done with DRM installation, we need to create application. Update DB details and do test connection. Test connection must be successful.

2. Create schema and schema objects using below scripts. Otherwise we can run Create repository wizard also. If schema already created, execute following script on that DRM DB.

3. If we are migrating from one environment to another, go to repository wizard, select copy or Upgrade existing repository option

4. Update Source database details, test connection and click Next

5. Once system analyse the objects, click next

6. Update Target database details, test connection and click next

7. Review Source and Target schema details and click Next to start copy.

8. Once copy finished and click on Finish and restart DRM service to access application.


If no objects created in schema, you may face this error in the above proce:

DRM-11016: Connection was established with the server but the connection parameters do not reference a valid DRM database. Error message: Invalid object name 'DAL_Version'

To Create Database in SQL Database:

/****** IMPORTANT INSTRUCTIONS FOR DATABASE ADMINISTRATORS *********
 * This script must be run by a DBA. It creates a new database and a new    *
 * user which will serve as the database login for the Data Relationship    *
 * Management service.                                                      *
 *                                                                          *
 * The sp_addlogin password parameter was supplied during configuration of  *
 * the new repository. Before running the script, you may want to change    *
 * the supplied password. If you do change the password, the new password   *
 * must be provided to the Oracle DRM administrator before the Oracle DRM   *
 * service can be started.                                                  *
 *                                                                          *
 * A separate script has been generated to create the schema objects.       *
 ****************************************************************************
  Oracle Data Relationship Management
  Database Name:  <SchemaName>
  Schema Version: 11.1.2.4.340.1
*/

CREATE DATABASE <SchemaName>
  ON (NAME = <SchemaName>,
  FILENAME = 'E:\MSSQL_HFMDEV\UserData\<SchemaName>.mdf',
  SIZE = 7301)
  LOG ON (NAME = <SchemaName>_log,
  FILENAME = 'F:\MSSQL_HFMDEV\UserLog\<SchemaName>_log.ldf',
  SIZE = 1825)

GO
ALTER DATABASE <SchemaName> SET ALLOW_SNAPSHOT_ISOLATION ON
GO
ALTER DATABASE <SchemaName> SET READ_COMMITTED_SNAPSHOT ON
GO

USE <SchemaName>
GO

IF NOT EXISTS(SELECT * FROM master.dbo.syslogins WHERE loginname = '<DBAUSER>')
  EXEC sp_addlogin <DBAUSER>, '<password>', <SchemaName>
GO

IF NOT EXISTS(SELECT * FROM sysusers WHERE name = '<DBAUSER>')
  EXEC sp_grantdbaccess <DBAUSER>
GO

EXEC sp_addrolemember db_owner, <DBAUSER>
GO

******************************************************************************
To Create Objects in Database:


/******** IMPORTANT! READ THIS BEFORE EXECUTING THE SCRIPT **********
 *                                                                           *
 * This script creates the objects within a newly created or otherwise empty *
 * database. Be sure you are using an empty database that is dedicated for   *
 * use by the Data Relationship Management service.                          *
 *                                                                           *
 *****************************************************************************
   Oracle Hyperion Data Relationship Management
   Database Name:  <SchemaName>
   Schema Version: 11.1.2.4.340.1
 */

 USE <SchemaName>
 GO


CREATE TABLE dbo.DAL_Sequence
   (
     c_key nvarchar(30) NOT NULL,
     i_id int NOT NULL,
     c_primary_table nvarchar(30) NULL
   );

CREATE TABLE dbo.DAL_Updates
   (
     c_version nvarchar(40) NOT NULL,
     b_failed bit NULL,
     c_message nvarchar(2000) NULL
   );

CREATE TABLE dbo.RM_Access_Group_Ctrl_Hier
   (
     i_security_id int NOT NULL,
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL
   );

CREATE TABLE dbo.RM_Access_Group_Definition
   (
     i_security_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     i_order int NULL,
     b_global bit NOT NULL,
     c_label nvarchar(255) NOT NULL,
     e_access_group_type nvarchar(30) NOT NULL,
     c_css_group_name nvarchar(256) NULL
   );

CREATE TABLE dbo.RM_Access_Group_Prop_Global
   (
     i_version_id int NOT NULL,
     i_node_id int NOT NULL,
     i_security_id int NOT NULL,
     b_leaf bit NOT NULL,
     b_locked bit NOT NULL,
     e_access_level nvarchar(30) NOT NULL,
     e_workflow_access_level nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Access_Group_Prop_Local
   (
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL,
     i_node_id int NOT NULL,
     i_security_id int NOT NULL,
     b_leaf bit NOT NULL,
     b_locked bit NOT NULL,
     e_access_level nvarchar(30) NOT NULL,
     e_workflow_access_level nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Access_Group_User
   (
     i_security_id int NOT NULL,
     i_user_id int NOT NULL
   );

CREATE TABLE dbo.RM_Blender
   (
     i_blender_id int NOT NULL,
     i_user_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     b_disable_rt_validations bit NOT NULL,
     i_allowed_errors int NOT NULL,
     b_create_version_copy bit NOT NULL,
     b_allow_hierarchy_create bit NOT NULL,
     i_maximum_passes int NOT NULL,
     b_populate_blend_properties bit NOT NULL,
     b_clear_blend_properties bit NOT NULL,
     b_all_hierarchies bit NOT NULL,
     b_default_all_hierarchies bit NOT NULL,
     b_process_structure bit NOT NULL,
     b_process_adds bit NOT NULL,
     b_process_removes bit NOT NULL,
     c_property_selection_mode nvarchar(20) NOT NULL,
     c_remove_mode nvarchar(20) NOT NULL,
     c_remove_indicator_property nvarchar(255) NULL,
     c_version_blended_property nvarchar(255) NULL,
     c_hierarchy_blended_property nvarchar(255) NULL,
     c_node_created_property nvarchar(255) NULL,
     c_node_added_property nvarchar(255) NULL,
     c_node_moved_property nvarchar(255) NULL,
     c_node_global_changed_property nvarchar(255) NULL,
     c_node_local_changed_property nvarchar(255) NULL,
     b_propagate_locks bit NOT NULL,
     c_propagate_mode nvarchar(20) NOT NULL,
     b_promote_leafs bit NOT NULL,
     c_leaf_promoted_property nvarchar(255) NULL,
     b_process_activations bit NOT NULL,
     b_process_hier_val_assignments bit NOT NULL,
     b_process_ver_val_assignments bit NOT NULL,
     c_source_version_abbrev nvarchar(255) NULL,
     c_target_version_abbrev nvarchar(255) NULL,
     e_domain_name_blend_method nvarchar(30) NOT NULL,
     b_create_domains_in_target bit NULL,
     c_domain_holding_property nvarchar(255) NULL,
     c_global_domain_name nvarchar(255) NULL,
     c_domain_node_assigned_prop nvarchar(255) NULL,
     i_access_group_id int NOT NULL,
     b_target_version_from_param bit NULL,
     c_copy_version_abbrev nvarchar(255) NULL,
     c_copy_version_descr nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Blender_Default_Param
   (
     i_blender_id int NOT NULL,
     c_parameter nvarchar(40) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Blender_Hierarchy_Set
   (
     i_blender_id int NOT NULL,
     i_hierarchy_set_id int NOT NULL,
     i_blender_property_list_id int NULL,
     c_source_hierarchy_abbrev nvarchar(255) NULL,
     c_source_top_node_abbrev nvarchar(255) NULL,
     c_target_hierarchy_abbrev nvarchar(255) NULL,
     c_target_top_node_abbrev nvarchar(255) NULL,
     b_process_structure bit NOT NULL,
     b_process_adds bit NOT NULL,
     b_process_removes bit NOT NULL,
     c_remove_mode nvarchar(20) NOT NULL,
     c_property_selection_mode nvarchar(20) NOT NULL,
     c_remove_indicator_property nvarchar(255) NULL,
     b_use_profile_defaults bit NOT NULL,
     b_process_activations bit NOT NULL,
     b_process_hier_val_assignments bit NOT NULL,
     c_domain_holding_property nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Blender_Property_List
   (
     i_blender_id int NOT NULL,
     i_blender_property_list_id int NOT NULL,
     b_default bit NOT NULL
   );

CREATE TABLE dbo.RM_Blender_Property_List_Item
   (
     i_blender_id int NOT NULL,
     i_blender_property_list_id int NOT NULL,
     i_blender_property_item_id int NOT NULL,
     c_prop_def_abbrev nvarchar(255) NOT NULL,
     b_propagate_locks bit NOT NULL,
     c_propagate_mode nvarchar(20) NOT NULL,
     e_blender_list_property_action nvarchar(20) NOT NULL
   );

CREATE TABLE dbo.RM_Book
   (
     i_book_id int NOT NULL,
     i_user_id int NOT NULL,
     c_book_name nvarchar(255) NULL,
     c_book_descr nvarchar(2000) NULL,
     c_pre_filename nvarchar(255) NULL,
     c_post_filename nvarchar(255) NULL,
     c_combined_filename nvarchar(255) NULL,
     b_combine bit NOT NULL,
     d_current_asof_datetime datetime NULL,
     i_current_asof_offset_days int NULL,
     i_current_asof_id int NULL,
     e_version_type_param__current nvarchar(30) NOT NULL,
     d_previous_asof_datetime datetime NULL,
     i_previous_asof_offset_days int NULL,
     i_previous_asof_id int NULL,
     e_version_type_param__previous nvarchar(30) NOT NULL,
     e_as_of_method__current nvarchar(30) NOT NULL,
     e_as_of_method__previous nvarchar(30) NOT NULL,
     i_current_asof_offset_time int NOT NULL,
     i_previous_asof_offset_time int NOT NULL,
     c_pre_file_connection nvarchar(40) NULL,
     c_post_file_connection nvarchar(40) NULL,
     c_combined_file_connection nvarchar(40) NULL,
     b_client_output bit NULL,
     c_current_version_abbrev nvarchar(255) NULL,
     c_previous_version_abbrev nvarchar(255) NULL,
     i_combined_file_codepage int NULL,
     i_access_group_id int NOT NULL
   );

CREATE TABLE dbo.RM_Book_Default_Param
   (
     i_book_id int NOT NULL,
     c_parameter nvarchar(40) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Book_Item
   (
     i_book_id int NOT NULL,
     i_book_item_id int NOT NULL,
     i_export_id int NOT NULL
   );

CREATE TABLE dbo.RM_Category
   (
     i_category_id int NOT NULL,
     c_category_code nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     i_order int NULL,
     c_css_group_name_readonly nvarchar(256) NULL,
     c_css_group_name_edit nvarchar(256) NULL
   );

CREATE TABLE dbo.RM_Category_User
   (
     i_user_id int NOT NULL,
     i_category_id int NOT NULL,
     e_access_level nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Compare
   (
     i_compare_id int NOT NULL,
     i_user_id int NOT NULL,
     i_query_id int NULL,
     c_from_hier nvarchar(255) NULL,
     c_to_hier nvarchar(255) NULL,
     c_from_node nvarchar(255) NULL,
     c_to_node nvarchar(255) NULL,
     b_differences bit NOT NULL,
     b_user_defined bit NOT NULL,
     b_compare_limbs bit NOT NULL,
     b_compare_leafs bit NOT NULL,
     e_comparison_type nvarchar(30) NOT NULL,
     b_expand_marks bit NOT NULL,
     c_compare_abbrev nvarchar(255) NULL,
     c_compare_descr nvarchar(2000) NULL,
     b_include_filter bit NOT NULL,
     b_rename_check bit NOT NULL,
     e_as_of_method__current nvarchar(30) NOT NULL,
     d_current_asof_datetime datetime NULL,
     i_current_asof_offset_days int NULL,
     i_current_asof_id int NULL,
     e_version_type_param__current nvarchar(30) NOT NULL,
     e_as_of_method__previous nvarchar(30) NOT NULL,
     d_previous_asof_datetime datetime NULL,
     i_previous_asof_offset_days int NULL,
     i_previous_asof_id int NULL,
     e_version_type_param__previous nvarchar(30) NOT NULL,
     c_join_property_abbrev nvarchar(255) NULL,
     b_show_list bit NOT NULL,
     b_mark_nodes bit NOT NULL,
     i_current_asof_offset_time int NOT NULL,
     i_previous_asof_offset_time int NOT NULL,
     b_include_compare_properties bit NOT NULL,
     c_current_version_abbrev nvarchar(255) NULL,
     c_previous_version_abbrev nvarchar(255) NULL,
     i_access_group_id int NOT NULL
   );

CREATE TABLE dbo.RM_Compare_Default_Param
   (
     i_compare_id int NOT NULL,
     c_parameter nvarchar(40) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Compare_Item
   (
     i_compare_id int NOT NULL,
     i_item_id int NOT NULL,
     c_property_abbrev nvarchar(255) NOT NULL,
     i_order int NULL
   );

CREATE TABLE dbo.RM_Config_Info
   (
     c_key nvarchar(255) NOT NULL,
     c_value nvarchar(1000) NULL
   );

CREATE TABLE dbo.RM_Connection
   (
     i_connection_id int NOT NULL,
     c_name nvarchar(40) NOT NULL,
     c_description nvarchar(2000) NULL,
     e_connection_type nvarchar(40) NOT NULL,
     c_connection_info nvarchar(1024) NULL,
     c_connection_string nvarchar(1024) NULL,
     c_connection_key nvarchar(2000) NULL,
     i_user_id int NOT NULL,
     c_user_name nvarchar(200) NULL,
     c_password nvarchar(510) NULL,
     i_access_group_id int NOT NULL,
     e_web_service_protocol nvarchar(40) NOT NULL,
     c_host_name nvarchar(1024) NULL,
     i_port int NULL,
     e_authentication_type nvarchar(40) NOT NULL
   );

CREATE TABLE dbo.RM_Connection_Allowed_Table
   (
     i_connection_id int NOT NULL,
     c_table_name nvarchar(128) NOT NULL,
     b_is_read_only bit NULL,
     b_is_view bit NULL,
     c_owner nvarchar(256) NOT NULL
   );

CREATE TABLE dbo.RM_Connection_Operation
   (
     i_connection_id int NOT NULL,
     i_operation_id int NOT NULL,
     c_name nvarchar(128) NOT NULL,
     c_description nvarchar(255) NULL,
     e_request_method nvarchar(30) NOT NULL,
     x_uri ntext NULL,
     x_header ntext NULL,
     x_body ntext NULL,
     c_list_identifier nvarchar(1024) NULL,
     e_operation_type nvarchar(30) NOT NULL,
     e_db_operation nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Connection_Operation_Column
   (
     i_connection_id int NOT NULL,
     i_operation_id int NOT NULL,
     c_column_name nvarchar(128) NOT NULL,
     i_order int NULL,
     c_expression nvarchar(1024) NULL
   );

CREATE TABLE dbo.RM_Connection_Operation_Param
   (
     i_connection_id int NOT NULL,
     i_operation_id int NOT NULL,
     c_param_name nvarchar(128) NOT NULL,
     c_description nvarchar(255) NULL,
     i_order int NULL,
     c_data_type nvarchar(255) NULL,
     e_param_direction nvarchar(30) NOT NULL,
     c_test_value nvarchar(255) NULL,
     b_is_result_param bit NULL
   );

CREATE TABLE dbo.RM_Derived_Property
   (
     c_deriver_class nvarchar(20) NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_label nvarchar(40) NULL,
     c_descr nvarchar(2000) NULL,
     c_required_abbrev nvarchar(255) NOT NULL,
     b_required bit NOT NULL
   );

CREATE TABLE dbo.RM_Derived_Property_Param
   (
     c_deriver_class nvarchar(20) NOT NULL,
     i_template_id int NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_label nvarchar(40) NULL,
     c_descr nvarchar(255) NULL,
     c_value nvarchar(2000) NULL
   );

CREATE TABLE dbo.RM_Domain
   (
     i_domain_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     c_qualifier nvarchar(2000) NULL,
     b_qualifier_suffix bit NULL,
     c_delimiter nvarchar(255) NULL,
     b_can_edit_leaf bit NULL,
     b_can_delete_nodes bit NULL
   );

CREATE TABLE dbo.RM_Domain_Node
   (
     i_domain_id int NOT NULL,
     i_domain_node_id int NOT NULL,
     c_domain_node_abbrev nvarchar(255) NOT NULL,
     c_domain_node_descr nvarchar(255) NOT NULL,
     d_inactive_date datetime NULL,
     i_update_id int NULL
   );

CREATE TABLE dbo.RM_Domain_Validations
   (
     i_domain_id int NOT NULL,
     i_validation_id int NOT NULL,
     e_validation_type nvarchar(255) NOT NULL
   );

CREATE TABLE dbo.RM_Domain_Version
   (
     i_domain_id int NOT NULL,
     i_version_id int NOT NULL
   );

CREATE TABLE dbo.RM_Engine_Info
   (
     i_id int NOT NULL,
     c_engine_id nvarchar(255) NOT NULL,
     c_application nvarchar(255) NOT NULL,
     c_machine_name nvarchar(255) NOT NULL,
     i_ping_frequency int NOT NULL,
     d_last_ping datetime NOT NULL
   );

CREATE TABLE dbo.RM_Export
   (
     i_export_id int NOT NULL,
     i_validation_id int NULL,
     i_query_id int NULL,
     e_export_output_mode nvarchar(30) NOT NULL,
     i_export_type_id int NOT NULL,
     i_user_id int NOT NULL,
     b_quoted_strings bit NOT NULL,
     c_delimiter nvarchar(8) NULL,
     b_fixed_width bit NOT NULL,
     c_output_filename nvarchar(255) NULL,
     c_export_abbrev nvarchar(255) NULL,
     c_export_descr nvarchar(2000) NULL,
     b_column_headers bit NOT NULL,
     b_include_inactive bit NOT NULL,
     i_access_group_id int NOT NULL
   );

CREATE TABLE dbo.RM_Export_Column
   (
     i_export_id int NOT NULL,
     i_column_id int NOT NULL,
     i_width int NOT NULL,
     c_title nvarchar(255) NULL,
     c_default_value nvarchar(255) NULL,
     x_key ntext NULL,
     c_column_class nvarchar(40) NOT NULL,
     c_padchar nvarchar(1) NULL,
     e_export_column_layout nvarchar(30) NOT NULL,
     b_pivot bit NOT NULL,
     b_skip_default bit NOT NULL,
     b_primarykey bit NOT NULL,
     c_db_field_name nvarchar(255) NULL,
     i_db_field_len int NOT NULL,
     e_db_field_type nvarchar(30) NOT NULL,
     b_db_key_field bit NOT NULL,
     e_export_column_case nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Export_Default_Param
   (
     i_export_id int NOT NULL,
     c_parameter nvarchar(40) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Export_Node
   (
     i_export_id int NOT NULL,
     i_export_node_id int NOT NULL,
     c_hierarchy_abbrev nvarchar(255) NULL,
     c_node_abbrev nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Export_Node_Prop
   (
     i_export_id int NOT NULL,
     i_export_node_id int NOT NULL,
     c_property_abbrev nvarchar(255) NOT NULL
   );

CREATE TABLE dbo.RM_Export_Param
   (
     i_export_id int NOT NULL,
     i_export_param_id int NOT NULL,
     c_key nvarchar(40) NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Export_Type
   (
     i_export_type_id int NOT NULL,
     c_export_class nvarchar(60) NOT NULL,
     c_export_label nvarchar(80) NULL,
     c_descr nvarchar(2000) NULL,
     c_namespace nvarchar(200) NULL,
     c_assembly_name nvarchar(80) NULL,
     b_enabled bit NOT NULL
   );

CREATE TABLE dbo.RM_Glyph
   (
     i_glyph_id int NOT NULL,
     c_descr nvarchar(2000) NULL,
     m_glyph image NULL,
     c_abbrev nvarchar(255) NULL,
     e_image_type nvarchar(50) NOT NULL
   );

CREATE TABLE dbo.RM_Hierarchy
   (
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL,
     c_abbrev nvarchar(255) NULL,
     c_descr nvarchar(255) NULL,
     i_top_node_id int NULL,
     i_order int NULL,
     i_hierarchy_group_id int NULL,
     i_user_id int NULL,
     i_node_count int NOT NULL,
     i_limb_count int NOT NULL,
     i_leaf_count int NOT NULL,
     i_primary_count int NOT NULL,
     i_shared_count int NOT NULL,
     b_full_count_flag bit NOT NULL,
     d_count_update_timestamp datetime NULL
   );

CREATE TABLE dbo.RM_Hierarchy_Group
   (
     i_hierarchy_group_id int NOT NULL,
     c_name nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     i_order int NULL
   );

CREATE TABLE dbo.RM_Hierarchy_Prop
   (
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL,
     i_property_id int NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Import
   (
     i_import_id int NOT NULL,
     i_import_type_id int NULL,
     i_user_id int NOT NULL,
     c_import_abbrev nvarchar(255) NULL,
     c_import_descr nvarchar(2000) NULL,
     i_access_group_id int NOT NULL
   );

CREATE TABLE dbo.RM_Import_Class
   (
     c_import_class nvarchar(40) NOT NULL,
     c_import_label nvarchar(40) NULL,
     c_import_descr nvarchar(2000) NULL
   );

CREATE TABLE dbo.RM_Import_Default_Param
   (
     i_import_id int NOT NULL,
     c_parameter nvarchar(40) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Import_Param
   (
     i_import_id int NOT NULL,
     i_import_param_id int NOT NULL,
     c_key nvarchar(20) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Import_Section
   (
     i_import_id int NOT NULL,
     i_import_section_id int NOT NULL,
     e_import_section_type nvarchar(30) NOT NULL,
     b_process_section bit NOT NULL
   );

CREATE TABLE dbo.RM_Import_Section_Column
   (
     i_import_id int NOT NULL,
     i_import_section_id int NOT NULL,
     i_import_section_column_id int NOT NULL,
     c_property_abbrev nvarchar(255) NULL,
     c_display_label nvarchar(255) NULL,
     b_ignore_column bit NOT NULL,
     b_is_structure_column bit NOT NULL
   );

CREATE TABLE dbo.RM_Import_Section_Column_Hier
   (
     i_import_id int NOT NULL,
     i_import_section_id int NOT NULL,
     i_import_section_column_id int NOT NULL,
     i_import_section_column_hierid int NOT NULL,
     c_hier_abbrev nvarchar(255) NOT NULL
   );

CREATE TABLE dbo.RM_Import_Section_Column_Param
   (
     i_import_id int NOT NULL,
     i_import_section_id int NOT NULL,
     i_import_section_column_id int NOT NULL,
     i_import_param_id int NOT NULL,
     c_key nvarchar(20) NULL,
     c_value nvarchar(2000) NULL
   );

CREATE TABLE dbo.RM_Import_Section_Param
   (
     i_import_id int NOT NULL,
     i_import_section_id int NOT NULL,
     i_import_param_id int NOT NULL,
     c_key nvarchar(20) NULL,
     c_value nvarchar(2000) NULL
   );

CREATE TABLE dbo.RM_Import_Type
   (
     i_import_type_id int NOT NULL,
     c_import_class nvarchar(40) NOT NULL,
     c_import_label nvarchar(40) NULL,
     c_import_descr nvarchar(2000) NULL
   );

CREATE TABLE dbo.RM_Job_History
   (
     i_job_id int NOT NULL,
     x_job_description ntext NULL,
     e_job_type nvarchar(30) NOT NULL,
     e_job_status nvarchar(30) NOT NULL,
     d_time_started datetime NOT NULL,
     d_time_finished datetime NULL,
     d_results_viewed datetime NULL,
     i_session_id int NOT NULL,
     c_user_name nvarchar(255) NOT NULL,
     c_machine_name nvarchar(255) NOT NULL,
     i_process_id int NOT NULL,
     i_thread_id int NOT NULL,
     i_percent_complete int NULL,
     c_progress_message nvarchar(2000) NULL,
     c_originating_object_name nvarchar(255) NULL,
     m_originating_object image NULL,
     c_exception_message nvarchar(2000) NULL,
     d_results_purged datetime NULL,
     c_purge_reason nvarchar(2000) NULL,
     c_version_from nvarchar(255) NULL,
     c_version_to nvarchar(255) NULL,
     i_results_size int NULL,
     b_cancellable bit NULL,
     b_user_notified bit NULL
   );

CREATE TABLE dbo.RM_Job_History_Result
   (
     i_job_id int NOT NULL,
     i_detail_id int NOT NULL,
     c_description nvarchar(255) NULL,
     m_job_result image NULL
   );

CREATE TABLE dbo.RM_Merge_Log
   (
     i_merge_log_id int NOT NULL,
     i_version_id int NOT NULL,
     i_node_id int NOT NULL,
     d_time datetime NULL,
     c_version nvarchar(255) NULL,
     c_user_name nvarchar(100) NOT NULL,
     e_merge_action nvarchar(60) NOT NULL,
     i_deleted_id int NULL,
     c_deleted_abbrev nvarchar(255) NULL,
     c_deleted_descr nvarchar(255) NULL,
     i_merged_id int NULL,
     c_merged_abbrev nvarchar(255) NULL,
     c_merged_descr nvarchar(255) NULL,
     i_delete_log_id int NULL
   );

CREATE TABLE dbo.RM_Node
   (
     i_version_id int NOT NULL,
     i_node_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_descr nvarchar(255) NULL,
     b_leaf bit NOT NULL,
     b_inactive bit NOT NULL,
     b_approved bit NOT NULL,
     c_added_by nvarchar(100) NULL,
     d_added_on datetime NULL,
     c_changed_by nvarchar(100) NULL,
     d_changed_on datetime NULL,
     b_node_changed bit NULL,
     i_domain_id int NULL
   );

CREATE TABLE dbo.RM_Node_Merge
   (
     i_version_id int NOT NULL,
     i_node_id int NOT NULL,
     i_merge_id int NOT NULL,
     i_merge_log_id int NULL
   );

CREATE TABLE dbo.RM_Node_Prop_Global
   (
     i_version_id int NOT NULL,
     i_node_id int NOT NULL,
     i_property_id int NOT NULL,
     x_value ntext NULL,
     b_locked bit NOT NULL
   );

CREATE TABLE dbo.RM_Node_Prop_Local
   (
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL,
     i_node_id int NOT NULL,
     i_property_id int NOT NULL,
     x_value ntext NULL,
     b_locked bit NOT NULL
   );

CREATE TABLE dbo.RM_Node_Type
   (
     i_node_type_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     i_glyph_id int NULL,
     c_descr nvarchar(2000) NULL
   );

CREATE TABLE dbo.RM_Node_Type_Property
   (
     i_node_type_id int NOT NULL,
     i_property_id int NOT NULL
   );

CREATE TABLE dbo.RM_Node_Type_Validation
   (
     i_node_type_id int NOT NULL,
     i_validation_id int NOT NULL
   );

CREATE TABLE dbo.RM_Notification
   (
     i_notification_id int NOT NULL,
     i_user_id int NOT NULL,
     e_notification_method nvarchar(30) NOT NULL,
     d_created datetime NOT NULL,
     x_subject ntext NULL,
     d_alert_fetched datetime NULL,
     d_email_next_try datetime NULL,
     c_last_bounce_reason nvarchar(2000) NULL,
     i_email_send_failures int NULL,
     d_email_sent datetime NULL,
     b_from_previous_session bit NULL,
     c_object_class nvarchar(255) NOT NULL,
     i_object_id int NULL
   );

CREATE TABLE dbo.RM_Notification_Detail
   (
     i_notification_id int NOT NULL,
     m_message image NULL
   );

CREATE TABLE dbo.RM_Object_Access_Group
   (
     i_access_group_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_label nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     b_user_defined bit NOT NULL
   );

CREATE TABLE dbo.RM_Object_Access_Group_Nag
   (
     i_access_group_id int NOT NULL,
     i_security_id int NOT NULL,
     e_object_access_level nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Object_Access_Group_User
   (
     i_access_group_id int NOT NULL,
     i_user_id int NOT NULL,
     e_object_access_level nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Property_Category
   (
     i_property_id int NOT NULL,
     i_category_id int NOT NULL,
     i_order int NULL
   );

CREATE TABLE dbo.RM_Property_Constraint
   (
     i_property_id int NOT NULL,
     c_constraint_name nvarchar(50) NOT NULL,
     c_key nvarchar(50) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Property_Ctrl_Hier
   (
     i_property_id int NOT NULL,
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL
   );

CREATE TABLE dbo.RM_Property_Definition
   (
     i_property_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     e_prop_type nvarchar(30) NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_default_value nvarchar(255) NULL,
     c_min_value nvarchar(255) NULL,
     c_max_value nvarchar(255) NULL,
     c_label nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     b_global bit NOT NULL,
     b_list bit NOT NULL,
     b_cascade bit NOT NULL,
     b_hidden bit NOT NULL,
     i_lookup_id int NULL,
     i_column_width int NOT NULL,
     c_deriver_class nvarchar(20) NULL,
     e_prop_level nvarchar(30) NOT NULL,
     i_assigned_domain_id int NULL,
     b_indexed bit NULL,
     i_connection_id int NULL,
     i_operation_id int NULL,
     c_key_column_name nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Property_External_Col_Map
   (
     i_property_id int NOT NULL,
     i_target_property_id int NOT NULL,
     c_column_name nvarchar(128) NOT NULL
   );

CREATE TABLE dbo.RM_Property_External_Param_Map
   (
     i_property_id int NOT NULL,
     c_parameter_name nvarchar(128) NOT NULL,
     e_parameter_source nvarchar(30) NOT NULL,
     x_parameter_value ntext NULL
   );

CREATE TABLE dbo.RM_Property_List
   (
     i_property_id int NOT NULL,
     i_order int NOT NULL,
     c_value nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Property_Lookup
   (
     i_property_id int NOT NULL,
     c_lookup_value nvarchar(255) NOT NULL,
     c_result_value nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Property_Param
   (
     i_property_id int NOT NULL,
     i_param_id int NOT NULL,
     c_label nvarchar(40) NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_descr nvarchar(255) NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Property_Query
   (
     i_query_id int NOT NULL,
     i_user_id int NOT NULL,
     c_hier_abbrev nvarchar(255) NULL,
     c_node_abbrev nvarchar(255) NULL,
     b_expand_list bit NOT NULL,
     b_inclusive bit NOT NULL,
     b_expand_marks bit NOT NULL,
     c_query_abbrev nvarchar(255) NULL,
     c_query_descr nvarchar(2000) NULL,
     b_user_defined bit NOT NULL,
     b_global_query bit NOT NULL,
     b_include_filter bit NOT NULL,
     b_display_criteria bit NOT NULL,
     e_as_of_method nvarchar(30) NOT NULL,
     d_asof_datetime datetime NULL,
     i_asof_offset_days int NULL,
     i_asof_id int NULL,
     e_version_type_param nvarchar(30) NOT NULL,
     b_show_list bit NOT NULL,
     b_mark_nodes bit NOT NULL,
     b_include_parents bit NOT NULL,
     b_include_children bit NOT NULL,
     i_asof_offset_time int NOT NULL,
     c_version_abbrev nvarchar(255) NULL,
     i_access_group_id int NOT NULL
   );

CREATE TABLE dbo.RM_Query_Criteria
   (
     i_query_id int NOT NULL,
     i_criteria_id int NOT NULL,
     e_comparison_operator nvarchar(30) NOT NULL,
     c_property_abbrev nvarchar(255) NOT NULL,
     b_incl_inherited bit NOT NULL,
     c_value nvarchar(255) NULL,
     e_join_operator nvarchar(30) NOT NULL,
     i_open_parens int NULL,
     i_close_parens int NULL
   );

CREATE TABLE dbo.RM_Query_Default_Param
   (
     i_query_id int NOT NULL,
     c_parameter nvarchar(40) NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Relationship
   (
     i_version_id int NOT NULL,
     i_parent_id int NOT NULL,
     i_child_id int NOT NULL
   );

CREATE TABLE dbo.RM_Request
   (
     i_request_id int NOT NULL,
     c_version_abbrev nvarchar(255) NULL,
     c_owned_by nvarchar(255) NULL,
     b_approved bit NOT NULL,
     b_validated bit NOT NULL,
     c_created_by nvarchar(255) NULL,
     c_updated_by nvarchar(255) NULL,
     c_approved_by nvarchar(255) NULL,
     d_created_on datetime NULL,
     d_updated_on datetime NULL,
     d_approved_on datetime NULL,
     c_committed_by nvarchar(255) NULL,
     c_external_id nvarchar(255) NULL,
     c_external_label nvarchar(255) NULL,
     c_external_status nvarchar(255) NULL,
     x_workflow_info ntext NULL,
     x_comment ntext NULL
   );

CREATE TABLE dbo.RM_Request_Item
   (
     i_request_id int NOT NULL,
     i_request_item_id int NOT NULL,
     c_action nvarchar(255) NOT NULL,
     c_hier_abbrev nvarchar(255) NULL,
     c_node_abbrev nvarchar(255) NULL,
     m_request_item_data image NULL
   );

CREATE TABLE dbo.RM_Request_Verification
   (
     i_request_id int NOT NULL,
     i_sequence int NOT NULL,
     c_verification_abbrev nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Role
   (
     i_role_id int NOT NULL,
     c_role_name nvarchar(30) NOT NULL,
     e_role_type nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Role_Permission
   (
     i_role_id int NOT NULL,
     e_permission nvarchar(50) NOT NULL
   );

CREATE TABLE dbo.RM_Scheduled_Tasks
   (
     i_task_id int NOT NULL,
     c_task_name nvarchar(40) NOT NULL,
     c_description nvarchar(255) NOT NULL,
     d_last_run datetime NULL,
     d_next_run datetime NULL,
     c_last_duration nvarchar(20) NULL,
     i_interval int NOT NULL,
     e_interval_units nvarchar(30) NOT NULL,
     d_next_blackout datetime NULL,
     i_blackout_duration int NULL,
     c_last_status nvarchar(80) NULL,
     c_notes nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Session_Info
   (
     i_session_id int NOT NULL,
     i_user_id int NOT NULL,
     i_session_logon_id int NOT NULL,
     b_prompt_to_change_password bit NOT NULL,
     i_days_of_grace_left int NOT NULL,
     b_must_change_password bit NOT NULL,
     c_error_code nvarchar(255) NULL,
     c_error_description nvarchar(255) NULL,
     d_logon_time datetime NOT NULL,
     d_last_accessed datetime NOT NULL,
     x_session_parameters ntext NULL
   );

CREATE TABLE dbo.RM_System_Preference
   (
     c_keyword nvarchar(40) NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_value nvarchar(2000) NULL,
     c_min_value nvarchar(255) NULL,
     c_max_value nvarchar(255) NULL,
     c_label nvarchar(255) NULL,
     c_descr nvarchar(255) NULL,
     c_allowed_values nvarchar(255) NULL,
     b_list bit NULL,
     b_requires_restart bit NULL,
     b_hidden bit NULL
   );

CREATE TABLE dbo.RM_Transaction_History
   (
     i_transaction_id int NOT NULL,
     i_detail_id int NOT NULL,
     d_timestamp datetime NULL,
     i_session_id int NULL,
     c_user_name nvarchar(100) NOT NULL,
     c_action nvarchar(40) NULL,
     c_action_level nvarchar(40) NULL,
     c_version_abbrev nvarchar(255) NULL,
     i_version_id int NULL,
     c_hierarchy_abbrev nvarchar(255) NULL,
     i_hierarchy_id int NULL,
     c_node_abbrev nvarchar(255) NULL,
     i_node_id int NULL,
     c_node_descr nvarchar(255) NULL,
     c_property_abbrev nvarchar(255) NULL,
     i_property_id int NULL,
     b_leaf bit NOT NULL,
     c_action_description nvarchar(1024) NULL,
     x_from_value ntext NULL,
     c_from_origin nvarchar(1024) NULL,
     x_to_value ntext NULL,
     c_to_origin nvarchar(1024) NULL,
     i_originating_id int NULL,
     i_originating_detail_id int NULL,
     c_object_name nvarchar(255) NULL,
     i_domain_id int NULL,
     c_domain_abbrev nvarchar(255) NULL,
     i_workflow_request_id int NULL,
     i_workflow_request_item_id int NULL,
     c_node_type nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_User
   (
     i_user_id int NOT NULL,
     c_user_name nvarchar(100) NOT NULL,
     c_full_name nvarchar(255) NULL,
     c_department nvarchar(40) NULL,
     c_phone_number nvarchar(20) NULL,
     c_password nvarchar(255) NULL,
     d_password_expire_date datetime NULL,
     e_user_auth_method nvarchar(20) NOT NULL,
     i_invalid_login_count int NOT NULL,
     d_last_valid_login datetime NULL,
     b_login_lockout bit NOT NULL,
     c_login_lockout_reason nvarchar(100) NULL,
     d_login_lockout_timestamp datetime NULL,
     b_change_pass_on_login bit NOT NULL,
     b_current_enc bit NULL,
     b_exclude_from_timeout bit NULL,
     b_no_password_expiration bit NULL,
     b_exclude_from_lockout bit NULL,
     c_email_address nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_User_Prop_Hierarchy
   (
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL,
     i_user_id int NOT NULL,
     i_property_id int NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_User_Prop_Version
   (
     i_version_id int NOT NULL,
     i_user_id int NOT NULL,
     i_property_id int NOT NULL,
     c_value nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_User_Property_Definition
   (
     i_user_property_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_default_value nvarchar(255) NULL,
     c_min_value nvarchar(255) NULL,
     c_max_value nvarchar(255) NULL,
     c_label nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     b_hidden bit NOT NULL,
     i_column_width int NOT NULL,
     i_order int NULL,
     e_prop_level nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_User_Role
   (
     i_user_id int NOT NULL,
     i_role_id int NOT NULL
   );

CREATE TABLE dbo.RM_Validation_Definition
   (
     i_validation_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_label nvarchar(255) NOT NULL,
     c_descr nvarchar(2000) NULL,
     b_cascade bit NOT NULL,
     e_validation_level nvarchar(30) NOT NULL,
     e_validation_type__default nvarchar(30) NOT NULL,
     c_class nvarchar(20) NOT NULL,
     i_column_width int NOT NULL,
     i_order int NULL,
     e_validation_type__allowed nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Validation_Definition_Templ
   (
     i_valid_def_templ_id int NOT NULL,
     c_label nvarchar(16) NOT NULL,
     c_descr nvarchar(2000) NULL,
     b_cascade bit NOT NULL,
     e_validation_level nvarchar(30) NOT NULL,
     e_validation_type__default nvarchar(30) NOT NULL,
     c_class nvarchar(20) NOT NULL,
     i_column_width int NOT NULL,
     i_order int NULL,
     e_validation_type__allowed nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_Validation_Param
   (
     i_validation_id int NOT NULL,
     i_parameter_id int NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_label nvarchar(16) NOT NULL,
     c_descr nvarchar(255) NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Validation_Param_Templ
   (
     i_valid_def_templ_id int NOT NULL,
     i_parameter_id int NOT NULL,
     e_data_type nvarchar(30) NOT NULL,
     c_label nvarchar(16) NOT NULL,
     c_descr nvarchar(255) NULL,
     c_value nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_Validation_Prop_Hierarchy
   (
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL,
     i_validation_id int NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Validation_Prop_Node
   (
     i_version_id int NOT NULL,
     i_hierarchy_id int NOT NULL,
     i_node_id int NOT NULL,
     i_validation_id int NOT NULL,
     x_value ntext NULL,
     b_locked bit NOT NULL
   );

CREATE TABLE dbo.RM_Validation_Prop_Version
   (
     i_version_id int NOT NULL,
     i_validation_id int NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_Version
   (
     i_version_id int NOT NULL,
     c_abbrev nvarchar(300) NOT NULL,
     c_descr nvarchar(300) NULL,
     e_version_status nvarchar(20) NOT NULL,
     e_version_type nvarchar(30) NOT NULL,
     i_baseline_reference_id int NULL,
     i_legacy_id int NULL,
     b_exact_copy bit NOT NULL,
     d_legacy_copy_timestamp datetime NULL,
     b_dirty_transactions bit NOT NULL,
     i_user_id int NULL,
     b_partially_saved bit NULL,
     i_access_group_id int NULL,
     c_legacy_abbrev nvarchar(300) NULL,
     i_lineage_id int NULL,
     i_node_count int NOT NULL,
     i_limb_count int NOT NULL,
     i_leaf_count int NOT NULL,
     i_primary_count int NOT NULL,
     i_shared_count int NOT NULL,
     i_orphan_count int NOT NULL,
     b_full_count_flag bit NOT NULL,
     d_count_update_timestamp datetime NULL
   );

CREATE TABLE dbo.RM_Version_Prop
   (
     i_version_id int NOT NULL,
     i_property_id int NOT NULL,
     x_value ntext NULL
   );

CREATE TABLE dbo.RM_WF_Model
   (
     i_model_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_label nvarchar(255) NOT NULL,
     c_description nvarchar(2000) NULL,
     i_request_duration int NULL,
     i_claim_duration int NULL,
     c_version_variable nvarchar(255) NULL,
     c_hierarchy_group_prop nvarchar(255) NULL,
     c_hierarchy_group nvarchar(255) NULL,
     b_hidden bit NULL
   );

CREATE TABLE dbo.RM_WF_Model_Filter_NodeType
   (
     i_model_id int NOT NULL,
     i_filter_nodetype_id int NOT NULL,
     c_node_type nvarchar(255) NOT NULL
   );

CREATE TABLE dbo.RM_WF_Model_Stage
   (
     i_model_id int NOT NULL,
     e_workflow_stage_type nvarchar(30) NOT NULL,
     i_stage_id int NOT NULL,
     c_label nvarchar(255) NOT NULL,
     e_approval_method nvarchar(30) NOT NULL,
     e_approval_sequence nvarchar(30) NOT NULL,
     e_reapproval_method nvarchar(30) NOT NULL,
     e_notification_group nvarchar(30) NOT NULL,
     e_inclusion_method nvarchar(30) NOT NULL,
     e_condition_action nvarchar(30) NOT NULL,
     i_inclusion_query_id int NULL,
     b_separation_of_duties bit NULL,
     b_recalculate bit NULL
   );

CREATE TABLE dbo.RM_WF_Model_Stage_Assg_Group
   (
     i_model_id int NOT NULL,
     i_stage_id int NOT NULL,
     i_group_id int NOT NULL,
     c_assigned_group nvarchar(255) NOT NULL
   );

CREATE TABLE dbo.RM_WF_Model_Stage_Task
   (
     i_model_id int NOT NULL,
     i_stage_id int NOT NULL,
     i_task_id int NOT NULL,
     i_primary_task_id int NULL,
     b_hidden bit NULL,
     i_sort_order int NULL
   );

CREATE TABLE dbo.RM_WF_Model_Stage_Validation
   (
     i_model_id int NOT NULL,
     i_stage_id int NOT NULL,
     i_validation_id int NOT NULL
   );

CREATE TABLE dbo.RM_WF_Request
   (
     i_workflow_request_id int NOT NULL,
     i_model_id int NOT NULL,
     c_title nvarchar(255) NOT NULL,
     i_version_id int NOT NULL,
     c_created_by nvarchar(255) NOT NULL,
     d_created_on datetime NOT NULL,
     d_submitted_on datetime NULL,
     b_overdue bit NULL,
     b_escalated bit NULL,
     e_workflow_status__current nvarchar(30) NOT NULL,
     e_workflow_status__requested nvarchar(30) NOT NULL,
     c_current_claimed_by nvarchar(255) NULL,
     d_current_claimed_on datetime NULL,
     i_current_stage_id int NULL,
     d_expedited datetime NULL,
     c_status_requested_by nvarchar(255) NULL,
     c_status_requested_param nvarchar(255) NULL,
     e_validation_run_status nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_WF_Request_Activity
   (
     i_activity_id int NOT NULL,
     i_workflow_request_id int NOT NULL,
     d_timestamp datetime NOT NULL,
     c_user_name nvarchar(255) NULL,
     e_workflow_activity nvarchar(30) NOT NULL,
     c_stage_name nvarchar(255) NULL,
     e_workflow_status__from nvarchar(30) NOT NULL,
     e_workflow_status__to nvarchar(30) NOT NULL,
     x_from_assigned_to ntext NULL,
     x_to_assigned_to ntext NULL,
     x_details ntext NOT NULL,
     b_system_activity bit NOT NULL,
     i_message_number int NULL,
     x_message_params ntext NULL
   );

CREATE TABLE dbo.RM_WF_Request_Assigned_To
   (
     i_workflow_request_id int NOT NULL,
     e_security_principal_type nvarchar(30) NOT NULL,
     c_name nvarchar(255) NOT NULL,
     i_id int NULL,
     d_assigned datetime NOT NULL
   );

CREATE TABLE dbo.RM_WF_Request_Attachment
   (
     i_workflow_request_id int NOT NULL,
     i_attachment_id int NOT NULL,
     c_filename nvarchar(255) NULL,
     c_content_type nvarchar(255) NULL,
     i_content_length int NULL,
     c_description nvarchar(255) NULL,
     c_created_by nvarchar(255) NOT NULL,
     d_created_on datetime NOT NULL,
     m_file_contents image NULL
   );

CREATE TABLE dbo.RM_WF_Request_Item
   (
     i_workflow_request_id int NOT NULL,
     i_workflow_request_item_id int NOT NULL,
     e_workflow_action__originating nvarchar(30) NOT NULL,
     i_stage_id int NOT NULL,
     i_task_id int NOT NULL,
     c_node_name nvarchar(255) NULL,
     c_node_descr nvarchar(255) NULL,
     c_parent_node_name nvarchar(255) NULL,
     c_hierarchy_name nvarchar(255) NULL,
     b_has_any_validation_failure bit NULL,
     b_has_prop_validation_failure bit NULL,
     b_has_node_validation_failure bit NULL,
     c_validation_failure_reason nvarchar(255) NULL,
     c_last_modified_by nvarchar(255) NULL,
     d_last_modified_on datetime NULL,
     b_initial_approval bit NULL,
     b_enriched_item bit NULL,
     i_dependent_group_id int NULL,
     b_is_primary bit NULL,
     i_calc_group_id int NULL
   );

CREATE TABLE dbo.RM_WF_Request_Item_Fail
   (
     i_workflow_request_id int NOT NULL,
     i_workflow_request_item_id int NOT NULL,
     i_workflow_req_item_fail_id int NOT NULL,
     e_failure_type nvarchar(30) NOT NULL,
     c_property_name nvarchar(255) NULL,
     x_validation_failure_reason ntext NULL,
     i_message_number int NULL,
     x_message_params ntext NULL
   );

CREATE TABLE dbo.RM_WF_Request_Item_PropVal
   (
     i_workflow_request_id int NOT NULL,
     i_workflow_request_item_id int NOT NULL,
     i_workflow_req_item_prop_id int NOT NULL,
     c_prop_name nvarchar(255) NOT NULL,
     x_new_value ntext NULL,
     b_has_new_value bit NULL,
     b_has_calc_value bit NULL,
     b_cannot_calculate bit NULL,
     x_calculated_value ntext NULL,
     c_last_modified_by nvarchar(255) NULL,
     d_last_modified_on datetime NULL,
     b_has_validation_failure bit NULL,
     i_last_updated_stage_id int NULL,
     i_last_updated_task_id int NULL,
     b_value_generated bit NULL
   );

CREATE TABLE dbo.RM_WF_Request_Stage
   (
     i_workflow_request_id int NOT NULL,
     i_stage_id int NOT NULL,
     i_model_stage_id int NOT NULL,
     c_model_stage_class nvarchar(255) NOT NULL,
     b_has_full_approval bit NULL,
     d_started_on datetime NULL,
     i_total_approvals_needed int NULL,
     e_stage_processing nvarchar(30) NOT NULL
   );

CREATE TABLE dbo.RM_WF_Request_Stage_Appr_Group
   (
     i_workflow_request_id int NOT NULL,
     i_stage_id int NOT NULL,
     i_stage_approval_id int NOT NULL,
     i_stage_approval_group_id int NOT NULL,
     c_approval_group nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_WF_Request_Stage_Approval
   (
     i_workflow_request_id int NOT NULL,
     i_stage_id int NOT NULL,
     i_stage_approval_id int NOT NULL,
     c_approved_by nvarchar(255) NOT NULL,
     d_approved_on datetime NOT NULL
   );

CREATE TABLE dbo.RM_WF_Request_Stage_Enriched
   (
     i_workflow_request_id int NOT NULL,
     i_stage_id int NOT NULL,
     i_stage_enrich_item_id int NOT NULL,
     i_item_id int NOT NULL
   );

CREATE TABLE dbo.RM_WF_Request_Tag
   (
     i_workflow_request_id int NOT NULL,
     c_name nvarchar(255) NOT NULL,
     c_value nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_WF_Task
   (
     i_task_id int NOT NULL,
     c_abbrev nvarchar(255) NOT NULL,
     c_label nvarchar(255) NOT NULL,
     c_instructions nvarchar(2000) NULL,
     e_workflow_action nvarchar(30) NOT NULL,
     c_hierarchy_group_filter nvarchar(255) NULL,
     c_domain_abbrev nvarchar(255) NULL
   );

CREATE TABLE dbo.RM_WF_Task_Commit_Op_Param
   (
     i_task_id int NOT NULL,
     i_commit_operation_id int NOT NULL,
     c_parameter_name nvarchar(128) NOT NULL,
     e_parameter_source nvarchar(30) NOT NULL,
     x_parameter_value ntext NULL
   );

CREATE TABLE dbo.RM_WF_Task_Commit_Operation
   (
     i_task_id int NOT NULL,
     i_commit_operation_id int NOT NULL,
     i_connection_id int NOT NULL,
     i_operation_id int NOT NULL,
     i_status_property_id int NULL
   );

CREATE TABLE dbo.RM_WF_Task_Property
   (
     i_task_id int NOT NULL,
     i_task_property_id int NOT NULL,
     c_prop_name nvarchar(255) NOT NULL,
     b_editable bit NOT NULL,
     b_required bit NOT NULL,
     c_instructions nvarchar(2000) NULL,
     c_label nvarchar(2000) NULL,
     b_calculated bit NULL,
     b_hidden bit NULL,
     x_script ntext NULL,
     i_script_timeout int NULL
   );

CREATE TABLE dbo.RM_WF_Task_Validation
   (
     i_task_id int NOT NULL,
     i_task_validation_id int NOT NULL,
     i_validation_id int NOT NULL
   );

CREATE TABLE dbo.RM_WF_Task_Validation_Property
   (
     i_task_id int NOT NULL,
     i_task_validation_id int NOT NULL,
     i_task_validation_prop_id int NOT NULL,
     c_property_name nvarchar(255) NOT NULL
   );

/* Indexes for RM_Access_Group_Ctrl_Hier */
CREATE INDEX IxRmAccessGroupCtrlHier1 ON dbo.RM_Access_Group_Ctrl_Hier
    (
     i_security_id ASC
    );


CREATE INDEX IxRmAccessGroupCtrlHier2 ON dbo.RM_Access_Group_Ctrl_Hier
    (
     i_version_id ASC
    );


CREATE INDEX IxRmAccessGroupCtrlHier3 ON dbo.RM_Access_Group_Ctrl_Hier
    (
     i_version_id ASC,
     i_hierarchy_id ASC
    );

/* Indexes for RM_Access_Group_Definition */
CREATE UNIQUE INDEX IxRmAccessGroupDefinition1 ON dbo.RM_Access_Group_Definition
    (
     c_abbrev ASC
    );

/* Indexes for RM_Access_Group_Prop_Global */
CREATE INDEX IxRmAccessGroupPropGlobal1 ON dbo.RM_Access_Group_Prop_Global
    (
     i_security_id ASC
    );


CREATE INDEX IxRmAccessGroupPropGlobal2 ON dbo.RM_Access_Group_Prop_Global
    (
     i_version_id ASC,
     i_node_id ASC
    );

/* Indexes for RM_Access_Group_Prop_Local */
CREATE INDEX IxRmAccessGroupPropLocal1 ON dbo.RM_Access_Group_Prop_Local
    (
     i_version_id ASC,
     i_node_id ASC
    );


CREATE INDEX IxRmAccessGroupPropLocal2 ON dbo.RM_Access_Group_Prop_Local
    (
     i_security_id ASC
    );

/* Indexes for RM_Access_Group_User */
CREATE INDEX IxRmAccessGroupUser1 ON dbo.RM_Access_Group_User
    (
     i_security_id ASC
    );


CREATE INDEX IxRmAccessGroupUser2 ON dbo.RM_Access_Group_User
    (
     i_user_id ASC
    );

/* Indexes for RM_Blender */
CREATE UNIQUE INDEX IxRmBlender1 ON dbo.RM_Blender
    (
     i_access_group_id ASC,
     c_abbrev ASC
    );


CREATE INDEX IxRmBlender2 ON dbo.RM_Blender
    (
     i_access_group_id ASC
    );

/* Indexes for RM_Blender_Default_Param */
CREATE INDEX IxRmBlenderDefaultParam1 ON dbo.RM_Blender_Default_Param
    (
     i_blender_id ASC
    );

/* Indexes for RM_Blender_Hierarchy_Set */
CREATE INDEX IxRmBlenderHierarchySet1 ON dbo.RM_Blender_Hierarchy_Set
    (
     i_blender_id ASC,
     i_blender_property_list_id ASC
    );


CREATE INDEX IxRmBlenderHierarchySet2 ON dbo.RM_Blender_Hierarchy_Set
    (
     i_blender_id ASC
    );

/* Indexes for RM_Blender_Property_List */
CREATE INDEX IxRmBlenderPropertyList1 ON dbo.RM_Blender_Property_List
    (
     i_blender_id ASC
    );

/* Indexes for RM_Blender_Property_List_Item */
CREATE INDEX IxRmBlenderPropertyListItem1 ON dbo.RM_Blender_Property_List_Item
    (
     i_blender_id ASC,
     i_blender_property_list_id ASC
    );

/* Indexes for RM_Book */
CREATE UNIQUE INDEX IxRmBook1 ON dbo.RM_Book
    (
     i_access_group_id ASC,
     c_book_name ASC
    );


CREATE INDEX IxRmBook2 ON dbo.RM_Book
    (
     i_access_group_id ASC
    );

/* Indexes for RM_Book_Default_Param */
CREATE INDEX IxRmBookDefaultParam1 ON dbo.RM_Book_Default_Param
    (
     i_book_id ASC
    );

/* Indexes for RM_Book_Item */
CREATE INDEX IxRmBookItem1 ON dbo.RM_Book_Item
    (
     i_book_id ASC
    );


CREATE INDEX IxRmBookItem2 ON dbo.RM_Book_Item
    (
     i_export_id ASC
    );

/* Indexes for RM_Category */
CREATE UNIQUE INDEX IxRmCategory1 ON dbo.RM_Category
    (
     c_category_code ASC
    );

/* Indexes for RM_Category_User */
CREATE INDEX IxRmCategoryUser1 ON dbo.RM_Category_User
    (
     i_user_id ASC
    );


CREATE INDEX IxRmCategoryUser2 ON dbo.RM_Category_User
    (
     i_category_id ASC
    );

/* Indexes for RM_Compare */
CREATE INDEX IxRmCompare1 ON dbo.RM_Compare
    (
     i_query_id ASC
    );


CREATE INDEX IxRmCompare2 ON dbo.RM_Compare
    (
     e_comparison_type ASC
    );


CREATE UNIQUE INDEX IxRmCompare3 ON dbo.RM_Compare
    (
     i_access_group_id ASC,
     c_compare_abbrev ASC
    );

/* Indexes for RM_Compare_Default_Param */
CREATE INDEX IxRmCompareDefaultParam1 ON dbo.RM_Compare_Default_Param
    (
     i_compare_id ASC
    );

/* Indexes for RM_Compare_Item */
CREATE INDEX IxRmCompareItem1 ON dbo.RM_Compare_Item
    (
     i_compare_id ASC
    );

/* Indexes for RM_Connection */
CREATE UNIQUE INDEX IxRmConnection1 ON dbo.RM_Connection
    (
     c_name ASC
    );


CREATE UNIQUE INDEX IxRmConnection2 ON dbo.RM_Connection
    (
     i_access_group_id ASC,
     c_name ASC
    );

/* Indexes for RM_Connection_Operation */
CREATE UNIQUE INDEX IxRmConnectionOperation1 ON dbo.RM_Connection_Operation
    (
     i_connection_id ASC,
     i_operation_id ASC
    );

/* Indexes for RM_Derived_Property */
CREATE INDEX IxRmDerivedProperty1 ON dbo.RM_Derived_Property
    (
     e_data_type ASC
    );

/* Indexes for RM_Derived_Property_Param */
CREATE INDEX IxRmDerivedPropertyParam1 ON dbo.RM_Derived_Property_Param
    (
     c_deriver_class ASC
    );


CREATE INDEX IxRmDerivedPropertyParam2 ON dbo.RM_Derived_Property_Param
    (
     e_data_type ASC
    );

/* Indexes for RM_Domain */
CREATE UNIQUE INDEX IxRmDomain1 ON dbo.RM_Domain
    (
     c_abbrev ASC
    );

/* Indexes for RM_Domain_Node */
CREATE UNIQUE INDEX IxRmDomainNode1 ON dbo.RM_Domain_Node
    (
     i_domain_id ASC,
     c_domain_node_abbrev ASC
    );


CREATE INDEX IxRmDomainNode2 ON dbo.RM_Domain_Node
    (
     i_update_id ASC
    );

/* Indexes for RM_Export */
CREATE INDEX IxRmExport1 ON dbo.RM_Export
    (
     i_validation_id ASC
    );


CREATE UNIQUE INDEX IxRmExport2 ON dbo.RM_Export
    (
     i_access_group_id ASC,
     c_export_abbrev ASC
    );


CREATE INDEX IxRmExport3 ON dbo.RM_Export
    (
     i_export_type_id ASC
    );


CREATE INDEX IxRmExport4 ON dbo.RM_Export
    (
     e_export_output_mode ASC
    );


CREATE INDEX IxRmExport5 ON dbo.RM_Export
    (
     i_query_id ASC
    );


CREATE INDEX IxRmExport6 ON dbo.RM_Export
    (
     i_access_group_id ASC
    );

/* Indexes for RM_Export_Column */
CREATE INDEX IxRmExportColumn1 ON dbo.RM_Export_Column
    (
     i_export_id ASC
    );


CREATE INDEX IxRmExportColumn2 ON dbo.RM_Export_Column
    (
     c_column_class ASC
    );

/* Indexes for RM_Export_Default_Param */
CREATE INDEX IxRmExportDefaultParam1 ON dbo.RM_Export_Default_Param
    (
     i_export_id ASC
    );

/* Indexes for RM_Export_Node */
CREATE INDEX IxRmExportNode1 ON dbo.RM_Export_Node
    (
     i_export_id ASC
    );

/* Indexes for RM_Export_Node_Prop */
CREATE INDEX IxRmExportNodeProp1 ON dbo.RM_Export_Node_Prop
    (
     i_export_id ASC,
     i_export_node_id ASC
    );

/* Indexes for RM_Export_Param */
CREATE INDEX IxRmExportParam1 ON dbo.RM_Export_Param
    (
     i_export_id ASC
    );

/* Indexes for RM_Export_Type */
CREATE UNIQUE INDEX IxRmExportType1 ON dbo.RM_Export_Type
    (
     c_export_class ASC
    );

/* Indexes for RM_Glyph */
CREATE UNIQUE INDEX IxRmGlyph1 ON dbo.RM_Glyph
    (
     c_abbrev ASC
    );

/* Indexes for RM_Hierarchy */
CREATE UNIQUE INDEX IxRmHierarchy1 ON dbo.RM_Hierarchy
    (
     i_version_id ASC,
     c_abbrev ASC
    );


CREATE INDEX IxRmHierarchy2 ON dbo.RM_Hierarchy
    (
     i_hierarchy_group_id ASC
    );


CREATE INDEX IxRmHierarchy3 ON dbo.RM_Hierarchy
    (
     i_version_id ASC
    );

/* Indexes for RM_Hierarchy_Group */
CREATE UNIQUE INDEX IxRmHierarchyGroup1 ON dbo.RM_Hierarchy_Group
    (
     c_name ASC
    );

/* Indexes for RM_Hierarchy_Prop */
CREATE INDEX IxRmHierarchyProp1 ON dbo.RM_Hierarchy_Prop
    (
     i_version_id ASC,
     i_hierarchy_id ASC
    );


CREATE INDEX IxRmHierarchyProp2 ON dbo.RM_Hierarchy_Prop
    (
     i_property_id ASC
    );

/* Indexes for RM_Import */
CREATE INDEX IxRmImport1 ON dbo.RM_Import
    (
     i_import_type_id ASC
    );


CREATE UNIQUE INDEX IxRmImport2 ON dbo.RM_Import
    (
     i_access_group_id ASC,
     c_import_abbrev ASC
    );


CREATE INDEX IxRmImport3 ON dbo.RM_Import
    (
     i_access_group_id ASC
    );

/* Indexes for RM_Import_Default_Param */
CREATE INDEX IxRmImportDefaultParam1 ON dbo.RM_Import_Default_Param
    (
     i_import_id ASC
    );

/* Indexes for RM_Import_Param */
CREATE INDEX IxRmImportParam1 ON dbo.RM_Import_Param
    (
     i_import_id ASC
    );

/* Indexes for RM_Import_Section */
CREATE INDEX IxRmImportSection1 ON dbo.RM_Import_Section
    (
     i_import_id ASC
    );

/* Indexes for RM_Import_Section_Column */
CREATE INDEX IxRmImportSectionColumn1 ON dbo.RM_Import_Section_Column
    (
     i_import_id ASC,
     i_import_section_id ASC
    );

/* Indexes for RM_Import_Section_Column_Hier */
CREATE INDEX IxRmImportSectionColumnHier1 ON dbo.RM_Import_Section_Column_Hier
    (
     i_import_id ASC,
     i_import_section_id ASC,
     i_import_section_column_id ASC
    );

/* Indexes for RM_Import_Section_Column_Param */
CREATE INDEX IxRmImportSectionColumnParam1 ON dbo.RM_Import_Section_Column_Param
    (
     i_import_id ASC,
     i_import_section_id ASC,
     i_import_section_column_id ASC
    );

/* Indexes for RM_Import_Section_Param */
CREATE INDEX IxRmImportSectionParam1 ON dbo.RM_Import_Section_Param
    (
     i_import_id ASC,
     i_import_section_id ASC
    );

/* Indexes for RM_Node */
CREATE UNIQUE INDEX IxRmNode1 ON dbo.RM_Node
    (
     i_version_id ASC,
     c_abbrev ASC
    );


CREATE INDEX IxRmNode2 ON dbo.RM_Node
    (
     i_version_id ASC
    );

/* Indexes for RM_Node_Prop_Global */
CREATE INDEX IxRmNodePropGlobal1 ON dbo.RM_Node_Prop_Global
    (
     i_property_id ASC
    );

/* Indexes for RM_Node_Prop_Local */
CREATE INDEX IxRmNodePropLocal1 ON dbo.RM_Node_Prop_Local
    (
     i_property_id ASC
    );


CREATE INDEX IxRmNodePropLocal2 ON dbo.RM_Node_Prop_Local
    (
     i_version_id ASC,
     i_node_id ASC
    );

/* Indexes for RM_Node_Type */
CREATE INDEX IxRmNodeType1 ON dbo.RM_Node_Type
    (
     i_glyph_id ASC
    );


CREATE UNIQUE INDEX IxRmNodeType2 ON dbo.RM_Node_Type
    (
     c_abbrev ASC
    );

/* Indexes for RM_Node_Type_Property */
CREATE INDEX IxRmNodeTypeProperty1 ON dbo.RM_Node_Type_Property
    (
     i_node_type_id ASC
    );


CREATE INDEX IxRmNodeTypeProperty2 ON dbo.RM_Node_Type_Property
    (
     i_property_id ASC
    );

/* Indexes for RM_Node_Type_Validation */
CREATE INDEX IxRmNodeTypeValidation1 ON dbo.RM_Node_Type_Validation
    (
     i_node_type_id ASC
    );


CREATE INDEX IxRmNodeTypeValidation2 ON dbo.RM_Node_Type_Validation
    (
     i_validation_id ASC
    );

/* Indexes for RM_Notification */
CREATE INDEX IxRmNotification1 ON dbo.RM_Notification
    (
     i_user_id ASC
    );

/* Indexes for RM_Object_Access_Group */
CREATE UNIQUE INDEX IxRmObjectAccessGroup1 ON dbo.RM_Object_Access_Group
    (
     c_abbrev ASC
    );

/* Indexes for RM_Property_Category */
CREATE INDEX IxRmPropertyCategory1 ON dbo.RM_Property_Category
    (
     i_property_id ASC
    );


CREATE INDEX IxRmPropertyCategory2 ON dbo.RM_Property_Category
    (
     i_category_id ASC
    );

/* Indexes for RM_Property_Constraint */
CREATE INDEX IxRmPropertyConstraint1 ON dbo.RM_Property_Constraint
    (
     i_property_id ASC
    );

/* Indexes for RM_Property_Ctrl_Hier */
CREATE INDEX IxRmPropertyCtrlHier1 ON dbo.RM_Property_Ctrl_Hier
    (
     i_property_id ASC
    );


CREATE INDEX IxRmPropertyCtrlHier2 ON dbo.RM_Property_Ctrl_Hier
    (
     i_version_id ASC
    );


CREATE INDEX IxRmPropertyCtrlHier3 ON dbo.RM_Property_Ctrl_Hier
    (
     i_version_id ASC,
     i_hierarchy_id ASC
    );

/* Indexes for RM_Property_Definition */
CREATE UNIQUE INDEX IxRmPropertyDefinition1 ON dbo.RM_Property_Definition
    (
     c_abbrev ASC
    );


CREATE INDEX IxRmPropertyDefinition2 ON dbo.RM_Property_Definition
    (
     e_data_type ASC
    );


CREATE INDEX IxRmPropertyDefinition3 ON dbo.RM_Property_Definition
    (
     e_prop_type ASC
    );

/* Indexes for RM_Property_List */
CREATE INDEX IxRmPropertyList1 ON dbo.RM_Property_List
    (
     i_property_id ASC
    );

/* Indexes for RM_Property_Lookup */
CREATE INDEX IxRmPropertyLookup1 ON dbo.RM_Property_Lookup
    (
     i_property_id ASC
    );

/* Indexes for RM_Property_Param */
CREATE UNIQUE INDEX IxRmPropertyParam1 ON dbo.RM_Property_Param
    (
     i_property_id ASC,
     c_label ASC
    );


CREATE INDEX IxRmPropertyParam2 ON dbo.RM_Property_Param
    (
     i_property_id ASC
    );

/* Indexes for RM_Property_Query */
CREATE UNIQUE INDEX IxRmPropertyQuery1 ON dbo.RM_Property_Query
    (
     i_access_group_id ASC,
     c_query_abbrev ASC
    );


CREATE INDEX IxRmPropertyQuery2 ON dbo.RM_Property_Query
    (
     i_access_group_id ASC
    );

/* Indexes for RM_Query_Default_Param */
CREATE INDEX IxRmQueryDefaultParam1 ON dbo.RM_Query_Default_Param
    (
     i_query_id ASC
    );

/* Indexes for RM_Relationship */
CREATE INDEX IxRmRelationship1 ON dbo.RM_Relationship
    (
     i_version_id ASC,
     i_child_id ASC
    );

/* Indexes for RM_Role */
CREATE UNIQUE INDEX IxRmRole1 ON dbo.RM_Role
    (
     c_role_name ASC
    );

/* Indexes for RM_Scheduled_Tasks */
CREATE UNIQUE INDEX IxRmScheduledTasks1 ON dbo.RM_Scheduled_Tasks
    (
     c_task_name ASC
    );

/* Indexes for RM_System_Preference */
CREATE INDEX IxRmSystemPreference1 ON dbo.RM_System_Preference
    (
     e_data_type ASC
    );

/* Indexes for RM_Transaction_History */
CREATE INDEX IxRmTransactionHistory1 ON dbo.RM_Transaction_History
    (
     i_session_id ASC
    );


CREATE INDEX IxRmTransactionHistory2 ON dbo.RM_Transaction_History
    (
     c_version_abbrev ASC
    );


CREATE INDEX IxRmTransactionHistory3 ON dbo.RM_Transaction_History
    (
     i_version_id ASC
    );


CREATE INDEX IxRmTransactionHistory4 ON dbo.RM_Transaction_History
    (
     i_version_id ASC,
     i_hierarchy_id ASC,
     i_node_id ASC
    );


CREATE INDEX IxRmTransactionHistory5 ON dbo.RM_Transaction_History
    (
     i_node_id ASC
    );


CREATE INDEX IxRmTransactionHistory6 ON dbo.RM_Transaction_History
    (
     c_node_abbrev ASC
    );


CREATE INDEX IxRmTransactionHistory7 ON dbo.RM_Transaction_History
    (
     i_version_id ASC,
     d_timestamp ASC,
     c_action_level ASC
    );


CREATE INDEX IxRmTransactionHistory8 ON dbo.RM_Transaction_History
    (
     c_property_abbrev ASC
    );

/* Indexes for RM_User */
CREATE UNIQUE INDEX IxRmUser1 ON dbo.RM_User
    (
     c_user_name ASC
    );

/* Indexes for RM_User_Prop_Hierarchy */
CREATE INDEX IxRmUserPropHierarchy1 ON dbo.RM_User_Prop_Hierarchy
    (
     i_version_id ASC,
     i_hierarchy_id ASC
    );


CREATE INDEX IxRmUserPropHierarchy2 ON dbo.RM_User_Prop_Hierarchy
    (
     i_user_id ASC
    );


CREATE INDEX IxRmUserPropHierarchy3 ON dbo.RM_User_Prop_Hierarchy
    (
     i_property_id ASC
    );

/* Indexes for RM_User_Prop_Version */
CREATE INDEX IxRmUserPropVersion1 ON dbo.RM_User_Prop_Version
    (
     i_version_id ASC
    );


CREATE INDEX IxRmUserPropVersion2 ON dbo.RM_User_Prop_Version
    (
     i_user_id ASC
    );


CREATE INDEX IxRmUserPropVersion3 ON dbo.RM_User_Prop_Version
    (
     i_property_id ASC
    );

/* Indexes for RM_User_Property_Definition */
CREATE UNIQUE INDEX IxRmUserPropertyDefinition1 ON dbo.RM_User_Property_Definition
    (
     c_abbrev ASC
    );


CREATE INDEX IxRmUserPropertyDefinition2 ON dbo.RM_User_Property_Definition
    (
     e_data_type ASC
    );

/* Indexes for RM_Validation_Definition */
CREATE UNIQUE INDEX IxRmValidationDefinition1 ON dbo.RM_Validation_Definition
    (
     c_abbrev ASC
    );

/* Indexes for RM_Validation_Definition_Templ */
CREATE UNIQUE INDEX IxRmValidationDefinitionTempl1 ON dbo.RM_Validation_Definition_Templ
    (
     c_label ASC
    );

/* Indexes for RM_Validation_Param */
CREATE INDEX IxRmValidationParam1 ON dbo.RM_Validation_Param
    (
     i_validation_id ASC
    );


CREATE INDEX IxRmValidationParam2 ON dbo.RM_Validation_Param
    (
     e_data_type ASC
    );

/* Indexes for RM_Validation_Param_Templ */
CREATE INDEX IxRmValidationParamTempl1 ON dbo.RM_Validation_Param_Templ
    (
     e_data_type ASC
    );


CREATE INDEX IxRmValidationParamTempl2 ON dbo.RM_Validation_Param_Templ
    (
     i_valid_def_templ_id ASC
    );

/* Indexes for RM_Validation_Prop_Hierarchy */
CREATE INDEX IxRmValidationPropHierarchy1 ON dbo.RM_Validation_Prop_Hierarchy
    (
     i_version_id ASC,
     i_hierarchy_id ASC
    );


CREATE INDEX IxRmValidationPropHierarchy2 ON dbo.RM_Validation_Prop_Hierarchy
    (
     i_validation_id ASC
    );

/* Indexes for RM_Validation_Prop_Node */
CREATE INDEX IxRmValidationPropNode1 ON dbo.RM_Validation_Prop_Node
    (
     i_version_id ASC,
     i_hierarchy_id ASC
    );


CREATE INDEX IxRmValidationPropNode2 ON dbo.RM_Validation_Prop_Node
    (
     i_version_id ASC,
     i_node_id ASC
    );


CREATE INDEX IxRmValidationPropNode3 ON dbo.RM_Validation_Prop_Node
    (
     i_validation_id ASC
    );

/* Indexes for RM_Validation_Prop_Version */
CREATE INDEX IxRmValidationPropVersion1 ON dbo.RM_Validation_Prop_Version
    (
     i_version_id ASC
    );


CREATE INDEX IxRmValidationPropVersion2 ON dbo.RM_Validation_Prop_Version
    (
     i_validation_id ASC
    );

/* Indexes for RM_Version */
CREATE UNIQUE INDEX IxRmVersion1 ON dbo.RM_Version
    (
     c_abbrev ASC
    );


CREATE INDEX IxRmVersion2 ON dbo.RM_Version
    (
     e_version_type ASC
    );

/* Indexes for RM_Version_Prop */
CREATE INDEX IxRmVersionProp1 ON dbo.RM_Version_Prop
    (
     i_version_id ASC
    );


CREATE INDEX IxRmVersionProp2 ON dbo.RM_Version_Prop
    (
     i_property_id ASC
    );

/* Indexes for RM_WF_Model */
CREATE UNIQUE INDEX IxRmWfModel1 ON dbo.RM_WF_Model
    (
     c_abbrev ASC
    );

/* Indexes for RM_WF_Model_Stage */
CREATE UNIQUE INDEX IxRmWfModelStage1 ON dbo.RM_WF_Model_Stage
    (
     i_model_id ASC,
     c_label ASC
    );

/* Indexes for RM_WF_Request */
CREATE INDEX IxRmWfRequest1 ON dbo.RM_WF_Request
    (
     d_created_on ASC
    );


CREATE INDEX IxRmWfRequest2 ON dbo.RM_WF_Request
    (
     c_created_by ASC,
     d_created_on ASC
    );


CREATE INDEX IxRmWfRequest3 ON dbo.RM_WF_Request
    (
     d_submitted_on ASC
    );


CREATE INDEX IxRmWfRequest4 ON dbo.RM_WF_Request
    (
     d_current_claimed_on ASC
    );


CREATE INDEX IxRmWfRequest5 ON dbo.RM_WF_Request
    (
     d_expedited ASC
    );


CREATE INDEX IxRmWfRequest6 ON dbo.RM_WF_Request
    (
     e_workflow_status__current ASC
    );

/* Indexes for RM_WF_Request_Activity */
CREATE INDEX IxRmWfRequestActivity1 ON dbo.RM_WF_Request_Activity
    (
     i_workflow_request_id ASC
    );


CREATE INDEX IxRmWfRequestActivity2 ON dbo.RM_WF_Request_Activity
    (
     c_user_name ASC
    );


CREATE INDEX IxRmWfRequestActivity3 ON dbo.RM_WF_Request_Activity
    (
     d_timestamp DESC
    );

/* Indexes for RM_WF_Request_Assigned_To */
CREATE INDEX IxRmWfRequestAssignedTo1 ON dbo.RM_WF_Request_Assigned_To
    (
     e_security_principal_type ASC,
     c_name ASC,
     d_assigned ASC
    );


CREATE INDEX IxRmWfRequestAssignedTo2 ON dbo.RM_WF_Request_Assigned_To
    (
     d_assigned ASC
    );

/* Indexes for RM_WF_Task */
CREATE UNIQUE INDEX IxRmWfTask1 ON dbo.RM_WF_Task
    (
     c_abbrev ASC
    );
ALTER TABLE dbo.DAL_Sequence
  ADD CONSTRAINT PkDalSequence
  PRIMARY KEY (c_key);
ALTER TABLE dbo.DAL_Updates
  ADD CONSTRAINT PkDalUpdates
  PRIMARY KEY (c_version);
ALTER TABLE dbo.RM_Access_Group_Ctrl_Hier
  ADD CONSTRAINT PkRmAccessGroupCtrlHier
  PRIMARY KEY (i_security_id, i_version_id);
ALTER TABLE dbo.RM_Access_Group_Definition
  ADD CONSTRAINT PkRmAccessGroupDefinition
  PRIMARY KEY (i_security_id);
ALTER TABLE dbo.RM_Access_Group_Prop_Global
  ADD CONSTRAINT PkRmAccessGroupPropGlobal
  PRIMARY KEY (i_version_id, i_node_id, i_security_id, b_leaf);
ALTER TABLE dbo.RM_Access_Group_Prop_Local
  ADD CONSTRAINT PkRmAccessGroupPropLocal
  PRIMARY KEY (i_version_id, i_hierarchy_id, i_node_id, i_security_id, b_leaf);
ALTER TABLE dbo.RM_Access_Group_User
  ADD CONSTRAINT PkRmAccessGroupUser
  PRIMARY KEY (i_security_id, i_user_id);
ALTER TABLE dbo.RM_Blender
  ADD CONSTRAINT PkRmBlender
  PRIMARY KEY (i_blender_id);
ALTER TABLE dbo.RM_Blender_Default_Param
  ADD CONSTRAINT PkRmBlenderDefaultParam
  PRIMARY KEY (i_blender_id, c_parameter);
ALTER TABLE dbo.RM_Blender_Hierarchy_Set
  ADD CONSTRAINT PkRmBlenderHierarchySet
  PRIMARY KEY (i_blender_id, i_hierarchy_set_id);
ALTER TABLE dbo.RM_Blender_Property_List
  ADD CONSTRAINT PkRmBlenderPropertyList
  PRIMARY KEY (i_blender_id, i_blender_property_list_id);
ALTER TABLE dbo.RM_Blender_Property_List_Item
  ADD CONSTRAINT PkRmBlenderPropertyListItem
  PRIMARY KEY (i_blender_id, i_blender_property_list_id, i_blender_property_item_id);
ALTER TABLE dbo.RM_Book
  ADD CONSTRAINT PkRmBook
  PRIMARY KEY (i_book_id);
ALTER TABLE dbo.RM_Book_Default_Param
  ADD CONSTRAINT PkRmBookDefaultParam
  PRIMARY KEY (i_book_id, c_parameter);
ALTER TABLE dbo.RM_Book_Item
  ADD CONSTRAINT PkRmBookItem
  PRIMARY KEY (i_book_id, i_book_item_id);
ALTER TABLE dbo.RM_Category
  ADD CONSTRAINT PkRmCategory
  PRIMARY KEY (i_category_id);
ALTER TABLE dbo.RM_Category_User
  ADD CONSTRAINT PkRmCategoryUser
  PRIMARY KEY (i_user_id, i_category_id);
ALTER TABLE dbo.RM_Compare
  ADD CONSTRAINT PkRmCompare
  PRIMARY KEY (i_compare_id);
ALTER TABLE dbo.RM_Compare_Default_Param
  ADD CONSTRAINT PkRmCompareDefaultParam
  PRIMARY KEY (i_compare_id, c_parameter);
ALTER TABLE dbo.RM_Compare_Item
  ADD CONSTRAINT PkRmCompareItem
  PRIMARY KEY (i_compare_id, i_item_id);
ALTER TABLE dbo.RM_Config_Info
  ADD CONSTRAINT PkRmConfigInfo
  PRIMARY KEY (c_key);
ALTER TABLE dbo.RM_Connection
  ADD CONSTRAINT PkRmConnection
  PRIMARY KEY (i_connection_id);
ALTER TABLE dbo.RM_Connection_Allowed_Table
  ADD CONSTRAINT PkRmConnectionAllowedTable
  PRIMARY KEY (i_connection_id, c_table_name, c_owner);
ALTER TABLE dbo.RM_Connection_Operation
  ADD CONSTRAINT PkRmConnectionOperation
  PRIMARY KEY (i_connection_id, c_name);
ALTER TABLE dbo.RM_Connection_Operation_Column
  ADD CONSTRAINT PkRmConnectionOperationColumn
  PRIMARY KEY (i_connection_id, i_operation_id, c_column_name);
ALTER TABLE dbo.RM_Connection_Operation_Param
  ADD CONSTRAINT PkRmConnectionOperationParam
  PRIMARY KEY (i_connection_id, i_operation_id, c_param_name);
ALTER TABLE dbo.RM_Derived_Property
  ADD CONSTRAINT PkRmDerivedProperty
  PRIMARY KEY (c_deriver_class);
ALTER TABLE dbo.RM_Derived_Property_Param
  ADD CONSTRAINT PkRmDerivedPropertyParam
  PRIMARY KEY (c_deriver_class, i_template_id);
ALTER TABLE dbo.RM_Domain
  ADD CONSTRAINT PkRmDomain
  PRIMARY KEY (i_domain_id);
ALTER TABLE dbo.RM_Domain_Node
  ADD CONSTRAINT PkRmDomainNode
  PRIMARY KEY (i_domain_id, i_domain_node_id);
ALTER TABLE dbo.RM_Domain_Validations
  ADD CONSTRAINT PkRmDomainValidations
  PRIMARY KEY (i_domain_id, i_validation_id);
ALTER TABLE dbo.RM_Domain_Version
  ADD CONSTRAINT PkRmDomainVersion
  PRIMARY KEY (i_domain_id, i_version_id);
ALTER TABLE dbo.RM_Engine_Info
  ADD CONSTRAINT PkRmEngineInfo
  PRIMARY KEY (i_id);
ALTER TABLE dbo.RM_Export
  ADD CONSTRAINT PkRmExport
  PRIMARY KEY (i_export_id);
ALTER TABLE dbo.RM_Export_Column
  ADD CONSTRAINT PkRmExportColumn
  PRIMARY KEY (i_export_id, i_column_id);
ALTER TABLE dbo.RM_Export_Default_Param
  ADD CONSTRAINT PkRmExportDefaultParam
  PRIMARY KEY (i_export_id, c_parameter);
ALTER TABLE dbo.RM_Export_Node
  ADD CONSTRAINT PkRmExportNode
  PRIMARY KEY (i_export_id, i_export_node_id);
ALTER TABLE dbo.RM_Export_Node_Prop
  ADD CONSTRAINT PkRmExportNodeProp
  PRIMARY KEY (i_export_id, i_export_node_id, c_property_abbrev);
ALTER TABLE dbo.RM_Export_Param
  ADD CONSTRAINT PkRmExportParam
  PRIMARY KEY (i_export_id, i_export_param_id);
ALTER TABLE dbo.RM_Export_Type
  ADD CONSTRAINT PkRmExportType
  PRIMARY KEY (i_export_type_id);
ALTER TABLE dbo.RM_Glyph
  ADD CONSTRAINT PkRmGlyph
  PRIMARY KEY (i_glyph_id);
ALTER TABLE dbo.RM_Hierarchy
  ADD CONSTRAINT PkRmHierarchy
  PRIMARY KEY (i_version_id, i_hierarchy_id);
ALTER TABLE dbo.RM_Hierarchy_Group
  ADD CONSTRAINT PkRmHierarchyGroup
  PRIMARY KEY (i_hierarchy_group_id);
ALTER TABLE dbo.RM_Hierarchy_Prop
  ADD CONSTRAINT PkRmHierarchyProp
  PRIMARY KEY (i_version_id, i_hierarchy_id, i_property_id);
ALTER TABLE dbo.RM_Import
  ADD CONSTRAINT PkRmImport
  PRIMARY KEY (i_import_id);
ALTER TABLE dbo.RM_Import_Class
  ADD CONSTRAINT PkRmImportClass
  PRIMARY KEY (c_import_class);
ALTER TABLE dbo.RM_Import_Default_Param
  ADD CONSTRAINT PkRmImportDefaultParam
  PRIMARY KEY (i_import_id, c_parameter);
ALTER TABLE dbo.RM_Import_Param
  ADD CONSTRAINT PkRmImportParam
  PRIMARY KEY (i_import_id, i_import_param_id);
ALTER TABLE dbo.RM_Import_Section
  ADD CONSTRAINT PkRmImportSection
  PRIMARY KEY (i_import_id, i_import_section_id);
ALTER TABLE dbo.RM_Import_Section_Column
  ADD CONSTRAINT PkRmImportSectionColumn
  PRIMARY KEY (i_import_id, i_import_section_id, i_import_section_column_id);
ALTER TABLE dbo.RM_Import_Section_Column_Hier
  ADD CONSTRAINT PkRmImportSectionColumnHier
  PRIMARY KEY (i_import_id, i_import_section_id, i_import_section_column_id, i_import_section_column_hierid);
ALTER TABLE dbo.RM_Import_Section_Column_Param
  ADD CONSTRAINT PkRmImportSectionColumnParam
  PRIMARY KEY (i_import_id, i_import_section_id, i_import_section_column_id, i_import_param_id);
ALTER TABLE dbo.RM_Import_Section_Param
  ADD CONSTRAINT PkRmImportSectionParam
  PRIMARY KEY (i_import_id, i_import_section_id, i_import_param_id);
ALTER TABLE dbo.RM_Import_Type
  ADD CONSTRAINT PkRmImportType
  PRIMARY KEY (i_import_type_id);
ALTER TABLE dbo.RM_Job_History
  ADD CONSTRAINT PkRmJobHistory
  PRIMARY KEY (i_job_id);
ALTER TABLE dbo.RM_Job_History_Result
  ADD CONSTRAINT PkRmJobHistoryResult
  PRIMARY KEY (i_job_id, i_detail_id);
ALTER TABLE dbo.RM_Merge_Log
  ADD CONSTRAINT PkRmMergeLog
  PRIMARY KEY (i_merge_log_id, i_version_id, i_node_id);
ALTER TABLE dbo.RM_Node
  ADD CONSTRAINT PkRmNode
  PRIMARY KEY (i_version_id, i_node_id);
ALTER TABLE dbo.RM_Node_Merge
  ADD CONSTRAINT PkRmNodeMerge
  PRIMARY KEY (i_version_id, i_node_id);
ALTER TABLE dbo.RM_Node_Prop_Global
  ADD CONSTRAINT PkRmNodePropGlobal
  PRIMARY KEY (i_version_id, i_node_id, i_property_id);
ALTER TABLE dbo.RM_Node_Prop_Local
  ADD CONSTRAINT PkRmNodePropLocal
  PRIMARY KEY (i_version_id, i_hierarchy_id, i_node_id, i_property_id);
ALTER TABLE dbo.RM_Node_Type
  ADD CONSTRAINT PkRmNodeType
  PRIMARY KEY (i_node_type_id);
ALTER TABLE dbo.RM_Node_Type_Property
  ADD CONSTRAINT PkRmNodeTypeProperty
  PRIMARY KEY (i_node_type_id, i_property_id);
ALTER TABLE dbo.RM_Node_Type_Validation
  ADD CONSTRAINT PkRmNodeTypeValidation
  PRIMARY KEY (i_node_type_id, i_validation_id);
ALTER TABLE dbo.RM_Notification
  ADD CONSTRAINT PkRmNotification
  PRIMARY KEY (i_notification_id);
ALTER TABLE dbo.RM_Notification_Detail
  ADD CONSTRAINT PkRmNotificationDetail
  PRIMARY KEY (i_notification_id);
ALTER TABLE dbo.RM_Object_Access_Group
  ADD CONSTRAINT PkRmObjectAccessGroup
  PRIMARY KEY (i_access_group_id);
ALTER TABLE dbo.RM_Object_Access_Group_Nag
  ADD CONSTRAINT PkRmObjectAccessGroupNag
  PRIMARY KEY (i_access_group_id, i_security_id);
ALTER TABLE dbo.RM_Object_Access_Group_User
  ADD CONSTRAINT PkRmObjectAccessGroupUser
  PRIMARY KEY (i_access_group_id, i_user_id);
ALTER TABLE dbo.RM_Property_Category
  ADD CONSTRAINT PkRmPropertyCategory
  PRIMARY KEY (i_property_id, i_category_id);
ALTER TABLE dbo.RM_Property_Constraint
  ADD CONSTRAINT PkRmPropertyConstraint
  PRIMARY KEY (i_property_id, c_constraint_name, c_key);
ALTER TABLE dbo.RM_Property_Ctrl_Hier
  ADD CONSTRAINT PkRmPropertyCtrlHier
  PRIMARY KEY (i_property_id, i_version_id);
ALTER TABLE dbo.RM_Property_Definition
  ADD CONSTRAINT PkRmPropertyDefinition
  PRIMARY KEY (i_property_id);
ALTER TABLE dbo.RM_Property_External_Col_Map
  ADD CONSTRAINT PkRmPropertyExternalColMap
  PRIMARY KEY (i_property_id, i_target_property_id);
ALTER TABLE dbo.RM_Property_External_Param_Map
  ADD CONSTRAINT PkRmPropertyExternalParamMap
  PRIMARY KEY (i_property_id, c_parameter_name);
ALTER TABLE dbo.RM_Property_List
  ADD CONSTRAINT PkRmPropertyList
  PRIMARY KEY (i_property_id, i_order);
ALTER TABLE dbo.RM_Property_Lookup
  ADD CONSTRAINT PkRmPropertyLookup
  PRIMARY KEY (i_property_id, c_lookup_value);
ALTER TABLE dbo.RM_Property_Param
  ADD CONSTRAINT PkRmPropertyParam
  PRIMARY KEY (i_property_id, i_param_id);
ALTER TABLE dbo.RM_Property_Query
  ADD CONSTRAINT PkRmPropertyQuery
  PRIMARY KEY (i_query_id);
ALTER TABLE dbo.RM_Query_Criteria
  ADD CONSTRAINT PkRmQueryCriteria
  PRIMARY KEY (i_query_id, i_criteria_id);
ALTER TABLE dbo.RM_Query_Default_Param
  ADD CONSTRAINT PkRmQueryDefaultParam
  PRIMARY KEY (i_query_id, c_parameter);
ALTER TABLE dbo.RM_Relationship
  ADD CONSTRAINT PkRmRelationship
  PRIMARY KEY (i_version_id, i_parent_id, i_child_id);
ALTER TABLE dbo.RM_Request
  ADD CONSTRAINT PkRmRequest
  PRIMARY KEY (i_request_id);
ALTER TABLE dbo.RM_Request_Item
  ADD CONSTRAINT PkRmRequestItem
  PRIMARY KEY (i_request_id, i_request_item_id);
ALTER TABLE dbo.RM_Request_Verification
  ADD CONSTRAINT PkRmRequestVerification
  PRIMARY KEY (i_request_id, i_sequence);
ALTER TABLE dbo.RM_Role
  ADD CONSTRAINT PkRmRole
  PRIMARY KEY (i_role_id);
ALTER TABLE dbo.RM_Role_Permission
  ADD CONSTRAINT PkRmRolePermission
  PRIMARY KEY (i_role_id, e_permission);
ALTER TABLE dbo.RM_Scheduled_Tasks
  ADD CONSTRAINT PkRmScheduledTasks
  PRIMARY KEY (i_task_id);
ALTER TABLE dbo.RM_Session_Info
  ADD CONSTRAINT PkRmSessionInfo
  PRIMARY KEY (i_session_id);
ALTER TABLE dbo.RM_System_Preference
  ADD CONSTRAINT PkRmSystemPreference
  PRIMARY KEY (c_keyword);
ALTER TABLE dbo.RM_Transaction_History
  ADD CONSTRAINT PkRmTransactionHistory
  PRIMARY KEY (i_transaction_id, i_detail_id);
ALTER TABLE dbo.RM_User
  ADD CONSTRAINT PkRmUser
  PRIMARY KEY (i_user_id);
ALTER TABLE dbo.RM_User_Prop_Hierarchy
  ADD CONSTRAINT PkRmUserPropHierarchy
  PRIMARY KEY (i_version_id, i_hierarchy_id, i_user_id, i_property_id);
ALTER TABLE dbo.RM_User_Prop_Version
  ADD CONSTRAINT PkRmUserPropVersion
  PRIMARY KEY (i_version_id, i_user_id, i_property_id);
ALTER TABLE dbo.RM_User_Property_Definition
  ADD CONSTRAINT PkRmUserPropertyDefinition
  PRIMARY KEY (i_user_property_id);
ALTER TABLE dbo.RM_User_Role
  ADD CONSTRAINT PkRmUserRole
  PRIMARY KEY (i_user_id, i_role_id);
ALTER TABLE dbo.RM_Validation_Definition
  ADD CONSTRAINT PkRmValidationDefinition
  PRIMARY KEY (i_validation_id);
ALTER TABLE dbo.RM_Validation_Definition_Templ
  ADD CONSTRAINT PkRmValidationDefinitionTempl
  PRIMARY KEY (i_valid_def_templ_id);
ALTER TABLE dbo.RM_Validation_Param
  ADD CONSTRAINT PkRmValidationParam
  PRIMARY KEY (i_validation_id, i_parameter_id);
ALTER TABLE dbo.RM_Validation_Param_Templ
  ADD CONSTRAINT PkRmValidationParamTempl
  PRIMARY KEY (i_valid_def_templ_id, i_parameter_id);
ALTER TABLE dbo.RM_Validation_Prop_Hierarchy
  ADD CONSTRAINT PkRmValidationPropHierarchy
  PRIMARY KEY (i_version_id, i_hierarchy_id, i_validation_id);
ALTER TABLE dbo.RM_Validation_Prop_Node
  ADD CONSTRAINT PkRmValidationPropNode
  PRIMARY KEY (i_version_id, i_hierarchy_id, i_node_id, i_validation_id);
ALTER TABLE dbo.RM_Validation_Prop_Version
  ADD CONSTRAINT PkRmValidationPropVersion
  PRIMARY KEY (i_version_id, i_validation_id);
ALTER TABLE dbo.RM_Version
  ADD CONSTRAINT PkRmVersion
  PRIMARY KEY (i_version_id);
ALTER TABLE dbo.RM_Version_Prop
  ADD CONSTRAINT PkRmVersionProp
  PRIMARY KEY (i_version_id, i_property_id);
ALTER TABLE dbo.RM_WF_Model
  ADD CONSTRAINT PkRmWfModel
  PRIMARY KEY (i_model_id);
ALTER TABLE dbo.RM_WF_Model_Filter_NodeType
  ADD CONSTRAINT PkRmWfModelFilterNodetype
  PRIMARY KEY (i_model_id, i_filter_nodetype_id);
ALTER TABLE dbo.RM_WF_Model_Stage
  ADD CONSTRAINT PkRmWfModelStage
  PRIMARY KEY (i_model_id, i_stage_id);
ALTER TABLE dbo.RM_WF_Model_Stage_Assg_Group
  ADD CONSTRAINT PkRmWfModelStageAssgGroup
  PRIMARY KEY (i_model_id, i_stage_id, i_group_id);
ALTER TABLE dbo.RM_WF_Model_Stage_Task
  ADD CONSTRAINT PkRmWfModelStageTask
  PRIMARY KEY (i_model_id, i_stage_id, i_task_id);
ALTER TABLE dbo.RM_WF_Model_Stage_Validation
  ADD CONSTRAINT PkRmWfModelStageValidation
  PRIMARY KEY (i_model_id, i_stage_id, i_validation_id);
ALTER TABLE dbo.RM_WF_Request
  ADD CONSTRAINT PkRmWfRequest
  PRIMARY KEY (i_workflow_request_id);
ALTER TABLE dbo.RM_WF_Request_Activity
  ADD CONSTRAINT PkRmWfRequestActivity
  PRIMARY KEY (i_activity_id);
ALTER TABLE dbo.RM_WF_Request_Assigned_To
  ADD CONSTRAINT PkRmWfRequestAssignedTo
  PRIMARY KEY (i_workflow_request_id, e_security_principal_type, c_name);
ALTER TABLE dbo.RM_WF_Request_Attachment
  ADD CONSTRAINT PkRmWfRequestAttachment
  PRIMARY KEY (i_workflow_request_id, i_attachment_id);
ALTER TABLE dbo.RM_WF_Request_Item
  ADD CONSTRAINT PkRmWfRequestItem
  PRIMARY KEY (i_workflow_request_id, i_workflow_request_item_id);
ALTER TABLE dbo.RM_WF_Request_Item_Fail
  ADD CONSTRAINT PkRmWfRequestItemFail
  PRIMARY KEY (i_workflow_request_id, i_workflow_request_item_id, i_workflow_req_item_fail_id);
ALTER TABLE dbo.RM_WF_Request_Item_PropVal
  ADD CONSTRAINT PkRmWfRequestItemPropval
  PRIMARY KEY (i_workflow_request_id, i_workflow_request_item_id, i_workflow_req_item_prop_id);
ALTER TABLE dbo.RM_WF_Request_Stage
  ADD CONSTRAINT PkRmWfRequestStage
  PRIMARY KEY (i_workflow_request_id, i_stage_id);
ALTER TABLE dbo.RM_WF_Request_Stage_Appr_Group
  ADD CONSTRAINT PkRmWfRequestStageApprGroup
  PRIMARY KEY (i_workflow_request_id, i_stage_id, i_stage_approval_id, i_stage_approval_group_id);
ALTER TABLE dbo.RM_WF_Request_Stage_Approval
  ADD CONSTRAINT PkRmWfRequestStageApproval
  PRIMARY KEY (i_workflow_request_id, i_stage_id, i_stage_approval_id);
ALTER TABLE dbo.RM_WF_Request_Stage_Enriched
  ADD CONSTRAINT PkRmWfRequestStageEnriched
  PRIMARY KEY (i_workflow_request_id, i_stage_id, i_stage_enrich_item_id);
ALTER TABLE dbo.RM_WF_Request_Tag
  ADD CONSTRAINT PkRmWfRequestTag
  PRIMARY KEY (i_workflow_request_id, c_name);
ALTER TABLE dbo.RM_WF_Task
  ADD CONSTRAINT PkRmWfTask
  PRIMARY KEY (i_task_id);
ALTER TABLE dbo.RM_WF_Task_Commit_Op_Param
  ADD CONSTRAINT PkRmWfTaskCommitOpParam
  PRIMARY KEY (i_task_id, i_commit_operation_id, c_parameter_name);
ALTER TABLE dbo.RM_WF_Task_Commit_Operation
  ADD CONSTRAINT PkRmWfTaskCommitOperation
  PRIMARY KEY (i_task_id, i_commit_operation_id);
ALTER TABLE dbo.RM_WF_Task_Property
  ADD CONSTRAINT PkRmWfTaskProperty
  PRIMARY KEY (i_task_id, i_task_property_id);
ALTER TABLE dbo.RM_WF_Task_Validation
  ADD CONSTRAINT PkRmWfTaskValidation
  PRIMARY KEY (i_task_id, i_task_validation_id);
ALTER TABLE dbo.RM_WF_Task_Validation_Property
  ADD CONSTRAINT PkRmWfTaskValidationProperty
  PRIMARY KEY (i_task_id, i_task_validation_id, i_task_validation_prop_id);

/* Foreign Key Constraints for RM_Access_Group_Ctrl_Hier */
ALTER TABLE dbo.RM_Access_Group_Ctrl_Hier
  ADD CONSTRAINT FkRmAccessGroupCtrlHier1
  FOREIGN KEY (i_security_id)
  REFERENCES RM_Access_Group_Definition (i_security_id);

ALTER TABLE dbo.RM_Access_Group_Ctrl_Hier
  ADD CONSTRAINT FkRmAccessGroupCtrlHier2
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_Access_Group_Ctrl_Hier
  ADD CONSTRAINT FkRmAccessGroupCtrlHier3
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_Access_Group_Prop_Global */
ALTER TABLE dbo.RM_Access_Group_Prop_Global
  ADD CONSTRAINT FkRmAccessGroupPropGlobal1
  FOREIGN KEY (i_security_id)
  REFERENCES RM_Access_Group_Definition (i_security_id);

ALTER TABLE dbo.RM_Access_Group_Prop_Global
  ADD CONSTRAINT FkRmAccessGroupPropGlobal2
  FOREIGN KEY (i_version_id, i_node_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

/* Foreign Key Constraints for RM_Access_Group_Prop_Local */
ALTER TABLE dbo.RM_Access_Group_Prop_Local
  ADD CONSTRAINT FkRmAccessGroupPropLocal1
  FOREIGN KEY (i_security_id)
  REFERENCES RM_Access_Group_Definition (i_security_id);

ALTER TABLE dbo.RM_Access_Group_Prop_Local
  ADD CONSTRAINT FkRmAccessGroupPropLocal2
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_Access_Group_Prop_Local
  ADD CONSTRAINT FkRmAccessGroupPropLocal3
  FOREIGN KEY (i_version_id, i_node_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

/* Foreign Key Constraints for RM_Access_Group_User */
ALTER TABLE dbo.RM_Access_Group_User
  ADD CONSTRAINT FkRmAccessGroupUser1
  FOREIGN KEY (i_security_id)
  REFERENCES RM_Access_Group_Definition (i_security_id);

ALTER TABLE dbo.RM_Access_Group_User
  ADD CONSTRAINT FkRmAccessGroupUser2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

/* Foreign Key Constraints for RM_Blender */
ALTER TABLE dbo.RM_Blender
  ADD CONSTRAINT FkRmBlender1
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Blender
  ADD CONSTRAINT FkRmBlender2
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

/* Foreign Key Constraints for RM_Blender_Default_Param */
ALTER TABLE dbo.RM_Blender_Default_Param
  ADD CONSTRAINT FkRmBlenderDefaultParam1
  FOREIGN KEY (i_blender_id)
  REFERENCES RM_Blender (i_blender_id);

/* Foreign Key Constraints for RM_Blender_Hierarchy_Set */
ALTER TABLE dbo.RM_Blender_Hierarchy_Set
  ADD CONSTRAINT FkRmBlenderHierarchySet1
  FOREIGN KEY (i_blender_id)
  REFERENCES RM_Blender (i_blender_id);

ALTER TABLE dbo.RM_Blender_Hierarchy_Set
  ADD CONSTRAINT FkRmBlenderHierarchySet2
  FOREIGN KEY (i_blender_id, i_blender_property_list_id)
  REFERENCES RM_Blender_Property_List (i_blender_id, i_blender_property_list_id);

/* Foreign Key Constraints for RM_Blender_Property_List */
ALTER TABLE dbo.RM_Blender_Property_List
  ADD CONSTRAINT FkRmBlenderPropertyList1
  FOREIGN KEY (i_blender_id)
  REFERENCES RM_Blender (i_blender_id);

/* Foreign Key Constraints for RM_Blender_Property_List_Item */
ALTER TABLE dbo.RM_Blender_Property_List_Item
  ADD CONSTRAINT FkRmBlenderPropertyListItem1
  FOREIGN KEY (i_blender_id, i_blender_property_list_id)
  REFERENCES RM_Blender_Property_List (i_blender_id, i_blender_property_list_id);

/* Foreign Key Constraints for RM_Book */
ALTER TABLE dbo.RM_Book
  ADD CONSTRAINT FkRmBook1
  FOREIGN KEY (c_pre_file_connection)
  REFERENCES RM_Connection (c_name);

ALTER TABLE dbo.RM_Book
  ADD CONSTRAINT FkRmBook2
  FOREIGN KEY (c_post_file_connection)
  REFERENCES RM_Connection (c_name);

ALTER TABLE dbo.RM_Book
  ADD CONSTRAINT FkRmBook3
  FOREIGN KEY (c_combined_file_connection)
  REFERENCES RM_Connection (c_name);

ALTER TABLE dbo.RM_Book
  ADD CONSTRAINT FkRmBook4
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Book
  ADD CONSTRAINT FkRmBook5
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

/* Foreign Key Constraints for RM_Book_Default_Param */
ALTER TABLE dbo.RM_Book_Default_Param
  ADD CONSTRAINT FkRmBookDefaultParam1
  FOREIGN KEY (i_book_id)
  REFERENCES RM_Book (i_book_id);

/* Foreign Key Constraints for RM_Book_Item */
ALTER TABLE dbo.RM_Book_Item
  ADD CONSTRAINT FkRmBookItem1
  FOREIGN KEY (i_book_id)
  REFERENCES RM_Book (i_book_id);

ALTER TABLE dbo.RM_Book_Item
  ADD CONSTRAINT FkRmBookItem2
  FOREIGN KEY (i_export_id)
  REFERENCES RM_Export (i_export_id);

/* Foreign Key Constraints for RM_Category_User */
ALTER TABLE dbo.RM_Category_User
  ADD CONSTRAINT FkRmCategoryUser1
  FOREIGN KEY (i_category_id)
  REFERENCES RM_Category (i_category_id);

ALTER TABLE dbo.RM_Category_User
  ADD CONSTRAINT FkRmCategoryUser2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

/* Foreign Key Constraints for RM_Compare */
ALTER TABLE dbo.RM_Compare
  ADD CONSTRAINT FkRmCompare1
  FOREIGN KEY (i_query_id)
  REFERENCES RM_Property_Query (i_query_id);

ALTER TABLE dbo.RM_Compare
  ADD CONSTRAINT FkRmCompare2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Compare
  ADD CONSTRAINT FkRmCompare3
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

/* Foreign Key Constraints for RM_Compare_Default_Param */
ALTER TABLE dbo.RM_Compare_Default_Param
  ADD CONSTRAINT FkRmCompareDefaultParam1
  FOREIGN KEY (i_compare_id)
  REFERENCES RM_Compare (i_compare_id);

/* Foreign Key Constraints for RM_Compare_Item */
ALTER TABLE dbo.RM_Compare_Item
  ADD CONSTRAINT FkRmCompareItem1
  FOREIGN KEY (i_compare_id)
  REFERENCES RM_Compare (i_compare_id);

/* Foreign Key Constraints for RM_Connection */
ALTER TABLE dbo.RM_Connection
  ADD CONSTRAINT FkRmConnection1
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Connection
  ADD CONSTRAINT FkRmConnection2
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

/* Foreign Key Constraints for RM_Connection_Allowed_Table */
ALTER TABLE dbo.RM_Connection_Allowed_Table
  ADD CONSTRAINT FkRmConnectionAllowedTable1
  FOREIGN KEY (i_connection_id)
  REFERENCES RM_Connection (i_connection_id);

/* Foreign Key Constraints for RM_Connection_Operation */
ALTER TABLE dbo.RM_Connection_Operation
  ADD CONSTRAINT FkRmConnectionOperation1
  FOREIGN KEY (i_connection_id)
  REFERENCES RM_Connection (i_connection_id);

/* Foreign Key Constraints for RM_Connection_Operation_Column */
ALTER TABLE dbo.RM_Connection_Operation_Column
  ADD CONSTRAINT FkRmConnectionOperationColumn1
  FOREIGN KEY (i_connection_id, i_operation_id)
  REFERENCES RM_Connection_Operation (i_connection_id, i_operation_id);

/* Foreign Key Constraints for RM_Connection_Operation_Param */
ALTER TABLE dbo.RM_Connection_Operation_Param
  ADD CONSTRAINT FkRmConnectionOperationParam1
  FOREIGN KEY (i_connection_id, i_operation_id)
  REFERENCES RM_Connection_Operation (i_connection_id, i_operation_id);

/* Foreign Key Constraints for RM_Derived_Property_Param */
ALTER TABLE dbo.RM_Derived_Property_Param
  ADD CONSTRAINT FkRmDerivedPropertyParam1
  FOREIGN KEY (c_deriver_class)
  REFERENCES RM_Derived_Property (c_deriver_class);

/* Foreign Key Constraints for RM_Domain_Node */
ALTER TABLE dbo.RM_Domain_Node
  ADD CONSTRAINT FkRmDomainNode1
  FOREIGN KEY (i_domain_id)
  REFERENCES RM_Domain (i_domain_id);

/* Foreign Key Constraints for RM_Domain_Validations */
ALTER TABLE dbo.RM_Domain_Validations
  ADD CONSTRAINT FkRmDomainValidations1
  FOREIGN KEY (i_domain_id)
  REFERENCES RM_Domain (i_domain_id);

ALTER TABLE dbo.RM_Domain_Validations
  ADD CONSTRAINT FkRmDomainValidations2
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

/* Foreign Key Constraints for RM_Domain_Version */
ALTER TABLE dbo.RM_Domain_Version
  ADD CONSTRAINT FkRmDomainVersion1
  FOREIGN KEY (i_domain_id)
  REFERENCES RM_Domain (i_domain_id);

ALTER TABLE dbo.RM_Domain_Version
  ADD CONSTRAINT FkRmDomainVersion2
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_Export */
ALTER TABLE dbo.RM_Export
  ADD CONSTRAINT FkRmExport1
  FOREIGN KEY (i_export_type_id)
  REFERENCES RM_Export_Type (i_export_type_id);

ALTER TABLE dbo.RM_Export
  ADD CONSTRAINT FkRmExport2
  FOREIGN KEY (i_query_id)
  REFERENCES RM_Property_Query (i_query_id);

ALTER TABLE dbo.RM_Export
  ADD CONSTRAINT FkRmExport3
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Export
  ADD CONSTRAINT FkRmExport4
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

ALTER TABLE dbo.RM_Export
  ADD CONSTRAINT FkRmExport5
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

/* Foreign Key Constraints for RM_Export_Column */
ALTER TABLE dbo.RM_Export_Column
  ADD CONSTRAINT FkRmExportColumn1
  FOREIGN KEY (i_export_id)
  REFERENCES RM_Export (i_export_id);

/* Foreign Key Constraints for RM_Export_Default_Param */
ALTER TABLE dbo.RM_Export_Default_Param
  ADD CONSTRAINT FkRmExportDefaultParam1
  FOREIGN KEY (i_export_id)
  REFERENCES RM_Export (i_export_id);

/* Foreign Key Constraints for RM_Export_Node */
ALTER TABLE dbo.RM_Export_Node
  ADD CONSTRAINT FkRmExportNode1
  FOREIGN KEY (i_export_id)
  REFERENCES RM_Export (i_export_id);

/* Foreign Key Constraints for RM_Export_Node_Prop */
ALTER TABLE dbo.RM_Export_Node_Prop
  ADD CONSTRAINT FkRmExportNodeProp1
  FOREIGN KEY (i_export_id, i_export_node_id)
  REFERENCES RM_Export_Node (i_export_id, i_export_node_id);

/* Foreign Key Constraints for RM_Export_Param */
ALTER TABLE dbo.RM_Export_Param
  ADD CONSTRAINT FkRmExportParam1
  FOREIGN KEY (i_export_id)
  REFERENCES RM_Export (i_export_id);

/* Foreign Key Constraints for RM_Hierarchy */
ALTER TABLE dbo.RM_Hierarchy
  ADD CONSTRAINT FkRmHierarchy1
  FOREIGN KEY (i_hierarchy_group_id)
  REFERENCES RM_Hierarchy_Group (i_hierarchy_group_id);

ALTER TABLE dbo.RM_Hierarchy
  ADD CONSTRAINT FkRmHierarchy2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Hierarchy
  ADD CONSTRAINT FkRmHierarchy3
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_Hierarchy_Prop */
ALTER TABLE dbo.RM_Hierarchy_Prop
  ADD CONSTRAINT FkRmHierarchyProp1
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_Hierarchy_Prop
  ADD CONSTRAINT FkRmHierarchyProp2
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Import */
ALTER TABLE dbo.RM_Import
  ADD CONSTRAINT FkRmImport1
  FOREIGN KEY (i_import_type_id)
  REFERENCES RM_Import_Type (i_import_type_id);

ALTER TABLE dbo.RM_Import
  ADD CONSTRAINT FkRmImport2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Import
  ADD CONSTRAINT FkRmImport3
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

/* Foreign Key Constraints for RM_Import_Default_Param */
ALTER TABLE dbo.RM_Import_Default_Param
  ADD CONSTRAINT FkRmImportDefaultParam1
  FOREIGN KEY (i_import_id)
  REFERENCES RM_Import (i_import_id);

/* Foreign Key Constraints for RM_Import_Param */
ALTER TABLE dbo.RM_Import_Param
  ADD CONSTRAINT FkRmImportParam1
  FOREIGN KEY (i_import_id)
  REFERENCES RM_Import (i_import_id);

/* Foreign Key Constraints for RM_Import_Section */
ALTER TABLE dbo.RM_Import_Section
  ADD CONSTRAINT FkRmImportSection1
  FOREIGN KEY (i_import_id)
  REFERENCES RM_Import (i_import_id);

/* Foreign Key Constraints for RM_Import_Section_Column */
ALTER TABLE dbo.RM_Import_Section_Column
  ADD CONSTRAINT FkRmImportSectionColumn1
  FOREIGN KEY (i_import_id, i_import_section_id)
  REFERENCES RM_Import_Section (i_import_id, i_import_section_id);

/* Foreign Key Constraints for RM_Import_Section_Column_Hier */
ALTER TABLE dbo.RM_Import_Section_Column_Hier
  ADD CONSTRAINT FkRmImportSectionColumnHier1
  FOREIGN KEY (i_import_id, i_import_section_id, i_import_section_column_id)
  REFERENCES RM_Import_Section_Column (i_import_id, i_import_section_id, i_import_section_column_id);

/* Foreign Key Constraints for RM_Import_Section_Column_Param */
ALTER TABLE dbo.RM_Import_Section_Column_Param
  ADD CONSTRAINT FkRmImportSectionColumnParam1
  FOREIGN KEY (i_import_id, i_import_section_id, i_import_section_column_id)
  REFERENCES RM_Import_Section_Column (i_import_id, i_import_section_id, i_import_section_column_id);

/* Foreign Key Constraints for RM_Import_Section_Param */
ALTER TABLE dbo.RM_Import_Section_Param
  ADD CONSTRAINT FkRmImportSectionParam1
  FOREIGN KEY (i_import_id, i_import_section_id)
  REFERENCES RM_Import_Section (i_import_id, i_import_section_id);

/* Foreign Key Constraints for RM_Job_History_Result */
ALTER TABLE dbo.RM_Job_History_Result
  ADD CONSTRAINT FkRmJobHistoryResult1
  FOREIGN KEY (i_job_id)
  REFERENCES RM_Job_History (i_job_id);

/* Foreign Key Constraints for RM_Node */
ALTER TABLE dbo.RM_Node
  ADD CONSTRAINT FkRmNode1
  FOREIGN KEY (i_domain_id)
  REFERENCES RM_Domain (i_domain_id);

ALTER TABLE dbo.RM_Node
  ADD CONSTRAINT FkRmNode2
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_Node_Merge */
ALTER TABLE dbo.RM_Node_Merge
  ADD CONSTRAINT FkRmNodeMerge1
  FOREIGN KEY (i_version_id, i_node_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

/* Foreign Key Constraints for RM_Node_Prop_Global */
ALTER TABLE dbo.RM_Node_Prop_Global
  ADD CONSTRAINT FkRmNodePropGlobal1
  FOREIGN KEY (i_version_id, i_node_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

ALTER TABLE dbo.RM_Node_Prop_Global
  ADD CONSTRAINT FkRmNodePropGlobal2
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Node_Prop_Local */
ALTER TABLE dbo.RM_Node_Prop_Local
  ADD CONSTRAINT FkRmNodePropLocal1
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_Node_Prop_Local
  ADD CONSTRAINT FkRmNodePropLocal2
  FOREIGN KEY (i_version_id, i_node_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

ALTER TABLE dbo.RM_Node_Prop_Local
  ADD CONSTRAINT FkRmNodePropLocal3
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Node_Type */
ALTER TABLE dbo.RM_Node_Type
  ADD CONSTRAINT FkRmNodeType1
  FOREIGN KEY (i_glyph_id)
  REFERENCES RM_Glyph (i_glyph_id);

/* Foreign Key Constraints for RM_Node_Type_Property */
ALTER TABLE dbo.RM_Node_Type_Property
  ADD CONSTRAINT FkRmNodeTypeProperty1
  FOREIGN KEY (i_node_type_id)
  REFERENCES RM_Node_Type (i_node_type_id);

ALTER TABLE dbo.RM_Node_Type_Property
  ADD CONSTRAINT FkRmNodeTypeProperty2
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Node_Type_Validation */
ALTER TABLE dbo.RM_Node_Type_Validation
  ADD CONSTRAINT FkRmNodeTypeValidation1
  FOREIGN KEY (i_node_type_id)
  REFERENCES RM_Node_Type (i_node_type_id);

ALTER TABLE dbo.RM_Node_Type_Validation
  ADD CONSTRAINT FkRmNodeTypeValidation2
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

/* Foreign Key Constraints for RM_Notification */
ALTER TABLE dbo.RM_Notification
  ADD CONSTRAINT FkRmNotification1
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

/* Foreign Key Constraints for RM_Notification_Detail */
ALTER TABLE dbo.RM_Notification_Detail
  ADD CONSTRAINT FkRmNotificationDetail1
  FOREIGN KEY (i_notification_id)
  REFERENCES RM_Notification (i_notification_id);

/* Foreign Key Constraints for RM_Object_Access_Group_Nag */
ALTER TABLE dbo.RM_Object_Access_Group_Nag
  ADD CONSTRAINT FkRmObjectAccessGroupNag1
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

ALTER TABLE dbo.RM_Object_Access_Group_Nag
  ADD CONSTRAINT FkRmObjectAccessGroupNag2
  FOREIGN KEY (i_security_id)
  REFERENCES RM_Access_Group_Definition (i_security_id);

/* Foreign Key Constraints for RM_Object_Access_Group_User */
ALTER TABLE dbo.RM_Object_Access_Group_User
  ADD CONSTRAINT FkRmObjectAccessGroupUser1
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

ALTER TABLE dbo.RM_Object_Access_Group_User
  ADD CONSTRAINT FkRmObjectAccessGroupUser2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

/* Foreign Key Constraints for RM_Property_Category */
ALTER TABLE dbo.RM_Property_Category
  ADD CONSTRAINT FkRmPropertyCategory1
  FOREIGN KEY (i_category_id)
  REFERENCES RM_Category (i_category_id);

ALTER TABLE dbo.RM_Property_Category
  ADD CONSTRAINT FkRmPropertyCategory2
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Property_Constraint */
ALTER TABLE dbo.RM_Property_Constraint
  ADD CONSTRAINT FkRmPropertyConstraint1
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Property_Ctrl_Hier */
ALTER TABLE dbo.RM_Property_Ctrl_Hier
  ADD CONSTRAINT FkRmPropertyCtrlHier1
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_Property_Ctrl_Hier
  ADD CONSTRAINT FkRmPropertyCtrlHier2
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

ALTER TABLE dbo.RM_Property_Ctrl_Hier
  ADD CONSTRAINT FkRmPropertyCtrlHier3
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_Property_Definition */
ALTER TABLE dbo.RM_Property_Definition
  ADD CONSTRAINT FkRmPropertyDefinition1
  FOREIGN KEY (i_assigned_domain_id)
  REFERENCES RM_Domain (i_domain_id);

ALTER TABLE dbo.RM_Property_Definition
  ADD CONSTRAINT FkRmPropertyDefinition2
  FOREIGN KEY (i_connection_id)
  REFERENCES RM_Connection (i_connection_id);

/* Foreign Key Constraints for RM_Property_External_Col_Map */
ALTER TABLE dbo.RM_Property_External_Col_Map
  ADD CONSTRAINT FkRmPropertyExternalColMap1
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Property_External_Param_Map */
ALTER TABLE dbo.RM_Property_External_Param_Map
  ADD CONSTRAINT FkRmPropertyExternalParamMap1
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Property_List */
ALTER TABLE dbo.RM_Property_List
  ADD CONSTRAINT FkRmPropertyList1
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Property_Lookup */
ALTER TABLE dbo.RM_Property_Lookup
  ADD CONSTRAINT FkRmPropertyLookup1
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Property_Param */
ALTER TABLE dbo.RM_Property_Param
  ADD CONSTRAINT FkRmPropertyParam1
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_Property_Query */
ALTER TABLE dbo.RM_Property_Query
  ADD CONSTRAINT FkRmPropertyQuery1
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Property_Query
  ADD CONSTRAINT FkRmPropertyQuery2
  FOREIGN KEY (i_access_group_id)
  REFERENCES RM_Object_Access_Group (i_access_group_id);

/* Foreign Key Constraints for RM_Query_Criteria */
ALTER TABLE dbo.RM_Query_Criteria
  ADD CONSTRAINT FkRmQueryCriteria1
  FOREIGN KEY (i_query_id)
  REFERENCES RM_Property_Query (i_query_id);

/* Foreign Key Constraints for RM_Query_Default_Param */
ALTER TABLE dbo.RM_Query_Default_Param
  ADD CONSTRAINT FkRmQueryDefaultParam1
  FOREIGN KEY (i_query_id)
  REFERENCES RM_Property_Query (i_query_id);

/* Foreign Key Constraints for RM_Relationship */
ALTER TABLE dbo.RM_Relationship
  ADD CONSTRAINT FkRmRelationship1
  FOREIGN KEY (i_version_id, i_child_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

ALTER TABLE dbo.RM_Relationship
  ADD CONSTRAINT FkRmRelationship2
  FOREIGN KEY (i_version_id, i_parent_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

/* Foreign Key Constraints for RM_Request_Item */
ALTER TABLE dbo.RM_Request_Item
  ADD CONSTRAINT FkRmRequestItem1
  FOREIGN KEY (i_request_id)
  REFERENCES RM_Request (i_request_id);

/* Foreign Key Constraints for RM_Request_Verification */
ALTER TABLE dbo.RM_Request_Verification
  ADD CONSTRAINT FkRmRequestVerification1
  FOREIGN KEY (i_request_id)
  REFERENCES RM_Request (i_request_id);

/* Foreign Key Constraints for RM_Role_Permission */
ALTER TABLE dbo.RM_Role_Permission
  ADD CONSTRAINT FkRmRolePermission1
  FOREIGN KEY (i_role_id)
  REFERENCES RM_Role (i_role_id);

/* Foreign Key Constraints for RM_User_Prop_Hierarchy */
ALTER TABLE dbo.RM_User_Prop_Hierarchy
  ADD CONSTRAINT FkRmUserPropHierarchy1
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_User_Prop_Hierarchy
  ADD CONSTRAINT FkRmUserPropHierarchy2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_User_Prop_Hierarchy
  ADD CONSTRAINT FkRmUserPropHierarchy3
  FOREIGN KEY (i_property_id)
  REFERENCES RM_User_Property_Definition (i_user_property_id);

/* Foreign Key Constraints for RM_User_Prop_Version */
ALTER TABLE dbo.RM_User_Prop_Version
  ADD CONSTRAINT FkRmUserPropVersion1
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_User_Prop_Version
  ADD CONSTRAINT FkRmUserPropVersion2
  FOREIGN KEY (i_property_id)
  REFERENCES RM_User_Property_Definition (i_user_property_id);

ALTER TABLE dbo.RM_User_Prop_Version
  ADD CONSTRAINT FkRmUserPropVersion3
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_User_Role */
ALTER TABLE dbo.RM_User_Role
  ADD CONSTRAINT FkRmUserRole1
  FOREIGN KEY (i_role_id)
  REFERENCES RM_Role (i_role_id);

ALTER TABLE dbo.RM_User_Role
  ADD CONSTRAINT FkRmUserRole2
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

/* Foreign Key Constraints for RM_Validation_Param */
ALTER TABLE dbo.RM_Validation_Param
  ADD CONSTRAINT FkRmValidationParam1
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

/* Foreign Key Constraints for RM_Validation_Param_Templ */
ALTER TABLE dbo.RM_Validation_Param_Templ
  ADD CONSTRAINT FkRmValidationParamTempl1
  FOREIGN KEY (i_valid_def_templ_id)
  REFERENCES RM_Validation_Definition_Templ (i_valid_def_templ_id);

/* Foreign Key Constraints for RM_Validation_Prop_Hierarchy */
ALTER TABLE dbo.RM_Validation_Prop_Hierarchy
  ADD CONSTRAINT FkRmValidationPropHierarchy1
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_Validation_Prop_Hierarchy
  ADD CONSTRAINT FkRmValidationPropHierarchy2
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

/* Foreign Key Constraints for RM_Validation_Prop_Node */
ALTER TABLE dbo.RM_Validation_Prop_Node
  ADD CONSTRAINT FkRmValidationPropNode1
  FOREIGN KEY (i_version_id, i_hierarchy_id)
  REFERENCES RM_Hierarchy (i_version_id, i_hierarchy_id);

ALTER TABLE dbo.RM_Validation_Prop_Node
  ADD CONSTRAINT FkRmValidationPropNode2
  FOREIGN KEY (i_version_id, i_node_id)
  REFERENCES RM_Node (i_version_id, i_node_id);

ALTER TABLE dbo.RM_Validation_Prop_Node
  ADD CONSTRAINT FkRmValidationPropNode3
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

/* Foreign Key Constraints for RM_Validation_Prop_Version */
ALTER TABLE dbo.RM_Validation_Prop_Version
  ADD CONSTRAINT FkRmValidationPropVersion1
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

ALTER TABLE dbo.RM_Validation_Prop_Version
  ADD CONSTRAINT FkRmValidationPropVersion2
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_Version */
ALTER TABLE dbo.RM_Version
  ADD CONSTRAINT FkRmVersion1
  FOREIGN KEY (i_user_id)
  REFERENCES RM_User (i_user_id);

ALTER TABLE dbo.RM_Version
  ADD CONSTRAINT FkRmVersion2
  FOREIGN KEY (i_lineage_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_Version_Prop */
ALTER TABLE dbo.RM_Version_Prop
  ADD CONSTRAINT FkRmVersionProp1
  FOREIGN KEY (i_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

ALTER TABLE dbo.RM_Version_Prop
  ADD CONSTRAINT FkRmVersionProp2
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_WF_Model_Filter_NodeType */
ALTER TABLE dbo.RM_WF_Model_Filter_NodeType
  ADD CONSTRAINT FkRmWfModelFilterNodetype1
  FOREIGN KEY (i_model_id)
  REFERENCES RM_WF_Model (i_model_id);

/* Foreign Key Constraints for RM_WF_Model_Stage */
ALTER TABLE dbo.RM_WF_Model_Stage
  ADD CONSTRAINT FkRmWfModelStage1
  FOREIGN KEY (i_model_id)
  REFERENCES RM_WF_Model (i_model_id);

/* Foreign Key Constraints for RM_WF_Model_Stage_Assg_Group */
ALTER TABLE dbo.RM_WF_Model_Stage_Assg_Group
  ADD CONSTRAINT FkRmWfModelStageAssgGroup1
  FOREIGN KEY (i_model_id, i_stage_id)
  REFERENCES RM_WF_Model_Stage (i_model_id, i_stage_id);

/* Foreign Key Constraints for RM_WF_Model_Stage_Task */
ALTER TABLE dbo.RM_WF_Model_Stage_Task
  ADD CONSTRAINT FkRmWfModelStageTask1
  FOREIGN KEY (i_model_id, i_stage_id)
  REFERENCES RM_WF_Model_Stage (i_model_id, i_stage_id);

/* Foreign Key Constraints for RM_WF_Model_Stage_Validation */
ALTER TABLE dbo.RM_WF_Model_Stage_Validation
  ADD CONSTRAINT FkRmWfModelStageValidation1
  FOREIGN KEY (i_model_id, i_stage_id)
  REFERENCES RM_WF_Model_Stage (i_model_id, i_stage_id);

ALTER TABLE dbo.RM_WF_Model_Stage_Validation
  ADD CONSTRAINT FkRmWfModelStageValidation2
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

/* Foreign Key Constraints for RM_WF_Request */
ALTER TABLE dbo.RM_WF_Request
  ADD CONSTRAINT FkRmWfRequest1
  FOREIGN KEY (i_version_id)
  REFERENCES RM_Version (i_version_id);

/* Foreign Key Constraints for RM_WF_Request_Activity */
ALTER TABLE dbo.RM_WF_Request_Activity
  ADD CONSTRAINT FkRmWfRequestActivity1
  FOREIGN KEY (i_workflow_request_id)
  REFERENCES RM_WF_Request (i_workflow_request_id);

/* Foreign Key Constraints for RM_WF_Request_Assigned_To */
ALTER TABLE dbo.RM_WF_Request_Assigned_To
  ADD CONSTRAINT FkRmWfRequestAssignedTo1
  FOREIGN KEY (i_workflow_request_id)
  REFERENCES RM_WF_Request (i_workflow_request_id);

/* Foreign Key Constraints for RM_WF_Request_Attachment */
ALTER TABLE dbo.RM_WF_Request_Attachment
  ADD CONSTRAINT FkRmWfRequestAttachment1
  FOREIGN KEY (i_workflow_request_id)
  REFERENCES RM_WF_Request (i_workflow_request_id);

/* Foreign Key Constraints for RM_WF_Request_Item */
ALTER TABLE dbo.RM_WF_Request_Item
  ADD CONSTRAINT FkRmWfRequestItem1
  FOREIGN KEY (i_workflow_request_id)
  REFERENCES RM_WF_Request (i_workflow_request_id);

/* Foreign Key Constraints for RM_WF_Request_Item_Fail */
ALTER TABLE dbo.RM_WF_Request_Item_Fail
  ADD CONSTRAINT FkRmWfRequestItemFail1
  FOREIGN KEY (i_workflow_request_id, i_workflow_request_item_id)
  REFERENCES RM_WF_Request_Item (i_workflow_request_id, i_workflow_request_item_id);

/* Foreign Key Constraints for RM_WF_Request_Item_PropVal */
ALTER TABLE dbo.RM_WF_Request_Item_PropVal
  ADD CONSTRAINT FkRmWfRequestItemPropval1
  FOREIGN KEY (i_workflow_request_id, i_workflow_request_item_id)
  REFERENCES RM_WF_Request_Item (i_workflow_request_id, i_workflow_request_item_id);

/* Foreign Key Constraints for RM_WF_Request_Stage */
ALTER TABLE dbo.RM_WF_Request_Stage
  ADD CONSTRAINT FkRmWfRequestStage1
  FOREIGN KEY (i_workflow_request_id)
  REFERENCES RM_WF_Request (i_workflow_request_id);

/* Foreign Key Constraints for RM_WF_Request_Stage_Appr_Group */
ALTER TABLE dbo.RM_WF_Request_Stage_Appr_Group
  ADD CONSTRAINT FkRmWfRequestStageApprGroup1
  FOREIGN KEY (i_workflow_request_id, i_stage_id, i_stage_approval_id)
  REFERENCES RM_WF_Request_Stage_Approval (i_workflow_request_id, i_stage_id, i_stage_approval_id);

/* Foreign Key Constraints for RM_WF_Request_Stage_Approval */
ALTER TABLE dbo.RM_WF_Request_Stage_Approval
  ADD CONSTRAINT FkRmWfRequestStageApproval1
  FOREIGN KEY (i_workflow_request_id, i_stage_id)
  REFERENCES RM_WF_Request_Stage (i_workflow_request_id, i_stage_id);

/* Foreign Key Constraints for RM_WF_Request_Stage_Enriched */
ALTER TABLE dbo.RM_WF_Request_Stage_Enriched
  ADD CONSTRAINT FkRmWfRequestStageEnriched1
  FOREIGN KEY (i_workflow_request_id, i_stage_id)
  REFERENCES RM_WF_Request_Stage (i_workflow_request_id, i_stage_id);

/* Foreign Key Constraints for RM_WF_Request_Tag */
ALTER TABLE dbo.RM_WF_Request_Tag
  ADD CONSTRAINT FkRmWfRequestTag1
  FOREIGN KEY (i_workflow_request_id)
  REFERENCES RM_WF_Request (i_workflow_request_id);

/* Foreign Key Constraints for RM_WF_Task */
ALTER TABLE dbo.RM_WF_Task
  ADD CONSTRAINT FkRmWfTask1
  FOREIGN KEY (c_domain_abbrev)
  REFERENCES RM_Domain (c_abbrev);

/* Foreign Key Constraints for RM_WF_Task_Commit_Op_Param */
ALTER TABLE dbo.RM_WF_Task_Commit_Op_Param
  ADD CONSTRAINT FkRmWfTaskCommitOpParam1
  FOREIGN KEY (i_task_id)
  REFERENCES RM_WF_Task (i_task_id);

ALTER TABLE dbo.RM_WF_Task_Commit_Op_Param
  ADD CONSTRAINT FkRmWfTaskCommitOpParam2
  FOREIGN KEY (i_task_id, i_commit_operation_id)
  REFERENCES RM_WF_Task_Commit_Operation (i_task_id, i_commit_operation_id);

/* Foreign Key Constraints for RM_WF_Task_Commit_Operation */
ALTER TABLE dbo.RM_WF_Task_Commit_Operation
  ADD CONSTRAINT FkRmWfTaskCommitOperation1
  FOREIGN KEY (i_task_id)
  REFERENCES RM_WF_Task (i_task_id);

ALTER TABLE dbo.RM_WF_Task_Commit_Operation
  ADD CONSTRAINT FkRmWfTaskCommitOperation2
  FOREIGN KEY (i_connection_id, i_operation_id)
  REFERENCES RM_Connection_Operation (i_connection_id, i_operation_id);

ALTER TABLE dbo.RM_WF_Task_Commit_Operation
  ADD CONSTRAINT FkRmWfTaskCommitOperation3
  FOREIGN KEY (i_status_property_id)
  REFERENCES RM_Property_Definition (i_property_id);

/* Foreign Key Constraints for RM_WF_Task_Property */
ALTER TABLE dbo.RM_WF_Task_Property
  ADD CONSTRAINT FkRmWfTaskProperty1
  FOREIGN KEY (i_task_id)
  REFERENCES RM_WF_Task (i_task_id);

/* Foreign Key Constraints for RM_WF_Task_Validation */
ALTER TABLE dbo.RM_WF_Task_Validation
  ADD CONSTRAINT FkRmWfTaskValidation1
  FOREIGN KEY (i_task_id)
  REFERENCES RM_WF_Task (i_task_id);

ALTER TABLE dbo.RM_WF_Task_Validation
  ADD CONSTRAINT FkRmWfTaskValidation2
  FOREIGN KEY (i_validation_id)
  REFERENCES RM_Validation_Definition (i_validation_id);

/* Foreign Key Constraints for RM_WF_Task_Validation_Property */
ALTER TABLE dbo.RM_WF_Task_Validation_Property
  ADD CONSTRAINT FkRmWfTaskValidationProperty1
  FOREIGN KEY (i_task_id, i_task_validation_id)
  REFERENCES RM_WF_Task_Validation (i_task_id, i_task_validation_id);

ALTER TABLE dbo.RM_WF_Task_Validation_Property
  ADD CONSTRAINT FkRmWfTaskValidationProperty2
  FOREIGN KEY (i_task_id)
  REFERENCES RM_WF_Task (i_task_id);


IF OBJECT_ID('dbo.DAL_DUAL') IS NOT NULL
  DROP VIEW dbo.DAL_DUAL;
GO
CREATE VIEW dbo.DAL_DUAL AS
SELECT 'x' AS DUMMY;
GO

GO

IF OBJECT_ID('dbo.DAL_VERSION') IS NOT NULL
  DROP VIEW dbo.DAL_VERSION;
GO
CREATE VIEW dbo.DAL_VERSION AS
SELECT '11.1.2.4.340.1:0' AS c_version;
GO

GO

IF OBJECT_ID('dbo.RM_Access_Group_Hierarchy') IS NOT NULL
  DROP VIEW dbo.RM_Access_Group_Hierarchy;
GO
CREATE VIEW dbo.RM_Access_Group_Hierarchy AS
SELECT DISTINCT
    i_security_id,
    i_version_id,
    i_hierarchy_id
  FROM RM_Access_Group_Prop_Local
  WHERE COALESCE(e_access_level, N'') != 'None';
GO

GO

IF OBJECT_ID('dbo.RM_Book_Item_Export') IS NOT NULL
  DROP VIEW dbo.RM_Book_Item_Export;
GO
CREATE VIEW dbo.RM_Book_Item_Export AS
SELECT
    bi.i_book_id,
    bi.i_book_item_id,
    bi.i_export_id,
    ex.c_export_abbrev,
    ex.i_user_id
  FROM RM_Book_Item bi
  JOIN RM_Export ex on bi.i_export_id = ex.i_export_id;
GO


IF OBJECT_ID('dbo.USP_GETNEXTSEQUENCE') IS NOT NULL
  DROP PROC dbo.USP_GETNEXTSEQUENCE;
GO
CREATE PROCEDURE dbo.usp_GetNextSequence
   (
    @p_v_c_key_field varchar(50),
    @p_v_i_reserve   int = 1,
    @p_v_result      int = null out
    )
AS
BEGIN
  SET NOCOUNT ON

  BEGIN TRAN

    UPDATE DAL_Sequence
      WITH (SERIALIZABLE)
      SET i_id = i_id + @p_v_i_reserve
      WHERE c_key = @p_v_c_key_field

    IF @@ROWCOUNT = 0
      INSERT INTO DAL_Sequence (c_key, i_id) SELECT @p_v_c_key_field, @p_v_i_reserve

    SELECT @p_v_result = i_id - @p_v_i_reserve + 1
      FROM DAL_Sequence
      WITH (SERIALIZABLE)
      WHERE c_key = @p_v_c_key_field

  COMMIT TRAN
  SET NOCOUNT OFF
END

GO

IF OBJECT_ID('dbo.USP_WFCLAIMREQUEST') IS NOT NULL
  DROP PROC dbo.USP_WFCLAIMREQUEST;
GO
CREATE PROCEDURE dbo.usp_WfClaimRequest
   (
    @p_v_i_workflowRequestId int,
    @p_v_c_username nvarchar(255),
    @p_v_updatedCount int = null out
    )
AS
BEGIN
  SET NOCOUNT OFF
  BEGIN TRAN

  UPDATE RM_WF_Request SET
    c_current_claimed_by = @p_v_c_username,
    d_current_claimed_on = GETUTCDATE()
  WHERE
    i_workflow_request_id = @p_v_i_workflowRequestId AND
    c_current_claimed_by IS NULL;

  SET @p_v_updatedCount = @@ROWCOUNT;

  COMMIT TRAN
 END

GO

IF OBJECT_ID('dbo.UF_COLUMNEXISTS') IS NOT NULL
  DROP FUNCTION dbo.UF_COLUMNEXISTS;
GO
CREATE FUNCTION dbo.uf_ColumnExists (@tbl VARCHAR(40), @col VARCHAR(40))
RETURNS bit
WITH EXECUTE AS CALLER
AS
BEGIN
    RETURN (SELECT CASE WHEN EXISTS (
SELECT * FROM sysobjects, syscolumns
WHERE sysobjects.id = syscolumns.id
  and sysobjects.name = @tbl
  and syscolumns.name = @col
) THEN 1 ELSE 0 END);
END

GO


-- User: <DBAUSER>
DECLARE @viewName AS NVARCHAR(500)
DECLARE viewsCursor CURSOR LOCAL FOR SELECT DISTINCT name from sys.views
OPEN viewsCursor
FETCH NEXT FROM viewsCursor INTO @viewName
WHILE (@@FETCH_STATUS = 0)
BEGIN
    BEGIN TRY
      EXEC sp_refreshview @viewName;
      PRINT  @viewName
    END TRY
    BEGIN CATCH
       -- Don't worry about the errors here. The view will refresh when used. We just may not
       -- be able to get column information quite yet.
    END CATCH;
    FETCH NEXT FROM viewsCursor INTO @viewName
END
CLOSE viewsCursor
DEALLOCATE viewsCursor
     
*******************************************************************************

Thanks,
Madhusudhan

HFM Copy Utility - Archive logs - Space issue

While running HFM copy Utility, Archive logs will occupy lot of sspace, some times we may face space issues also.

To avoid this issue, we can turn off/disable  archive logs in Oracle Database.

If we are running same in SQL Database, We need to make of change Database into Simple from FULL option.



This way, we can avoid, log file getting occupied space and Copy Utility runs smoothly.

Thanks,
Madhusudhan