-- Licensed Materials - Property of IBM
-- 5724-I68
--
-- © Copyright IBM Corp. 2000, 2007 
--
-- US Government Users Restricted Rights - Use, duplication, or
-- disclosure restricted by GSA ADP Schedule Contract with IBM Corp.



update command options using c off;

-- ===================================================================
--
-- Table tctg_sel_selection
--
-- Contains generic selection information.
-- ===================================================================

drop table tctg_sel_selection;
create table tctg_sel_selection
( 
    sel_company_id                integer,
    sel_catalog_id                integer,
    sel_version_id                integer,
    sel_selection_name            varchar(100),
    sel_selection_id              integer,
    sel_selection_type            char,
    sel_cat_tree_id               integer,
    sel_hidden_flag               char,
    sel_object_group_id           integer
) 

in users index in indx;


drop synonym sel;
create synonym sel for tctg_sel_selection;

drop sequence qctg_sel_selection_id restrict;
create sequence qctg_sel_selection_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_dys_dynamic_selection
--
-- Contains dynamic selection query strings.
-- ===================================================================

drop table tctg_dys_dynamic_selection;
create table tctg_dys_dynamic_selection
( 
    dys_company_id                integer,
    dys_selection_id              integer,
    dys_query_string              varchar(900),
    dys_row_order                 integer
) 

in users index in indx;


drop synonym dys;
create synonym dys for tctg_dys_dynamic_selection;

-- ===================================================================
--
-- Table tctg_tss_template_search_sort
--
-- Contains sort parameters for a template for presetting in rich search UI.
-- ===================================================================

drop table tctg_tss_template_search_sort;
create table tctg_tss_template_search_sort
( 
    tss_company_id                integer,
    tss_catalog_id                integer,
    tss_template_id               integer,
    tss_user_id                   integer,
    tss_node_id                   integer,
    tss_sort_order                char
) 

in users index in indx;


drop synonym tss;
create synonym tss for tctg_tss_template_search_sort;

-- ===================================================================
--
-- Table tctg_tsd_template_search_data
--
-- Contains search criteria for a template for presetting in rich search UI.
-- ===================================================================

drop table tctg_tsd_template_search_data;
create table tctg_tsd_template_search_data
( 
    tsd_company_id                integer,
    tsd_catalog_id                integer,
    tsd_template_id               integer,
    tsd_user_id                   integer,
    tsd_node_id                   integer,
    tsd_included                  char,
    tsd_override                  char,
    tsd_negated                   char,
    tsd_operator                  integer,
    tsd_value_1_type              char,
    tsd_value_1                   varchar(1024),
    tsd_value_2                   varchar(1024)
) 

in users index in indx;


drop synonym tsd;
create synonym tsd for tctg_tsd_template_search_data;

-- ===================================================================
--
-- Table tctg_sit_selected_item
--
-- Contains the mapping of items  and selection_id.
-- ===================================================================

drop table tctg_sit_selected_item;
create table tctg_sit_selected_item
( 
    sit_company_id                integer,
    sit_selection_id              integer,
    sit_cat_tree_id               integer,
    sit_catalog_id                integer,
    sit_item_id                   integer
) 

in users index in indx;


drop synonym sit;
create synonym sit for tctg_sit_selected_item;

-- ===================================================================
--
-- Table tctg_sca_selected_category
--
-- Contains the cateogory ids of selected categories
-- ===================================================================

drop table tctg_sca_selected_category;
create table tctg_sca_selected_category
( 
    sca_company_id                integer,
    sca_selection_id              integer,
    sca_catalog_id                integer,
    sca_cat_tree_id               integer,
    sca_category_id               integer
) 

in users index in indx;


drop synonym sca;
create synonym sca for tctg_sca_selected_category;

-- ===================================================================
--
-- Table tctg_dso_data_source
--
-- Table holding the name, type of transfer, and company id for data sources.
-- ===================================================================

drop table tctg_dso_data_source;
create table tctg_dso_data_source
( 
    dso_id                        integer,
    dso_name                      varchar(200),
    dso_company_id                integer,
    dso_protocol_id               varchar(30)
) 

in users index in indx;


drop synonym dso;
create synonym dso for tctg_dso_data_source;

drop sequence qctg_dso_id restrict;
create sequence qctg_dso_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_dsd_data_source_details
--
-- Table holding the name / value pairs for the required parameters of a given data
-- source.
-- ===================================================================

drop table tctg_dsd_data_source_details;
create table tctg_dsd_data_source_details
( 
    dsd_datasource_id             integer,
    dsd_company_id                integer,
    dsd_name                      varchar(50),
    dsd_value                     varchar(2000)
) 

in users index in indx;


drop synonym dsd;
create synonym dsd for tctg_dsd_data_source_details;

-- ===================================================================
--
-- Table tctg_fee_feed
--
-- Table pulling together components of a data feed to Trigo
-- ===================================================================

drop table tctg_fee_feed;
create table tctg_fee_feed
( 
    fee_company_id                integer not null,
    fee_feed_id                   integer,
    fee_name                      varchar(100) not null,
    fee_feed_type                 varchar(30),
    fee_feed_semantics            varchar(30),
    fee_data_source_id            integer,
    fee_file_spec_id              integer,
    fee_script_path               varchar(256),
    fee_ctg_id                    integer,
    fee_spec_map_id               integer,
    fee_ctr_id                    integer,
    fee_doc_store_path            varchar(200),
    fee_fetch_job_id              integer,
    fee_load_job_id               integer,
    fee_request_id                integer,
    fee_charset_name              varchar(200),
    fee_extra_attribs             varchar(4000),
    fee_object_group_id           integer,
    constraint fee_0_pk
        primary key (fee_name, fee_company_id)
) 

in users index in indx;


drop synonym fee;
create synonym fee for tctg_fee_feed;

drop sequence qctg_fee_feed_id restrict;
create sequence qctg_fee_feed_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_ftf_fetched_files
--
-- Table that lists the files that have been fetched
-- ===================================================================

drop table tctg_ftf_fetched_files;
create table tctg_ftf_fetched_files
( 
    ftf_company_id                integer,
    ftf_feed_id                   integer,
    ftf_filename                  varchar(1000),
    ftf_doc_store_path            varchar(1000),
    ftf_date_fetched              timestamp
) 

in users index in indx;


drop synonym ftf;
create synonym ftf for tctg_ftf_fetched_files;

-- ===================================================================
--
-- Table tctg_syn_syndication
--
-- Table pulling together components of catalog data outflow from Trigo
-- ===================================================================

drop table tctg_syn_syndication;
create table tctg_syn_syndication
( 
    syn_company_id                integer,
    syn_syndication_id            integer,
    syn_type                      varchar(100),
    syn_mktplace_spec_id          integer,
    syn_script_path               varchar(256),
    syn_file_type                 varchar(200),
    syn_catalog_id                integer,
    syn_spec_map_id               integer,
    syn_version_id                integer,
    syn_cat_tree_id               integer,
    syn_version_id_2              integer,
    syn_diff_types                varchar(100),
    syn_selection_id              integer,
    syn_job_id                    integer,
    syn_distributions             varchar(3000),
    syn_distribution_groups       varchar(3000),
    syn_request_id                integer,
    syn_charset_name              varchar(200),
    syn_params_doc_path           varchar(3000),
    syn_name                      varchar(100)
) 

in users index in indx;


drop synonym syn;
create synonym syn for tctg_syn_syndication;

drop sequence qctg_syn_syndication_id restrict;
create sequence qctg_syn_syndication_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_cce_ctlg_ctlg_export
--
-- Table to support holding catalog to catalog export information
-- ===================================================================

drop table tctg_cce_ctlg_ctlg_export;
create table tctg_cce_ctlg_ctlg_export
( 
    cce_company_id                integer,
    cce_id                        integer,
    cce_name                      varchar(100),
    cce_type                      varchar(100),
    cce_src_catalog_id            integer,
    cce_src_selection_id          integer,
    cce_src_version_id            integer,
    cce_src_version_id2           integer,
    cce_dest_catalog_id           integer,
    cce_spec_map_id               integer,
    cce_diff_types                varchar(100),
    cce_job_id                    integer,
    cce_request_id                integer,
    cce_script_path               varchar(256),
    cce_params_doc_path           varchar(3000)
) 

in users index in indx;


drop synonym cce;
create synonym cce for tctg_cce_ctlg_ctlg_export;

drop sequence qctg_cce_id restrict;
create sequence qctg_cce_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_fi2_file
--
-- Contains basic information related to files (uploaded by suppliers or generated
-- by the system)
-- ===================================================================

drop table tctg_fi2_file;
create table tctg_fi2_file
( 
    fi2_file_id                   integer,
    fi2_company_id                integer,
    fi2_date_created              timestamp,
    fi2_type                      char
) 

in users index in indx;


drop synonym fi2;
create synonym fi2 for tctg_fi2_file;

drop sequence qctg_fi2_file_id restrict;
create sequence qctg_fi2_file_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_fia_file_attribute
--
-- Contains more attributes as name/value pairs for files (uploaded by suppliers or
-- generated by the system)
-- ===================================================================

drop table tctg_fia_file_attribute;
create table tctg_fia_file_attribute
( 
    fia_file_id                   integer,
    fia_company_id                integer,
    fia_attribute_name            varchar(4000),
    fia_attribute_value           varchar(4000)
) 

in users index in indx;


drop synonym fia;
create synonym fia for tctg_fia_file_attribute;

-- ===================================================================
--
-- Table tctg_ctg_catalog
--
-- A catalog has attributes as described in the tctg_caa_catalog_attributes table (caa).
-- A company has many catalogs.
-- A catalog name is unique to a company.  This is enforced.
-- A catalog id is unique.  This is enforced.
-- ===================================================================

drop table tctg_ctg_catalog;
create table tctg_ctg_catalog
( 
    ctg_company_id                integer not null,
    ctg_id                        integer not null,
    ctg_name                      varchar(100) not null,
    ctg_type                      varchar(100),
    ctg_object_group_id           integer,
    constraint ctg_0_pk
        primary key (ctg_id),
    constraint ctg_1_uk
        unique (ctg_company_id, ctg_name)
) 

in users index in indx;


drop synonym ctg;
create synonym ctg for tctg_ctg_catalog;

drop sequence qctg_ctg_id restrict;
create sequence qctg_ctg_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_caa_catalog_attributes
--
-- Extra attributes for a catalog are kept in name value pairs.
-- A name may exist multiple times for a particular catalog.
-- ===================================================================

drop table tctg_caa_catalog_attributes;
create table tctg_caa_catalog_attributes
( 
    caa_company_id                integer,
    caa_catalog_id                integer,
    caa_name                      varchar(100),
    caa_value                     varchar(800),
    caa_version_id                integer,
    caa_next_version_id           integer
) 

in users index in indx;


drop synonym caa;
create synonym caa for tctg_caa_catalog_attributes;

-- ===================================================================
--
-- Table tctg_ver_version
--
-- This table contains the version control information for catalogs/category trees/specs.
-- The version numbers span companies.
-- Just because a catalog/spec/category tree is tagged with a version does not necessarily mean any entries exist with this version id.
-- A newer version has a higher version number.
-- The sequence is incremented once here.  Look in the extra section for this module (last line of file).
-- ===================================================================

drop table tctg_ver_version;
create table tctg_ver_version
( 
    ver_company_id                integer,
    ver_object_id                 integer,
    ver_object_type               varchar(100),
    ver_id                        integer,
    ver_name                      varchar(200),
    ver_type                      varchar(100),
    ver_date                      timestamp
) 

in users index in indx;


drop synonym ver;
create synonym ver for tctg_ver_version;

drop sequence qctg_ver_id restrict;
create sequence qctg_ver_id start with 1 increment by 1 nocache;

-- ===================================================================
--
-- Table tctg_itm_item
--
-- This is the item table. We keep all attributes for an item whether inherited from the
-- catalog specification or from the set of categories the item belongs to in the item
-- attributes table. So we can have 2 items that belong to the same catalog but have
-- a different number of attributes.
-- ===================================================================

drop table tctg_itm_item;
create table tctg_itm_item
( 
    itm_company_id                integer not null,
    itm_id                        integer not null,
    itm_container_id              integer not null,
    itm_primary_key               varchar(300) not null,
    itm_version_id                integer,
    itm_next_version_id           integer not null,
    itm_status                    varchar(300),
    itm_collab_info               varchar(3000),
    itm_last_modified             bigint,
    constraint itm_0_pk
        primary key (itm_id, itm_next_version_id, itm_container_id, itm_company_id),
    constraint itm_1_uk
        unique (itm_container_id, itm_primary_key, itm_next_version_id)
) 

in users index in indx;


drop synonym itm;
create synonym itm for tctg_itm_item;

drop sequence qctg_itm_id restrict;
create sequence qctg_itm_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_itd_item_detail
--
-- This is the item detail table. It is versioned and contains possibly multiple rows of data
-- for a string representation of an item.
-- ===================================================================

drop table tctg_itd_item_detail;
create table tctg_itd_item_detail
( 
    itd_company_id                integer,
    itd_item_id                   integer,
    itd_container_id              integer,
    itd_blob                      blob (1G),
    itd_version_id                integer,
    itd_next_version_id           integer,
    itd_bit_varchar               long varchar for bit data
) 

in users index in indx;


drop synonym itd;
create synonym itd for tctg_itd_item_detail;

-- ===================================================================
--
-- Table tctg_ita_item_attributes
--
-- Table holding name value pairs for item attributes.  The type column tells you whether the
-- value for this attribute is of basic type numeric, string, or date.  The node id is the name
-- part of our name-value pair.  It is the id of the node of type attribute in a spec.  Please
-- read Versioning Howto.
-- NOTE: ADDING THE DBNAME ATTRIBUTE TO THE VALUE_NUMERIC COLUMN THE LENGTH FOR ORACLE WOULD BE
-- 38,12, AND FOR DB2 IT WILL BE 31, 12 ... DB LIMIT !!
-- NOTE: IF YOU CHANGE THIS CHANGE TCTG_CAB_CATEGORY_ATTRIBUTES TOO (SAME SETUP AS THIS)
-- 
-- ===================================================================

drop table tctg_ita_item_attributes;
create table tctg_ita_item_attributes
( 
    ita_company_id                integer,
    ita_catalog_id                integer,
    ita_item_id                   integer,
    ita_node_id                   integer,
    ita_value_numeric             decimal(31, 12),
    ita_value_string              varchar(4000),
    ita_version_id                integer,
    ita_next_version_id           integer,
    ita_occurrence_id             integer,
    ita_value_string_ignorecase   varchar(4000)
) 

in users index in indx;


drop synonym ita;
create synonym ita for tctg_ita_item_attributes;

-- ===================================================================
--
-- Table tctg_ctr_category_tree
--
-- Table holding the name and description of category trees.  A category tree name must be
-- unique for a company.  For non-company related trees, names must also be unique
-- (i.e. UNSPSC) company_id for trees that are not tied to a particular company should be given
-- a unique company_id.
-- ===================================================================

drop table tctg_ctr_category_tree;
create table tctg_ctr_category_tree
( 
    ctr_company_id                integer,
    ctr_id                        integer,
    ctr_name                      varchar(100),
    ctr_type                      varchar(100),
    ctr_object_group_id           integer
) 

in users index in indx;


drop synonym ctr;
create synonym ctr for tctg_ctr_category_tree;

drop sequence qctg_ctg_id restrict;
create sequence qctg_ctg_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_cta_categ_tree_attribute
--
-- Table holding the attribute name and value of category trees.
-- ===================================================================

drop table tctg_cta_categ_tree_attribute;
create table tctg_cta_categ_tree_attribute
( 
    cta_company_id                integer,
    cta_cat_tree_id               integer,
    cta_name                      varchar(100),
    cta_value                     varchar(880),
    cta_version_id                integer,
    cta_next_version_id           integer
) 

in users index in indx;


drop synonym cta;
create synonym cta for tctg_cta_categ_tree_attribute;

-- ===================================================================
--
-- Table tctg_cat_category
--
-- A category has attributes as described in the tctg_cga_cat_attribute.
-- IF YOU MAKE CHANGES ON THIS TABLE PLEASE RUN AN EXPLAIN PLAN FOR QUERIES in Category.java and CategoryTree.java
-- TO MAKE SURE THEY ARE STILL FAST.
-- ===================================================================

drop table tctg_cat_category;
create table tctg_cat_category
( 
    cat_company_id                integer not null,
    cat_id                        integer not null,
    cat_container_id              integer not null,
    cat_primary_key               varchar(300) not null,
    cat_version_id                integer,
    cat_next_version_id           integer not null,
    cat_status                    varchar(300),
    cat_collab_info               varchar(3000),
    cat_last_modified             bigint,
    constraint cat_0_pk
        primary key (cat_id, cat_next_version_id, cat_container_id, cat_company_id),
    constraint cat_1_uk
        unique (cat_container_id, cat_primary_key, cat_next_version_id)
) 

in users index in indx;


drop synonym cat;
create synonym cat for tctg_cat_category;

drop sequence qctg_itm_id restrict;
create sequence qctg_itm_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_cad_category_detail
--
-- This is the category detail table. It is versioned and contains possibly multiple rows of
-- data for a string representation of a category.
-- ===================================================================

drop table tctg_cad_category_detail;
create table tctg_cad_category_detail
( 
    cad_company_id                integer,
    cad_category_id               integer,
    cad_container_id              integer,
    cad_blob                      blob (1G),
    cad_version_id                integer,
    cad_next_version_id           integer,
    cad_bit_varchar               long varchar for bit data
) 

in users index in indx;


drop synonym cad;
create synonym cad for tctg_cad_category_detail;

-- ===================================================================
--
-- Table tctg_msq_multi_sequence
--
-- This table is used to get unique identifiers for
-- mulioccurrences in the serialized form found in cad
-- ===================================================================

drop table tctg_msq_multi_sequence;
create table tctg_msq_multi_sequence
( 
    msq_sequence                  integer
) 

in users index in indx;


drop synonym msq;
create synonym msq for tctg_msq_multi_sequence;

drop sequence qctg_msq_sequence restrict;
create sequence qctg_msq_sequence start with 1 increment by 200 nocache cycle minvalue 0 maxvalue 2147483647;

-- ===================================================================
--
-- Table tctg_cab_category_attributes
--
-- Table holding name value pairs for category attributes.  The type column tells you whether
-- the value for this attribute is of basic type numeric, string, or date.  The node id is the
-- name part of our name-value pair.  It is the id of the node of type attribute in a spec.
-- Please read Versioning Howto.
-- NOTE: ADDING THE DBNAME ATTRIBUTE TO THE VALUE_NUMERIC COLUMN THE LENGTH FOR ORACLE WOULD BE
-- 38,12, AND FOR DB2 IT WILL BE 31, 12 ... DB LIMIT !!
-- NOTE: IF YOU CHANGE THIS CHANGE TCTG_ITA_ITEM_ATTRIBUTES TOO (SAME SETUP AS THIS)
-- 
-- ===================================================================

drop table tctg_cab_category_attributes;
create table tctg_cab_category_attributes
( 
    cab_company_id                integer,
    cab_cat_tree_id               integer,
    cab_category_id               integer,
    cab_node_id                   integer,
    cab_value_numeric             decimal(31, 12),
    cab_value_string              varchar(4000),
    cab_version_id                integer,
    cab_next_version_id           integer,
    cab_occurrence_id             integer,
    cab_value_string_ignorecase   varchar(4000)
) 

in users index in indx;


drop synonym cab;
create synonym cab for tctg_cab_category_attributes;

-- ===================================================================
--
-- Table tctg_csm_category_spec_map
--
-- Table holding mapping between categories and specs
-- ===================================================================

drop table tctg_csm_category_spec_map;
create table tctg_csm_category_spec_map
( 
    csm_company_id                integer,
    csm_cat_tree_id               integer,
    csm_category_id               integer,
    csm_spec_id                   integer,
    csm_filter_catalog_id         integer,
    csm_version_id                integer,
    csm_next_version_id           integer
) 

in users index in indx;


drop synonym csm;
create synonym csm for tctg_csm_category_spec_map;

-- ===================================================================
--
-- Table tctg_csa_cat_sys_attr
--
-- Table holding the system (internal use only) attributes of a category -- name and value.
-- ===================================================================

drop table tctg_csa_cat_sys_attr;
create table tctg_csa_cat_sys_attr
( 
    csa_company_id                integer,
    csa_cat_tree_id               integer,
    csa_category_id               integer,
    csa_name                      varchar(100),
    csa_value                     varchar(850),
    csa_version_id                integer,
    csa_next_version_id           integer
) 

in users index in indx;


drop synonym csa;
create synonym csa for tctg_csa_cat_sys_attr;

-- ===================================================================
--
-- Table tctg_cfp_cat_full_paths
--
-- Table holding the full paths of a category.
-- Patrice & Saad: This should never be queried by anyone other than the search dynamic queries
-- ===================================================================

drop table tctg_cfp_cat_full_paths;
create table tctg_cfp_cat_full_paths
( 
    cfp_company_id                integer,
    cfp_cat_tree_id               integer not null,
    cfp_category_id               integer,
    cfp_full_path_type            varchar(100) not null,
    cfp_full_path                 varchar(850) not null,
    cfp_version_id                integer,
    cfp_next_version_id           integer not null,
    constraint cfp_0_pk
        primary key (cfp_full_path, cfp_full_path_type, cfp_next_version_id, cfp_cat_tree_id)
) 

in users index in indx;


drop synonym cfp;
create synonym cfp for tctg_cfp_cat_full_paths;

-- ===================================================================
--
-- Table tctg_chi_category_hierarchy
--
-- Mapping between a parent and child category
-- IF YOU MAKE CHANGES ON THIS TABLE PLEASE RUN AN EXPLAIN PLAN FOR QUERIES in Category.java and CategoryTree.java
-- TO MAKE SURE THEY ARE STILL FAST.
-- ===================================================================

drop table tctg_chi_category_hierarchy;
create table tctg_chi_category_hierarchy
( 
    chi_company_id                integer not null,
    chi_cat_tree_id               integer,
    chi_parent_id                 integer not null,
    chi_child_id                  integer not null,
    chi_version_id                integer,
    chi_next_version_id           integer not null,
    constraint chi_0_pk
        primary key (chi_parent_id, chi_child_id, chi_next_version_id, chi_company_id)
) 

in users index in indx;


drop synonym chi;
create synonym chi for tctg_chi_category_hierarchy;

-- ===================================================================
--
-- Table tctg_ccm_category_category_map
--
-- Mapping between a source and a destination category..
-- IF YOU MAKE CHANGES ON THIS TABLE PLEASE RUN AN EXPLAIN PLAN FOR QUERIES in Category.java and CategoryTree.java
-- TO MAKE SURE THEY ARE STILL FAST.
-- ===================================================================

drop table tctg_ccm_category_category_map;
create table tctg_ccm_category_category_map
( 
    ccm_company_id                integer,
    ccm_src_cat_tree_id           integer,
    ccm_src_category_id           integer,
    ccm_dst_cat_tree_id           integer,
    ccm_dst_category_id           integer,
    ccm_version_id                integer,
    ccm_next_version_id           integer
) 

in users index in indx;


drop synonym ccm;
create synonym ccm for tctg_ccm_category_category_map;

-- ===================================================================
--
-- Table tctg_icm_item_category_map
--
-- Creates the mapping between categories and their associated items. There is
-- a version_id field to make it possible to keep historical information and
-- make it possible to reassemble older versions of a catalog.
-- ***** If you change the indexes, change the where clauses of the queries and also look in com.ibm.ccd.content/xml/query/query_catalog.xml
-- and in Category.java,  CategoryTree.java, StaticSelectionBean.java
-- IF YOU MAKE CHANGES ON THIS TABLE PLEASE RUN AN EXPLAIN PLAN FOR QUERIES in Category.java,  CategoryTree.java and StaticSelectionBean.java
-- TO MAKE SURE THEY ARE STILL FAST.
-- ===================================================================

drop table tctg_icm_item_category_map;
create table tctg_icm_item_category_map
( 
    icm_company_id                integer not null,
    icm_catalog_id                integer,
    icm_item_id                   integer not null,
    icm_cat_tree_id               integer not null,
    icm_category_id               integer not null,
    icm_version_id                integer,
    icm_next_version_id           integer not null,
    constraint icm_0_pk
        primary key (icm_item_id, icm_next_version_id, icm_cat_tree_id, icm_category_id, icm_company_id)
) 

in users index in indx;


drop synonym icm;
create synonym icm for tctg_icm_item_category_map;

-- ===================================================================
--
-- Table tctg_spc_specification
--
-- The set of tables for specs is intended to model the XML Schema language. The idea
-- is to be able to describe all XML documents as well as most other document types
-- we will encounter. This is accomplished by having name-value pairs for the specs
-- to indicate what kind of file/catalog/database we are dealing with e.g. csv,
-- pipe-delimited, tab-delimited etc. The node hierarchy defined by the set of node,
-- node_attributes and node_hierarchy tables defines the actual details of the spec.
-- Things to look out for: one attribute of the nodes is expected to be TYPE which
-- tells you whether the node is an element/attribute/type; if we are dealing with
-- sequences / all / choice we put in attributes of the same names, but make their
-- values numbers in order - each node has one attribute of this kind; if we are
-- dealing with enumerations, we put in attributes with name ENUMERATION and put
-- in all the possible values as attributes of the node.
-- Please read Versioning Howto.
-- ===================================================================

drop table tctg_spc_specification;
create table tctg_spc_specification
( 
    spc_company_id                integer,
    spc_id                        integer,
    spc_name                      varchar(100),
    spc_xml                       varchar(3000)
) 

in users index in indx;


drop synonym spc;
create synonym spc for tctg_spc_specification;

drop sequence qctg_spc_id restrict;
create sequence qctg_spc_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_spa_spec_attributes
--
-- Please read spec information.
-- ===================================================================

drop table tctg_spa_spec_attributes;
create table tctg_spa_spec_attributes
( 
    spa_company_id                integer,
    spa_spec_id                   integer,
    spa_name                      varchar(100),
    spa_value                     varchar(3000),
    spa_order                     integer,
    spa_version_id                integer,
    spa_next_version_id           integer
) 

in users index in indx;


drop synonym spa;
create synonym spa for tctg_spa_spec_attributes;

-- ===================================================================
--
-- Table tctg_nod_node
--
-- Please read spec information.
-- ===================================================================

drop table tctg_nod_node;
create table tctg_nod_node
( 
    nod_company_id                integer not null,
    nod_spec_id                   integer not null,
    nod_id                        integer not null,
    nod_type                      varchar(100),
    nod_name                      varchar(800),
    nod_version_id                integer,
    nod_next_version_id           integer not null,
    constraint nod_0_pk
        primary key (nod_id, nod_next_version_id, nod_spec_id, nod_company_id)
) 

in users index in indx;


drop synonym nod;
create synonym nod for tctg_nod_node;

drop sequence qctg_nod_id restrict;
create sequence qctg_nod_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_noa_node_attributes
--
-- Please read spec information.
-- ===================================================================

drop table tctg_noa_node_attributes;
create table tctg_noa_node_attributes
( 
    noa_company_id                integer,
    noa_spec_id                   integer,
    noa_node_id                   integer,
    noa_name                      varchar(100),
    noa_value                     varchar(3000),
    noa_order                     integer,
    noa_version_id                integer,
    noa_next_version_id           integer
) 

in users index in indx;


drop synonym noa;
create synonym noa for tctg_noa_node_attributes;

-- ===================================================================
--
-- Table tctg_noh_node_hierarchy
--
-- Please read spec information.
-- ===================================================================

drop table tctg_noh_node_hierarchy;
create table tctg_noh_node_hierarchy
( 
    noh_company_id                integer not null,
    noh_spec_id                   integer not null,
    noh_parent_node_id            integer,
    noh_child_node_id             integer,
    noh_order                     integer not null,
    noh_version_id                integer,
    noh_next_version_id           integer not null,
    constraint noh_0_pk
        primary key (noh_spec_id, noh_next_version_id, noh_order, noh_company_id)
) 

in users index in indx;


drop synonym noh;
create synonym noh for tctg_noh_node_hierarchy;

-- ===================================================================
--
-- Table tctg_nom_node_mapping
--
-- Table to keep track of which nodes in master specs were from subspecs - required
-- now becuase the master spec doesn't point directly at the subspec and this table
-- will allow us to map between the two
-- ===================================================================

drop table tctg_nom_node_mapping;
create table tctg_nom_node_mapping
( 
    nom_company_id                integer,
    nom_sub_spec_id               integer,
    nom_sub_spec_node_id          integer,
    nom_master_spec_id            integer,
    nom_master_spec_node_id       integer,
    nom_version_id                integer,
    nom_next_version_id           integer
) 

in users index in indx;


drop synonym nom;
create synonym nom for tctg_nom_node_mapping;

-- ===================================================================
--
-- Table tctg_obm_object_map
--
-- This table defines the name and id for a map between two objects driven by specs, such as imports and exports
-- ===================================================================

drop table tctg_obm_object_map;
create table tctg_obm_object_map
( 
    obm_company_id                integer,
    obm_id                        integer,
    obm_name                      varchar(256),
    obm_type                      varchar(100),
    obm_src_object_id             integer,
    obm_dst_object_id             integer,
    obm_version_id                integer,
    obm_next_version_id           integer
) 

in users index in indx;


drop synonym obm;
create synonym obm for tctg_obm_object_map;

drop sequence qctg_obm_id restrict;
create sequence qctg_obm_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_omd_object_map_detail
--
-- This table holds the individual source node to
-- destination mappings
-- ===================================================================

drop table tctg_omd_object_map_detail;
create table tctg_omd_object_map_detail
( 
    omd_company_id                integer,
    omd_object_map_id             integer,
    omd_src_object_id             integer,
    omd_src_node_id               integer,
    omd_dst_object_id             integer,
    omd_dst_node_id               integer,
    omd_version_id                integer,
    omd_next_version_id           integer
) 

in users index in indx;


drop synonym omd;
create synonym omd for tctg_omd_object_map_detail;

-- ===================================================================
--
-- Table tctg_oms_object_map_scripts
--
-- This table holds the scripts associated with
-- the map between two objects driven by specs. This table holds
-- a script path for each destination node in the object
-- map
-- ===================================================================

drop table tctg_oms_object_map_scripts;
create table tctg_oms_object_map_scripts
( 
    oms_company_id                integer,
    oms_object_map_id             integer,
    oms_dst_object_id             integer,
    oms_dst_node_id               integer,
    oms_script_path               varchar(4000),
    oms_version_id                integer,
    oms_next_version_id           integer
) 

in users index in indx;


drop synonym oms;
create synonym oms for tctg_oms_object_map_scripts;

-- ===================================================================
--
-- Table tctg_ctm_categorization_map
--
-- Table holds the categorization maps
-- ===================================================================

drop table tctg_ctm_categorization_map;
create table tctg_ctm_categorization_map
( 
    ctm_company_id                integer,
    ctm_categmap_id               integer not null,
    ctm_categmap_name             varchar(300),
    ctm_filespec_id               integer,
    ctm_cattree_id                integer,
    ctm_deffile_attr              varchar(300),
    ctm_object_group_id           integer,
    constraint ctm_0_pk
        primary key (ctm_categmap_id)
) 

in users index in indx;


drop synonym ctm;
create synonym ctm for tctg_ctm_categorization_map;

drop sequence qctg_ctm_categmap_id restrict;
create sequence qctg_ctm_categmap_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_cmd_categmap_detail
--
-- Table holds categorization map details
-- ===================================================================

drop table tctg_cmd_categmap_detail;
create table tctg_cmd_categmap_detail
( 
    cmd_company_id                integer,
    cmd_categmap_id               integer,
    cmd_detail_id                 integer not null,
    cmd_file_attr                 varchar(300),
    cmd_isRegExp                  varchar(5),
    cmd_expression                varchar(300),
    constraint cmd_0_pk
        primary key (cmd_detail_id)
) 

in users index in indx;


drop synonym cmd;
create synonym cmd for tctg_cmd_categmap_detail;

drop sequence qctg_cmd_detail_id restrict;
create sequence qctg_cmd_detail_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_cmc_categmap_categories
--
-- Table holds the categories which specific mapping is mapped to
-- ===================================================================

drop table tctg_cmc_categmap_categories;
create table tctg_cmc_categmap_categories
( 
    cmc_company_id                integer,
    cmc_detail_id                 integer,
    cmc_category_id               integer
) 

in users index in indx;


drop synonym cmc;
create synonym cmc for tctg_cmc_categmap_categories;

-- ===================================================================
--
-- Table tctg_cgm_catalog_catalog_map
--
-- Contains mappings betweens catalogs.
-- ===================================================================

drop table tctg_cgm_catalog_catalog_map;
create table tctg_cgm_catalog_catalog_map
( 
    cgm_company_id                integer,
    cgm_src_ctg_id                integer,
    cgm_src_node_id               integer,
    cgm_dst_ctg_id                integer,
    cgm_dst_node_id               integer,
    cgm_version_id                integer,
    cgm_next_version_id           integer
) 

in users index in indx;


drop synonym cgm;
create synonym cgm for tctg_cgm_catalog_catalog_map;

-- ===================================================================
--
-- Table tctg_seq_sequence
--
-- This table contains the current value of the sequence for a
-- node id in an object - the object can be any spec driven
-- object
-- ===================================================================

drop table tctg_seq_sequence;
create table tctg_seq_sequence
( 
    seq_company_id                integer,
    seq_object_id                 integer not null,
    seq_object_type               varchar(100) not null,
    seq_name                      varchar(900) not null,
    seq_increment                 bigint,
    seq_value                     bigint,
    constraint seq_0_pk
        primary key (seq_object_id, seq_object_type, seq_name)
) 

in users index in indx;


drop synonym seq;
create synonym seq for tctg_seq_sequence;

-- ===================================================================
--
-- Table tctg_epr_entry_processor_run
--
-- Keep info for latest entry processor runs.
-- ===================================================================

drop table tctg_epr_entry_processor_run;
create table tctg_epr_entry_processor_run
( 
    epr_run_id                    integer,
    epr_company_id                integer,
    epr_user_id                   integer,
    epr_type                      varchar(128),
    epr_entry_cnt                 integer,
    epr_start_time                timestamp,
    epr_completion_time           timestamp,
    epr_digest                    varchar(3000),
    epr_status                    char,
    epr_container_type            varchar(128),
    epr_container_id              integer
) 

in users index in indx;


drop synonym epr;
create synonym epr for tctg_epr_entry_processor_run;

drop sequence qctg_epr_run_id restrict;
create sequence qctg_epr_run_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_rul_inheritance_rule
--
-- This table keeps the src defn of rules.  One row per node_id for a ctg or ctr.
-- ===================================================================

drop table tctg_rul_inheritance_rule;
create table tctg_rul_inheritance_rule
( 
    rul_company_id                integer not null,
    rul_id                        integer,
    rul_name                      varchar(900) not null,
    rul_src_ctg_id                integer,
    rul_src_ctr_id                integer,
    rul_collab_id                 integer not null,
    rul_version_id                integer,
    rul_next_version_id           integer not null,
    constraint rul_0_uk
        unique (rul_company_id, rul_name, rul_collab_id, rul_next_version_id)
) 

in users index in indx;


drop synonym rul;
create synonym rul for tctg_rul_inheritance_rule;

drop sequence qctg_rul_id restrict;
create sequence qctg_rul_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_rgm_rul_group_map
--

-- ===================================================================

drop table tctg_rgm_rul_group_map;
create table tctg_rgm_rul_group_map
( 
    rgm_company_id                integer,
    rgm_rule_id                   integer,
    rgm_attr_group_id             integer,
    rgm_version_id                integer,
    rgm_next_version_id           integer
) 

in users index in indx;


drop synonym rgm;
create synonym rgm for tctg_rgm_rul_group_map;

-- ===================================================================
--
-- Table tctg_udl_user_defined_logs
--

-- ===================================================================

drop table tctg_udl_user_defined_logs;
create table tctg_udl_user_defined_logs
( 
    udl_company_id                integer not null,
    udl_id                        integer,
    udl_name                      varchar(200) not null,
    udl_container_id              integer not null,
    udl_container_type            varchar(128) not null,
    udl_description               varchar(3000),
    udl_running_log               char,
    udl_table_name                varchar(128),
    constraint udl_0_pk
        primary key (udl_company_id, udl_container_type, udl_container_id, udl_name)
) 

in users index in indx;


drop synonym udl;
create synonym udl for tctg_udl_user_defined_logs;

drop sequence qctg_udl_id restrict;
create sequence qctg_udl_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_ule_user_log_entry_
--

-- ===================================================================

drop table tctg_ule_user_log_entry_;
create table tctg_ule_user_log_entry_
( 
    ule_log_entry_id              integer,
    ule_date                      timestamp,
    ule_container_id              integer,
    ule_entry_id                  integer,
    ule_log                       varchar(3000),
    ule_category_id               integer,
    ule_multi_row_order           integer
) 

in users index in indx;


drop synonym ule;
create synonym ule for tctg_ule_user_log_entry_;

drop sequence qctg_ule_log_entry_id restrict;
create sequence qctg_ule_log_entry_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_tmt_test_multi_row
--
-- Table for a sample of multi row stuff.
-- ===================================================================

drop table tctg_tmt_test_multi_row;
create table tctg_tmt_test_multi_row
( 
    tmt_company_id                integer,
    tmt_catalog_id                integer,
    tmt_item_id                   integer,
    tmt_node_id                   integer,
    tmt_type                      varchar(100),
    tmt_value_numeric             decimal(31, 8),
    tmt_value_string              varchar(3000),
    tmt_value_date                timestamp,
    tmt_version_id                integer,
    tmt_next_version_id           integer,
    tmt_order                     integer,
    tmt_parent_order              integer,
    tmt_row_order                 integer
) 

in users index in indx;


drop synonym tmt;
create synonym tmt for tctg_tmt_test_multi_row;

-- ===================================================================
--
-- Table tctg_etp_entry_tabbed_pane
--
-- Table associating scripts and entry node ids with tabbed pane
-- ===================================================================

drop table tctg_etp_entry_tabbed_pane;
create table tctg_etp_entry_tabbed_pane
( 
    etp_company_id                integer,
    etp_ctg_view_id               integer,
    etp_ctg_sub_view_id           integer,
    etp_tab_id                    integer,
    etp_tab_name                  varchar(80),
    etp_tab_order                 integer,
    etp_container_type            varchar(128),
    etp_container_id              integer,
    etp_tab_attr_order            varchar(100)
) 

in users index in indx;


drop synonym etp;
create synonym etp for tctg_etp_entry_tabbed_pane;

drop sequence qctg_etp_tab_id restrict;
create sequence qctg_etp_tab_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_tpa_tabbed_pane_attr
--
-- Table associating scripts and entry node ids with tabbed pane
-- ===================================================================

drop table tctg_tpa_tabbed_pane_attr;
create table tctg_tpa_tabbed_pane_attr
( 
    tpa_company_id                integer,
    tpa_tab_id                    integer,
    tpa_attr_group_id             integer,
    tpa_order                     integer
) 

in users index in indx;


drop synonym tpa;
create synonym tpa for tctg_tpa_tabbed_pane_attr;

-- ===================================================================
--
-- Table tctg_ord_ordering
--
-- Table defining orderings of a catalog within a particular category trees
-- ===================================================================

drop table tctg_ord_ordering;
create table tctg_ord_ordering
( 
    ord_company_id                integer,
    ord_id                        integer,
    ord_name                      varchar(256),
    ord_catalog_id                integer,
    ord_cat_tree_id               integer
) 

in users index in indx;


drop synonym ord;
create synonym ord for tctg_ord_ordering;

drop sequence qctg_ord_id restrict;
create sequence qctg_ord_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_odd_ord_detail
--
-- Table defining the detail of orderings of a catalog within a particular category trees.
-- ===================================================================

drop table tctg_odd_ord_detail;
create table tctg_odd_ord_detail
( 
    odd_company_id                integer,
    odd_ord_id                    integer,
    odd_catalog_id                integer,
    odd_cat_tree_id               integer,
    odd_parent_id                 integer,
    odd_child_id                  integer,
    odd_type                      varchar(100),
    odd_version_id                integer,
    odd_next_version_id           integer,
    odd_prev_id                   integer
) 

in users index in indx;


drop synonym odd;
create synonym odd for tctg_odd_ord_detail;

-- ===================================================================
--
-- Table tctg_atg_attr_group
--

-- ===================================================================

drop table tctg_atg_attr_group;
create table tctg_atg_attr_group
( 
    atg_id                        integer not null,
    atg_company_id                integer not null,
    atg_name                      varchar(420) not null,
    atg_type                      varchar(100),
    atg_description               varchar(3000),
    constraint atg_0_pk
        primary key (atg_id),
    constraint atg_1_uk
        unique (atg_company_id, atg_name)
) 

in users index in indx;


drop synonym atg;
create synonym atg for tctg_atg_attr_group;

drop sequence qctg_atg_id restrict;
create sequence qctg_atg_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_agn_attr_group_node
--

-- ===================================================================

drop table tctg_agn_attr_group_node;
create table tctg_agn_attr_group_node
( 
    agn_attr_group_id             integer not null,
    agn_company_id                integer,
    agn_spec_id                   integer not null,
    agn_node_id                   integer not null,
    agn_included                  char,
    agn_version_id                integer,
    agn_next_version_id           integer not null,
    constraint agn_0_uk
        unique (agn_attr_group_id, agn_spec_id, agn_node_id, agn_next_version_id)
) 

in users index in indx;


drop synonym agn;
create synonym agn for tctg_agn_attr_group_node;

-- ===================================================================
--
-- Table tctg_agl_attr_group_locale
--

-- ===================================================================

drop table tctg_agl_attr_group_locale;
create table tctg_agl_attr_group_locale
( 
    agl_attr_group_id             integer not null,
    agl_company_id                integer,
    agl_locale                    varchar(100) not null,
    agl_version_id                integer,
    agl_next_version_id           integer not null,
    constraint agl_0_uk
        unique (agl_attr_group_id, agl_locale, agl_next_version_id)
) 

in users index in indx;


drop synonym agl;
create synonym agl for tctg_agl_attr_group_locale;

-- ===================================================================
--
-- Table tctg_agd_attr_group_dyn_node
--

-- ===================================================================

drop table tctg_agd_attr_group_dyn_node;
create table tctg_agd_attr_group_dyn_node
( 
    agd_attr_group_id             integer not null,
    agd_company_id                integer,
    agd_spec_id                   integer not null,
    agd_node_id                   integer not null,
    agd_version_id                integer,
    agd_next_version_id           integer not null,
    constraint agd_0_uk
        unique (agd_attr_group_id, agd_spec_id, agd_node_id, agd_next_version_id)
) 

in users index in indx;


drop synonym agd;
create synonym agd for tctg_agd_attr_group_dyn_node;

-- ===================================================================
--
-- Table tctg_sim_status_image_map
--

-- ===================================================================

drop table tctg_sim_status_image_map;
create table tctg_sim_status_image_map
( 
    sim_company_id                integer,
    sim_object_container_id       integer,
    sim_object_type               varchar(50),
    sim_status                    varchar(300),
    sim_image_url                 varchar(500)
) 

in users index in indx;


drop synonym sim;
create synonym sim for tctg_sim_status_image_map;

-- ===================================================================
--
-- Table tctg_rec_relation_container
--

-- ===================================================================

drop table tctg_rec_relation_container;
create table tctg_rec_relation_container
( 
    rec_company_id                integer,
    rec_id                        integer not null,
    rec_ctg_id                    integer not null,
    rec_ctr_id                    integer not null,
    constraint rec_0_pk
        primary key (rec_id),
    constraint rec_1_uk
        unique (rec_ctg_id, rec_ctr_id)
) 

in users index in indx;


drop synonym rec;
create synonym rec for tctg_rec_relation_container;

drop sequence qctg_ctg_id restrict;
create sequence qctg_ctg_id start with 1 increment by 200 nocache;

-- ===================================================================
--
-- Table tctg_rea_relation_attributes
--
-- Extra attributes for a catalog are kept in name value pairs.
-- A name may exist multiple times for a particular catalog.
-- ===================================================================

drop table tctg_rea_relation_attributes;
create table tctg_rea_relation_attributes
( 
    rea_company_id                integer,
    rea_relation_id               integer,
    rea_name                      varchar(100),
    rea_value                     varchar(800),
    rea_version_id                integer,
    rea_next_version_id           integer
) 

in users index in indx;


drop synonym rea;
create synonym rea for tctg_rea_relation_attributes;

-- ===================================================================
--
-- Table tctg_esr_entry_search_result
--
-- Entry search result.
-- ===================================================================

drop table tctg_esr_entry_search_result;
create table tctg_esr_entry_search_result
( 
    esr_company_id                integer,
    esr_entry_id                  integer,
    esr_sel_id                    integer,
    esr_ctg_id                    integer,
    esr_data                      varchar(3000),
    esr_row_order                 integer
) 

in users index in indx;


drop synonym esr;
create synonym esr for tctg_esr_entry_search_result;

insert into ver (ver_id) values(nextval for qctg_ver_id);
insert into ver (ver_id) values(nextval for qctg_ver_id);
insert into ver (ver_id) values(nextval for qctg_ver_id);
insert into ver (ver_id) values(nextval for qctg_ver_id);
drop sequence qctg_agg_aggregation_queue_seq restrict;
create sequence qctg_agg_aggregation_queue_seq start with 1 increment by 1 nocache;
drop sequence qctg_lkp_updates restrict;
create sequence qctg_lkp_updates start with 1 increment by 1 nocache;

commit;

update command options using c on;

terminate;