-- IBM Confidential
-- OCO Source Materials
-- 5724-I68.
-- (C) Copyright IBM Corp. 2000, 2004 - All Rights Reserved.
-- US Government Users Restricted Rights - Use, duplication or disclosure 
-- restricted by GSA ADP Schedule Contract with IBM Corp. 
-- This file is generated by GenSchema!! DO NOT EDIT!!!
-- This file is generated by GenSchema!! DO NOT EDIT!!!


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

drop table tctg_sel_selection cascade constraints;
create table tctg_sel_selection
( 
    sel_company_id                number(9, 0),
    sel_catalog_id                number(9, 0),
    sel_version_id                number(9, 0),
    sel_selection_name            varchar2(100),
    sel_selection_id              number(9, 0),
    sel_selection_type            char,
    sel_cat_tree_id               number(9, 0),
    sel_hidden_flag               char,
    sel_object_group_id           number(9, 0)
) 
tablespace users;


drop synonym sel;
create synonym sel for tctg_sel_selection;

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

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

drop table tctg_sit_selected_item cascade constraints;
create table tctg_sit_selected_item
( 
    sit_company_id                number(9, 0),
    sit_selection_id              number(9, 0),
    sit_cat_tree_id               number(9, 0),
    sit_catalog_id                number(9, 0),
    sit_item_id                   number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_sca_selected_category
( 
    sca_company_id                number(9, 0),
    sca_selection_id              number(9, 0),
    sca_catalog_id                number(9, 0),
    sca_cat_tree_id               number(9, 0),
    sca_category_id               number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_dso_data_source
( 
    dso_id                        number(9),
    dso_name                      varchar2(200),
    dso_company_id                number(9),
    dso_protocol_id               varchar2(30)
) 
tablespace users;


drop synonym dso;
create synonym dso for tctg_dso_data_source;

drop sequence qctg_dso_id;
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 cascade constraints;
create table tctg_dsd_data_source_details
( 
    dsd_datasource_id             number(9),
    dsd_company_id                number(9),
    dsd_name                      varchar2(50),
    dsd_value                     varchar2(2000)
) 
tablespace users;


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 cascade constraints;
create table tctg_fee_feed
( 
    fee_company_id                number(9) not null,
    fee_feed_id                   number(9),
    fee_name                      varchar2(100) not null,
    fee_feed_type                 varchar2(30),
    fee_feed_semantics            varchar2(30),
    fee_data_source_id            number(9),
    fee_file_spec_id              number(9),
    fee_script_path               varchar2(256),
    fee_ctg_id                    number(9),
    fee_spec_map_id               number(9),
    fee_ctr_id                    number(9),
    fee_doc_store_path            varchar2(200),
    fee_fetch_job_id              number(9),
    fee_load_job_id               number(9),
    fee_request_id                number(9),
    fee_charset_name              varchar2(200),
    fee_extra_attribs             varchar2(4000),
    fee_object_group_id           number(9, 0),
    constraint fee_0_pk
        primary key (fee_name, fee_company_id)
) 
tablespace users;


drop synonym fee;
create synonym fee for tctg_fee_feed;

drop sequence qctg_fee_feed_id;
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 cascade constraints;
create table tctg_ftf_fetched_files
( 
    ftf_company_id                number(9),
    ftf_feed_id                   number(9),
    ftf_filename                  varchar2(1000),
    ftf_doc_store_path            varchar2(1000),
    ftf_date_fetched              date
) 
tablespace users;


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 cascade constraints;
create table tctg_syn_syndication
( 
    syn_company_id                number(9),
    syn_syndication_id            number(9),
    syn_type                      varchar2(100),
    syn_mktplace_spec_id          number(9),
    syn_script_path               varchar2(256),
    syn_file_type                 varchar2(100),
    syn_catalog_id                number(9),
    syn_spec_map_id               number(9),
    syn_version_id                number(9),
    syn_cat_tree_id               number(9),
    syn_version_id_2              number(9),
    syn_diff_types                varchar2(100),
    syn_selection_id              number(9),
    syn_job_id                    number(9),
    syn_distributions             varchar2(3000),
    syn_distribution_groups       varchar2(3000),
    syn_request_id                number(9),
    syn_charset_name              varchar2(200),
    syn_params_doc_path           varchar2(3000),
    syn_name                      varchar2(100)
) 
tablespace users;


drop synonym syn;
create synonym syn for tctg_syn_syndication;

drop sequence qctg_syn_syndication_id;
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 cascade constraints;
create table tctg_cce_ctlg_ctlg_export
( 
    cce_company_id                number(9),
    cce_id                        number(9),
    cce_name                      varchar2(100),
    cce_type                      varchar2(100),
    cce_src_catalog_id            number(9),
    cce_src_selection_id          number(9),
    cce_src_version_id            number(9),
    cce_src_version_id2           number(9),
    cce_dest_catalog_id           number(9),
    cce_spec_map_id               number(9),
    cce_diff_types                varchar2(100),
    cce_job_id                    number(9),
    cce_request_id                number(9),
    cce_script_path               varchar2(256),
    cce_params_doc_path           varchar2(3000)
) 
tablespace users;


drop synonym cce;
create synonym cce for tctg_cce_ctlg_ctlg_export;

drop sequence qctg_cce_id;
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 cascade constraints;
create table tctg_fi2_file
( 
    fi2_file_id                   number(9, 0),
    fi2_company_id                number(9, 0),
    fi2_date_created              date,
    fi2_type                      char
) 
tablespace users;


drop synonym fi2;
create synonym fi2 for tctg_fi2_file;

drop sequence qctg_fi2_file_id;
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 cascade constraints;
create table tctg_fia_file_attribute
( 
    fia_file_id                   number(9, 0),
    fia_company_id                number(9, 0),
    fia_attribute_name            varchar2(4000),
    fia_attribute_value           varchar2(4000)
) 
tablespace users;


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 cascade constraints;
create table tctg_ctg_catalog
( 
    ctg_company_id                number(9, 0) not null,
    ctg_id                        number(9, 0) not null,
    ctg_name                      varchar2(100) not null,
    ctg_type                      varchar2(100),
    ctg_object_group_id           number(9, 0),
    constraint ctg_0_pk
        primary key (ctg_id),
    constraint ctg_1_uk
        unique (ctg_company_id, ctg_name)
) 
tablespace users;


drop synonym ctg;
create synonym ctg for tctg_ctg_catalog;

drop sequence qctg_ctg_id;
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 cascade constraints;
create table tctg_caa_catalog_attributes
( 
    caa_company_id                number(9, 0),
    caa_catalog_id                number(9, 0),
    caa_name                      varchar2(100),
    caa_value                     varchar2(800),
    caa_version_id                number(9, 0),
    caa_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_ver_version
( 
    ver_company_id                number(9, 0),
    ver_object_id                 number(9, 0),
    ver_object_type               varchar2(100),
    ver_id                        number(9, 0),
    ver_name                      varchar2(100),
    ver_type                      varchar2(100),
    ver_date                      date
) 
tablespace users;


drop synonym ver;
create synonym ver for tctg_ver_version;

drop sequence qctg_ver_id;
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 cascade constraints;
create table tctg_itm_item
( 
    itm_company_id                number(9, 0),
    itm_id                        number(9, 0),
    itm_container_id              number(9, 0) not null,
    itm_primary_key               varchar2(300) not null,
    itm_version_id                number(9, 0),
    itm_next_version_id           number(9, 0) not null,
    itm_status                    varchar2(300),
    itm_collab_info               varchar2(3000),
    itm_last_modified             number(13, 0),
    constraint itm_1_uk
        unique (itm_container_id, itm_primary_key, itm_next_version_id)
) 
tablespace users;


drop synonym itm;
create synonym itm for tctg_itm_item;

drop sequence qctg_itm_id;
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 cascade constraints;
create table tctg_itd_item_detail
( 
    itd_company_id                number(9, 0),
    itd_item_id                   number(9, 0),
    itd_container_id              number(9, 0),
    itd_blob                      blob,
    itd_version_id                number(9, 0),
    itd_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_ita_item_attributes
( 
    ita_company_id                number(9, 0),
    ita_catalog_id                number(9, 0),
    ita_item_id                   number(9, 0),
    ita_node_id                   number(9, 0),
    ita_value_numeric             number(38, 12),
    ita_value_string              varchar2(3000),
    ita_version_id                number(9, 0),
    ita_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_ctr_category_tree
( 
    ctr_company_id                number(9),
    ctr_id                        number(9),
    ctr_name                      varchar2(100),
    ctr_type                      varchar2(100),
    ctr_object_group_id           number(9, 0)
) 
tablespace users;


drop synonym ctr;
create synonym ctr for tctg_ctr_category_tree;

drop sequence qctg_ctg_id;
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 cascade constraints;
create table tctg_cta_categ_tree_attribute
( 
    cta_company_id                number(9),
    cta_cat_tree_id               number(9),
    cta_name                      varchar2(100),
    cta_value                     varchar2(880),
    cta_version_id                number(9, 0),
    cta_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_cat_category
( 
    cat_company_id                number(9),
    cat_id                        number(9),
    cat_container_id              number(9) not null,
    cat_primary_key               varchar2(300) not null,
    cat_version_id                number(9, 0),
    cat_next_version_id           number(9, 0) not null,
    cat_status                    varchar2(300),
    cat_collab_info               varchar2(3000),
    cat_last_modified             number(13, 0),
    constraint cat_1_uk
        unique (cat_container_id, cat_primary_key, cat_next_version_id)
) 
tablespace users;


drop synonym cat;
create synonym cat for tctg_cat_category;

drop sequence qctg_itm_id;
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 cascade constraints;
create table tctg_cad_category_detail
( 
    cad_company_id                number(9, 0),
    cad_category_id               number(9, 0),
    cad_container_id              number(9, 0),
    cad_blob                      blob,
    cad_version_id                number(9, 0),
    cad_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_msq_multi_sequence
( 
    msq_sequence                  number(9, 0)
) 
tablespace users;


drop synonym msq;
create synonym msq for tctg_msq_multi_sequence;

drop sequence qctg_msq_sequence;
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 cascade constraints;
create table tctg_cab_category_attributes
( 
    cab_company_id                number(9, 0),
    cab_cat_tree_id               number(9, 0),
    cab_category_id               number(9, 0),
    cab_node_id                   number(9, 0),
    cab_value_numeric             number(38, 12),
    cab_value_string              varchar2(3000),
    cab_version_id                number(9, 0),
    cab_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_csm_category_spec_map
( 
    csm_company_id                number(9),
    csm_cat_tree_id               number(9),
    csm_category_id               number(9),
    csm_spec_id                   number(9),
    csm_filter_catalog_id         number(9),
    csm_version_id                number(9, 0),
    csm_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_csa_cat_sys_attr
( 
    csa_company_id                number(9),
    csa_cat_tree_id               number(9),
    csa_category_id               number(9),
    csa_name                      varchar2(100),
    csa_value                     varchar2(850),
    csa_version_id                number(9, 0),
    csa_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_cfp_cat_full_paths
( 
    cfp_company_id                number(9),
    cfp_cat_tree_id               number(9) not null,
    cfp_category_id               number(9),
    cfp_full_path_type            varchar2(100) not null,
    cfp_full_path                 varchar2(850) not null,
    cfp_version_id                number(9, 0),
    cfp_next_version_id           number(9, 0) not null,
    constraint cfp_0_uk
        unique (cfp_cat_tree_id, cfp_full_path_type, cfp_full_path, cfp_next_version_id)
) 
tablespace users;


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 cascade constraints;
create table tctg_chi_category_hierarchy
( 
    chi_company_id                number(9),
    chi_cat_tree_id               number(9, 0),
    chi_parent_id                 number(9, 0),
    chi_child_id                  number(9, 0),
    chi_version_id                number(9, 0),
    chi_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_ccm_category_category_map
( 
    ccm_company_id                number(9),
    ccm_src_cat_tree_id           number(9, 0),
    ccm_src_category_id           number(9, 0),
    ccm_dst_cat_tree_id           number(9, 0),
    ccm_dst_category_id           number(9, 0),
    ccm_version_id                number(9, 0),
    ccm_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_icm_item_category_map
( 
    icm_company_id                number(9),
    icm_catalog_id                number(9),
    icm_item_id                   number(9, 0),
    icm_cat_tree_id               number(9, 0),
    icm_category_id               number(9, 0),
    icm_version_id                number(9, 0),
    icm_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_spc_specification
( 
    spc_company_id                number(9, 0),
    spc_id                        number(9, 0),
    spc_name                      varchar2(100),
    spc_xml                       varchar2(3000)
) 
tablespace users;


drop synonym spc;
create synonym spc for tctg_spc_specification;

drop sequence qctg_spc_id;
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 cascade constraints;
create table tctg_spa_spec_attributes
( 
    spa_company_id                number(9, 0),
    spa_spec_id                   number(9, 0),
    spa_name                      varchar2(100),
    spa_value                     varchar2(887),
    spa_order                     number(9, 0),
    spa_version_id                number(9, 0),
    spa_next_version_id           number(9, 0)
) 
tablespace users;


drop synonym spa;
create synonym spa for tctg_spa_spec_attributes;

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

drop table tctg_nod_node cascade constraints;
create table tctg_nod_node
( 
    nod_company_id                number(9, 0),
    nod_spec_id                   number(9, 0),
    nod_id                        number(9, 0),
    nod_type                      varchar2(100),
    nod_name                      varchar2(800),
    nod_version_id                number(9, 0),
    nod_next_version_id           number(9, 0)
) 
tablespace users;


drop synonym nod;
create synonym nod for tctg_nod_node;

drop sequence qctg_nod_id;
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 cascade constraints;
create table tctg_noa_node_attributes
( 
    noa_company_id                number(9, 0),
    noa_spec_id                   number(9, 0),
    noa_node_id                   number(9, 0),
    noa_name                      varchar2(100),
    noa_value                     varchar2(3000),
    noa_order                     number(9, 0),
    noa_version_id                number(9, 0),
    noa_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_noh_node_hierarchy
( 
    noh_company_id                number(9, 0),
    noh_spec_id                   number(9, 0),
    noh_parent_node_id            number(9, 0),
    noh_child_node_id             number(9, 0),
    noh_order                     number(9, 0),
    noh_version_id                number(9, 0),
    noh_next_version_id           number(9, 0)
) 
tablespace users;


drop synonym noh;
create synonym noh for tctg_noh_node_hierarchy;

-- ===================================================================
--
-- 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 cascade constraints;
create table tctg_obm_object_map
( 
    obm_company_id                number(9, 0),
    obm_id                        number(9, 0),
    obm_name                      varchar2(256),
    obm_type                      varchar2(100),
    obm_src_object_id             number(9, 0),
    obm_dst_object_id             number(9, 0),
    obm_version_id                number(9, 0),
    obm_next_version_id           number(9, 0)
) 
tablespace users;


drop synonym obm;
create synonym obm for tctg_obm_object_map;

drop sequence qctg_obm_id;
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 cascade constraints;
create table tctg_omd_object_map_detail
( 
    omd_company_id                number(9, 0),
    omd_object_map_id             number(9, 0),
    omd_src_object_id             number(9, 0),
    omd_src_node_id               number(9, 0),
    omd_dst_object_id             number(9, 0),
    omd_dst_node_id               number(9, 0),
    omd_version_id                number(9, 0),
    omd_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_oms_object_map_scripts
( 
    oms_company_id                number(9, 0),
    oms_object_map_id             number(9, 0),
    oms_dst_object_id             number(9, 0),
    oms_dst_node_id               number(9, 0),
    oms_script_path               varchar2(4000),
    oms_version_id                number(9, 0),
    oms_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_ctm_categorization_map
( 
    ctm_company_id                number(9, 0),
    ctm_categmap_id               number(9, 0) not null,
    ctm_categmap_name             varchar2(300),
    ctm_filespec_id               number(9, 0),
    ctm_cattree_id                number(9, 0),
    ctm_deffile_attr              varchar2(300),
    ctm_object_group_id           number(9, 0),
    constraint ctm_0_pk
        primary key (ctm_categmap_id)
) 
tablespace users;


drop synonym ctm;
create synonym ctm for tctg_ctm_categorization_map;

drop sequence qctg_ctm_categmap_id;
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 cascade constraints;
create table tctg_cmd_categmap_detail
( 
    cmd_company_id                number(9, 0),
    cmd_categmap_id               number(9, 0),
    cmd_detail_id                 number(9, 0) not null,
    cmd_file_attr                 varchar2(300),
    cmd_isRegExp                  varchar2(5),
    cmd_expression                varchar2(300),
    constraint cmd_0_pk
        primary key (cmd_detail_id)
) 
tablespace users;


drop synonym cmd;
create synonym cmd for tctg_cmd_categmap_detail;

drop sequence qctg_cmd_detail_id;
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 cascade constraints;
create table tctg_cmc_categmap_categories
( 
    cmc_company_id                number(9, 0),
    cmc_detail_id                 number(9, 0),
    cmc_category_id               number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_cgm_catalog_catalog_map
( 
    cgm_company_id                number(9, 0),
    cgm_src_ctg_id                number(9, 0),
    cgm_src_node_id               number(9, 0),
    cgm_dst_ctg_id                number(9, 0),
    cgm_dst_node_id               number(9, 0),
    cgm_version_id                number(9, 0),
    cgm_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_seq_sequence
( 
    seq_company_id                number(9, 0),
    seq_object_id                 number(9, 0) not null,
    seq_object_type               varchar2(100) not null,
    seq_name                      varchar2(900) not null,
    seq_increment                 number(38, 0),
    seq_value                     number(38, 0),
    constraint seq_0_pk
        primary key (seq_object_id, seq_object_type, seq_name)
) 
tablespace users;


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 cascade constraints;
create table tctg_epr_entry_processor_run
( 
    epr_run_id                    number(9, 0),
    epr_company_id                number,
    epr_user_id                   number(9, 0),
    epr_type                      varchar2(128),
    epr_entry_cnt                 number(9, 0),
    epr_start_time                date,
    epr_completion_time           date,
    epr_digest                    varchar2(3000),
    epr_status                    char,
    epr_container_type            varchar2(128),
    epr_container_id              number(9, 0)
) 
tablespace users;


drop synonym epr;
create synonym epr for tctg_epr_entry_processor_run;

drop sequence qctg_epr_run_id;
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 cascade constraints;
create table tctg_rul_inheritance_rule
( 
    rul_company_id                number(9, 0) not null,
    rul_id                        number(9, 0),
    rul_name                      varchar2(900) not null,
    rul_src_ctg_id                number(9, 0),
    rul_src_ctr_id                number(9, 0),
    rul_collab_id                 number(9, 0) not null,
    rul_version_id                number(9, 0),
    rul_next_version_id           number(9, 0) not null,
    constraint rul_0_uk
        unique (rul_company_id, rul_name, rul_collab_id, rul_next_version_id)
) 
tablespace users;


drop synonym rul;
create synonym rul for tctg_rul_inheritance_rule;

drop sequence qctg_rul_id;
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 cascade constraints;
create table tctg_rgm_rul_group_map
( 
    rgm_company_id                number(9, 0),
    rgm_rule_id                   number(9, 0),
    rgm_attr_group_id             number(9, 0),
    rgm_version_id                number(9, 0),
    rgm_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_udl_user_defined_logs
( 
    udl_company_id                number(9, 0),
    udl_id                        number(9, 0),
    udl_name                      varchar2(3000),
    udl_container_id              number(9, 0),
    udl_container_type            varchar2(128),
    udl_description               varchar2(3000),
    udl_running_log               char,
    udl_table_name                varchar2(128)
) 
tablespace users;


drop synonym udl;
create synonym udl for tctg_udl_user_defined_logs;

drop sequence qctg_udl_id;
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_ cascade constraints;
create table tctg_ule_user_log_entry_
( 
    ule_log_entry_id              number(9, 0),
    ule_date                      date,
    ule_container_id              number(9, 0),
    ule_entry_id                  number(9, 0),
    ule_log                       varchar2(3000),
    ule_category_id               number(9, 0),
    ule_multi_row_order           number(9, 0)
) 
tablespace users;


drop synonym ule;
create synonym ule for tctg_ule_user_log_entry_;

drop sequence qctg_ule_log_entry_id;
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 cascade constraints;
create table tctg_tmt_test_multi_row
( 
    tmt_company_id                number(9, 0),
    tmt_catalog_id                number(9, 0),
    tmt_item_id                   number(9, 0),
    tmt_node_id                   number(9, 0),
    tmt_type                      varchar2(100),
    tmt_value_numeric             number(38, 8),
    tmt_value_string              varchar2(3000),
    tmt_value_date                date,
    tmt_version_id                number(9, 0),
    tmt_next_version_id           number(9, 0),
    tmt_order                     number(9, 0),
    tmt_parent_order              number(9, 0),
    tmt_row_order                 number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_etp_entry_tabbed_pane
( 
    etp_company_id                number(9, 0),
    etp_ctg_view_id               number(9, 0),
    etp_ctg_sub_view_id           number(9, 0),
    etp_tab_id                    number(9, 0),
    etp_tab_name                  varchar2(80),
    etp_tab_order                 number(9, 0),
    etp_container_type            varchar2(128),
    etp_container_id              number(9, 0)
) 
tablespace users;


drop synonym etp;
create synonym etp for tctg_etp_entry_tabbed_pane;

drop sequence qctg_etp_tab_id;
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 cascade constraints;
create table tctg_tpa_tabbed_pane_attr
( 
    tpa_company_id                number(9, 0),
    tpa_tab_id                    number(9, 0),
    tpa_attr_group_id             number(9, 0),
    tpa_order                     number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_ord_ordering
( 
    ord_company_id                number(9, 0),
    ord_id                        number(9, 0),
    ord_name                      varchar2(256),
    ord_catalog_id                number(9, 0),
    ord_cat_tree_id               number(9, 0)
) 
tablespace users;


drop synonym ord;
create synonym ord for tctg_ord_ordering;

drop sequence qctg_ord_id;
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 cascade constraints;
create table tctg_odd_ord_detail
( 
    odd_company_id                number(9, 0),
    odd_ord_id                    number(9, 0),
    odd_catalog_id                number(9, 0),
    odd_cat_tree_id               number(9, 0),
    odd_parent_id                 number(9, 0),
    odd_child_id                  number(9, 0),
    odd_type                      varchar2(100),
    odd_order                     number(9, 0),
    odd_version_id                number(9, 0),
    odd_next_version_id           number(9, 0)
) 
tablespace users;


drop synonym odd;
create synonym odd for tctg_odd_ord_detail;

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

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

drop table tctg_atg_attr_group cascade constraints;
create table tctg_atg_attr_group
( 
    atg_id                        number(9, 0) not null,
    atg_company_id                number(9, 0) not null,
    atg_name                      varchar2(140) not null,
    atg_type                      varchar2(100),
    atg_description               varchar2(3000),
    constraint atg_0_pk
        primary key (atg_id),
    constraint atg_1_uk
        unique (atg_company_id, atg_name)
) 
tablespace users;


drop synonym atg;
create synonym atg for tctg_atg_attr_group;

drop sequence qctg_atg_id;
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 cascade constraints;
create table tctg_agn_attr_group_node
( 
    agn_attr_group_id             number(9, 0) not null,
    agn_company_id                number(9, 0),
    agn_spec_id                   number(9, 0) not null,
    agn_node_id                   number(9, 0) not null,
    agn_included                  char,
    agn_version_id                number(9, 0),
    agn_next_version_id           number(9, 0) not null,
    constraint agn_0_uk
        unique (agn_attr_group_id, agn_spec_id, agn_node_id, agn_next_version_id)
) 
tablespace users;


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 cascade constraints;
create table tctg_agl_attr_group_locale
( 
    agl_attr_group_id             number(9, 0) not null,
    agl_company_id                number(9, 0),
    agl_locale                    varchar2(100) not null,
    agl_version_id                number(9, 0),
    agl_next_version_id           number(9, 0) not null,
    constraint agl_0_uk
        unique (agl_attr_group_id, agl_locale, agl_next_version_id)
) 
tablespace users;


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 cascade constraints;
create table tctg_agd_attr_group_dyn_node
( 
    agd_attr_group_id             number(9, 0) not null,
    agd_company_id                number(9, 0),
    agd_spec_id                   number(9, 0) not null,
    agd_node_id                   number(9, 0) not null,
    agd_version_id                number(9, 0),
    agd_next_version_id           number(9, 0) not null,
    constraint agd_0_uk
        unique (agd_attr_group_id, agd_spec_id, agd_node_id, agd_next_version_id)
) 
tablespace users;


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 cascade constraints;
create table tctg_sim_status_image_map
( 
    sim_company_id                number(9, 0),
    sim_object_container_id       number(9, 0),
    sim_object_type               varchar2(50),
    sim_status                    varchar2(300),
    sim_image_url                 varchar2(500)
) 
tablespace users;


drop synonym sim;
create synonym sim for tctg_sim_status_image_map;

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

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

drop table tctg_rec_relation_container cascade constraints;
create table tctg_rec_relation_container
( 
    rec_company_id                number(9, 0),
    rec_id                        number(9, 0) not null,
    rec_ctg_id                    number(9, 0) not null,
    rec_ctr_id                    number(9, 0) not null,
    constraint rec_0_pk
        primary key (rec_id),
    constraint rec_1_uk
        unique (rec_ctg_id, rec_ctr_id)
) 
tablespace users;


drop synonym rec;
create synonym rec for tctg_rec_relation_container;

drop sequence qctg_ctg_id;
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 cascade constraints;
create table tctg_rea_relation_attributes
( 
    rea_company_id                number(9, 0),
    rea_relation_id               number(9, 0),
    rea_name                      varchar2(100),
    rea_value                     varchar2(800),
    rea_version_id                number(9, 0),
    rea_next_version_id           number(9, 0)
) 
tablespace users;


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 cascade constraints;
create table tctg_esr_entry_search_result
( 
    esr_company_id                number(9, 0),
    esr_entry_id                  number(9, 0),
    esr_sel_id                    number(9, 0),
    esr_ctg_id                    number(9, 0),
    esr_data                      varchar2(3000),
    esr_row_order                 number(9, 0)
) 
tablespace users;


drop synonym esr;
create synonym esr for tctg_esr_entry_search_result;

insert into ver (ver_id) select qctg_ver_id.nextval from dual;
insert into ver (ver_id) select qctg_ver_id.nextval from dual;
insert into ver (ver_id) select qctg_ver_id.nextval from dual;
insert into ver (ver_id) select qctg_ver_id.nextval from dual;
drop sequence qctg_agg_aggregation_queue_seq;
create sequence qctg_agg_aggregation_queue_seq start with 1 increment by 1 nocache;
drop sequence qctg_lkp_updates;
create sequence qctg_lkp_updates start with 1 increment by 1 nocache;


