-- Licensed Materials - Property of IBM
-- 5724-I68
--
-- (C) Copyright IBM Corp. 2000, 2006
--
-- 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 tcnt_sen_selected_entry
--
-- Contains the mapping of items  and selection_id.
-- ===================================================================

drop table tcnt_sen_selected_entry;
create table tcnt_sen_selected_entry
( 
    sen_company_id                bigint,
    sen_selection_id              bigint,
    sen_src_container_id          bigint,
    sen_selected_container_id     bigint,
    sen_entry_id                  bigint,
    sen_get_children              varchar(80)
) 

in users index in indx;


drop synonym sen;
create synonym sen for tcnt_sen_selected_entry;

-- ===================================================================
--
-- Table tcnt_cnt_container
--
-- A container has attributes as described in the tcnt_cna_container_attributes table (cna).
-- A company has many cotainer.
-- A container name is unique to a company for a given type.  This is enforced.
-- A container id is unique.  This is enforced.
-- ===================================================================

drop table tcnt_cnt_container;
create table tcnt_cnt_container
( 
    cnt_company_id                bigint,
    cnt_id                        bigint,
    cnt_name                      varchar(100),
    cnt_type                      varchar(100),
    cnt_object_group_id           bigint,
    cnt_container_type            varchar(128)
) 

in users index in indx;


drop synonym cnt;
create synonym cnt for tcnt_cnt_container;

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

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

drop table tcnt_cna_container_attributes;
create table tcnt_cna_container_attributes
( 
    cna_company_id                bigint,
    cna_container_id              bigint,
    cna_name                      varchar(100),
    cna_value                     varchar(800),
    cna_version_id                bigint,
    cna_next_version_id           bigint
) 

in users index in indx;


drop synonym cna;
create synonym cna for tcnt_cna_container_attributes;

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

drop table tcnt_ent_entry;
create table tcnt_ent_entry
( 
    ent_company_id                bigint,
    ent_id                        bigint,
    ent_container_id              bigint not null,
    ent_primary_key               varchar(300) not null,
    ent_version_id                bigint,
    ent_next_version_id           bigint not null,
    ent_status                    varchar(300),
    ent_collab_info               varchar(3000),
    ent_entry_type                varchar(128),
    constraint ent_1_uk
        unique (ent_container_id, ent_primary_key, ent_next_version_id)
) 

in users index in indx;


drop synonym ent;
create synonym ent for tcnt_ent_entry;

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

-- ===================================================================
--
-- Table tcnt_eta_entry_attributes
--
-- Table holding name value pairs for entry 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 tcnt_eta_entry_attributes;
create table tcnt_eta_entry_attributes
( 
    eta_company_id                bigint,
    eta_container_id              bigint,
    eta_entry_id                  bigint,
    eta_node_id                   bigint,
    eta_value_numeric             decimal(31, 12),
    eta_value_string              varchar(900),
    eta_version_id                bigint,
    eta_next_version_id           bigint
) 

in users index in indx;


drop synonym eta;
create synonym eta for tcnt_eta_entry_attributes;

-- ===================================================================
--
-- Table tcnt_esa_entry_sys_attr
--
-- Table holding the system (internal use only) attributes of a category -- name and value.
-- NOTE: CHANGED VALUE COLUMN LENGTH TO 850 TO REDUCE THE SIZE OF THE INDEX - DB2
-- ===================================================================

drop table tcnt_esa_entry_sys_attr;
create table tcnt_esa_entry_sys_attr
( 
    esa_company_id                bigint,
    esa_container_id              bigint,
    esa_entry_id                  bigint,
    esa_name                      varchar(100),
    esa_value                     varchar(850),
    esa_version_id                bigint,
    esa_next_version_id           bigint
) 

in users index in indx;


drop synonym esa;
create synonym esa for tcnt_esa_entry_sys_attr;

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

drop table tcnt_esm_entry_spec_map;
create table tcnt_esm_entry_spec_map
( 
    esm_company_id                bigint,
    esm_container_id              bigint,
    esm_entry_id                  bigint,
    esm_spec_id                   bigint,
    esm_filter_container_id       bigint,
    esm_version_id                bigint,
    esm_next_version_id           bigint
) 

in users index in indx;


drop synonym esm;
create synonym esm for tcnt_esm_entry_spec_map;

-- ===================================================================
--
-- Table tcnt_efp_entry_full_paths
--
-- Table holding the full paths of an entry
-- Patrice & Saad: This should never be queried by anyone other than the search dynamic queries
-- ===================================================================

drop table tcnt_efp_entry_full_paths;
create table tcnt_efp_entry_full_paths
( 
    efp_company_id                bigint,
    efp_container_id              bigint not null,
    efp_entry_id                  bigint,
    efp_full_path_type            varchar(100) not null,
    efp_full_path                 varchar(850) not null,
    efp_version_id                bigint,
    efp_next_version_id           bigint not null,
    constraint efp_0_uk
        unique (efp_container_id, efp_full_path_type, efp_full_path, efp_next_version_id)
) 

in users index in indx;


drop synonym efp;
create synonym efp for tcnt_efp_entry_full_paths;

-- ===================================================================
--
-- Table tcnt_ehi_entry_hierarchy
--

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

drop table tcnt_ehi_entry_hierarchy;
create table tcnt_ehi_entry_hierarchy
( 
    ehi_company_id                bigint,
    ehi_container_id              bigint,
    ehi_container_type            varchar(100),
    ehi_parent_id                 bigint,
    ehi_child_id                  bigint,
    ehi_version_id                bigint,
    ehi_next_version_id           bigint
) 

in users index in indx;


drop synonym ehi;
create synonym ehi for tcnt_ehi_entry_hierarchy;

-- ===================================================================
--
-- Table tcnt_eem_entry_entry_map
--
-- Mapping between a source and a destination entry..
-- ===================================================================

drop table tcnt_eem_entry_entry_map;
create table tcnt_eem_entry_entry_map
( 
    eem_company_id                bigint,
    eem_src_entry_id              bigint,
    eem_src_container_id          bigint,
    eem_dst_entry_id              bigint,
    eem_dst_container_id          bigint,
    eem_version_id                bigint,
    eem_next_version_id           bigint,
    eem_map_type                  varchar(300)
) 

in users index in indx;


drop synonym eem;
create synonym eem for tcnt_eem_entry_entry_map;

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;

commit;

update command options using c on;

terminate;