-- 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 tsec_scu_user
--
-- All users are kept in this table. Additional fields will be added
-- as needed. Currently only being used to support login and display
-- the users name. Also, the user's company is retrieved from this
-- table and the scu_company_id plays a critical role in all operations
-- in Trigo. The active field (Y/N) shows if the user is enabled or
-- disabled. An user can only login if the active field is 'Y'.
-- ===================================================================

drop table tsec_scu_user cascade constraints;
create table tsec_scu_user
( 
    scu_user_id                   number(9, 0) not null,
    scu_active                    char,
    scu_username                  varchar2(20) not null,
    scu_password                  varchar2(32),
    scu_first_name                varchar2(100),
    scu_last_name                 varchar2(100),
    scu_company_id                number(9, 0) not null,
    scu_user_phone                varchar2(20),
    scu_user_address              varchar2(200),
    scu_user_email                varchar2(40),
    scu_user_title                varchar2(40),
    scu_user_fax                  varchar2(20),
    scu_log_flag                  number(9,0),
    scu_notify_email              varchar2(40),
    constraint scu_0_pk
        primary key (scu_user_id),
    constraint scu_1_uk
        unique (scu_username, scu_company_id)
) 
tablespace users;


drop synonym scu;
create synonym scu for tsec_scu_user;

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

-- ===================================================================
--
-- Table tsec_ust_user_setting
--
-- The user settings is an add-on to the security infrastructure and does not deal with
-- authentication or authorization, but with default values, user preferences, etc.
-- ===================================================================

drop table tsec_ust_user_setting cascade constraints;
create table tsec_ust_user_setting
( 
    ust_company_id                number(9, 0),
    ust_user_id                   number(9, 0),
    ust_user_settable             char,
    ust_setting                   varchar2(100),
    ust_instance                  varchar2(100),
    ust_value                     varchar2(3000)
) 
tablespace users;


drop synonym ust;
create synonym ust for tsec_ust_user_setting;

-- ===================================================================
--
-- Table tsec_lot_login_times
--
-- This table contains information about successful logins and subsequent logouts for
-- users. Both the login and logout times are stored as well as the logout method, saved
-- in the field 'logout_method' which can currently hold the following values:
-- T - if a session timeout occurred
-- U - if the user manually logged out of the app
-- S - if some kind of system error occurred.
-- ===================================================================

drop table tsec_lot_login_times cascade constraints;
create table tsec_lot_login_times
( 
    lot_session_id                number(9, 0),
    lot_user_id                   number(9,0),
    lot_company_id                number(9, 0),
    lot_login_time                date,
    lot_logout_time               date,
    lot_logout_method             varchar2(1),
    lot_service_name              varchar2(100)
) 
tablespace users;


drop synonym lot;
create synonym lot for tsec_lot_login_times;

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

-- ===================================================================
--
-- Table tsec_cmp_company
--
-- All companies are kept in this table. This includes Trigo, all
-- marketplaces and Trigo customers.
-- The type is one of the following values:
-- 'T' Trigo
-- 'M' Marketplace
-- 'S' Supplier
-- We expect that the type will evolve since we would want to keep
-- track of the different e-commerce models that each marketplace
-- supports. We might also want to keep more information about the
-- supplier.
-- Also, the company_id is generated from two sequences so that
-- we can distinguish the company in other tables.
-- ===================================================================

drop table tsec_cmp_company cascade constraints;
create table tsec_cmp_company
( 
    cmp_company_id                number(9, 0) not null,
    cmp_company_name              varchar2(60),
    cmp_company_code              varchar2(20),
    cmp_company_type              char,
    cmp_directory                 varchar2(1000),
    cmp_company_url               varchar2(200),
    constraint cmp_0_pk
        primary key (cmp_company_id)
) 
tablespace users;


drop synonym cmp;
create synonym cmp for tsec_cmp_company;

-- ===================================================================
--
-- Table tsec_lnk_mylinks
--
-- User's personnal links are kept here. The lnk_link is a string
-- the should match one of the ids on the menu.xml file
-- ===================================================================

drop table tsec_lnk_mylinks cascade constraints;
create table tsec_lnk_mylinks
( 
    lnk_company_id                number(9, 0) not null,
    lnk_user_id                   number(9, 0) not null,
    lnk_link                      varchar2(200) not null,
    lnk_creation_date             date,
    constraint lnk_0_pk
        primary key (lnk_company_id, lnk_user_id, lnk_link)
) 
tablespace users;


drop synonym lnk;
create synonym lnk for tsec_lnk_mylinks;

-- ===================================================================
--
-- Table tsec_log_useractivity
--

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

drop table tsec_log_useractivity cascade constraints;
create table tsec_log_useractivity
( 
    log_user_id                   number(9,0),
    log_company_id                number(9, 0),
    log_page_id                   number(9, 0),
    log_date                      date
) 
tablespace users;


drop synonym log;
create synonym log for tsec_log_useractivity;

-- ===================================================================
--
-- Table tsec_oac_object_action
--
-- Object Actions may have company_type assigned to them, to reflect that
-- the actions on objects applies to all the companies of that type.
-- The Company type is one of the following values:
-- 'T' Trigo
-- 'M' Marketplace
-- 'S' Supplier
-- ===================================================================

drop table tsec_oac_object_action cascade constraints;
create table tsec_oac_object_action
( 
    oac_id                        number(9, 0) not null,
    oac_name                      varchar2(60),
    oac_desc                      varchar2(200),
    oac_object_type_id            number(9, 0),
    oac_company_type              char,
    oac_default_obg               char,
    constraint oac_0_pk
        primary key (oac_id)
) 
tablespace users;


drop synonym oac;
create synonym oac for tsec_oac_object_action;

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

-- ===================================================================
--
-- Table tsec_rol_role
--

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

drop table tsec_rol_role cascade constraints;
create table tsec_rol_role
( 
    rol_company_id                number(9, 0),
    rol_role_id                   number(9, 0) not null,
    rol_role_name                 varchar2(100),
    rol_role_desc                 varchar2(200),
    constraint rol_0_pk
        primary key (rol_role_id)
) 
tablespace users;


drop synonym rol;
create synonym rol for tsec_rol_role;

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

-- ===================================================================
--
-- Table tsec_rat_role_attributes
--

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

drop table tsec_rat_role_attributes cascade constraints;
create table tsec_rat_role_attributes
( 
    rat_company_id                number(9, 0),
    rat_role_id                   number(9, 0),
    rat_name                      varchar2(100),
    rat_attr_value                varchar2(3000),
    rat_row_order                 number(9, 0)
) 
tablespace users;


drop synonym rat;
create synonym rat for tsec_rat_role_attributes;

-- ===================================================================
--
-- Table tsec_urm_user_role_map
--

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

drop table tsec_urm_user_role_map cascade constraints;
create table tsec_urm_user_role_map
( 
    urm_company_id                number(9, 0),
    urm_user_id                   number(9, 0),
    urm_role_id                   number(9, 0),
    urm_role_request_flag         char
) 
tablespace users;


drop synonym urm;
create synonym urm for tsec_urm_user_role_map;

-- ===================================================================
--
-- Table tsec_obt_object_type
--

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

drop table tsec_obt_object_type cascade constraints;
create table tsec_obt_object_type
( 
    obt_id                        number(9, 0),
    obt_name                      varchar2(60),
    obt_desc                      varchar2(200),
    obt_default_obg               char
) 
tablespace users;


drop synonym obt;
create synonym obt for tsec_obt_object_type;

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

-- ===================================================================
--
-- Table tsec_cot_company_attrib
--
-- This table stores attributes of a company
-- ===================================================================

drop table tsec_cot_company_attrib cascade constraints;
create table tsec_cot_company_attrib
( 
    cot_company_id                number(10, 0),
    cot_attrib_name               varchar2(100),
    cot_attrib_value              varchar2(3000)
) 
tablespace users;


drop synonym cot;
create synonym cot for tsec_cot_company_attrib;

-- ===================================================================
--
-- Table tsec_cap_ctg_access_prv
--
-- This table stores catalog access for each node of a catalog 1:view 0:noview
-- ===================================================================

drop table tsec_cap_ctg_access_prv cascade constraints;
create table tsec_cap_ctg_access_prv
( 
    cap_company_id                number(9, 0),
    cap_cap_id                    number(9, 0) not null,
    cap_attr_group_id             number(9, 0) not null,
    cap_viewable                  char,
    constraint cap_0_uk
        unique (cap_cap_id, cap_attr_group_id)
) 
tablespace users;


drop synonym cap;
create synonym cap for tsec_cap_ctg_access_prv;

-- ===================================================================
--
-- Table tsec_cma_cap_role_object_map
--
-- This table stores the objects/role combinations for which ctg access privileges
-- are enabled.
-- ===================================================================

drop table tsec_cma_cap_role_object_map cascade constraints;
create table tsec_cma_cap_role_object_map
( 
    cma_company_id                number(9, 0),
    cma_role_id                   number(9, 0) not null,
    cma_object_id                 number(9, 0) not null,
    cma_object_type               varchar2(100) not null,
    cma_cap_id                    number(9, 0) not null,
    constraint cma_0_pk
        primary key (cma_role_id, cma_object_id, cma_object_type),
    constraint cma_1_uk
        unique (cma_cap_id)
) 
tablespace users;


drop synonym cma;
create synonym cma for tsec_cma_cap_role_object_map;

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

-- ===================================================================
--
-- Table tsec_cvd_ctg_view_detail
--
-- This table stores the details of a catalog view for each attribute group of a catalog 1:view 0:noview
-- ===================================================================

drop table tsec_cvd_ctg_view_detail cascade constraints;
create table tsec_cvd_ctg_view_detail
( 
    cvd_company_id                number(9, 0),
    cvd_view_id                   number(9, 0),
    cvd_attr_group_id             number(9, 0),
    cvd_sub_view_type             varchar2(100),
    cvd_sub_view_id               number(9, 0),
    cvd_viewable                  char,
    cvd_order                     number(9, 0)
) 
tablespace users;


drop synonym cvd;
create synonym cvd for tsec_cvd_ctg_view_detail;

-- ===================================================================
--
-- Table tsec_cvi_ctg_view
--
-- This table stores the list of catalog views
-- ===================================================================

drop table tsec_cvi_ctg_view cascade constraints;
create table tsec_cvi_ctg_view
( 
    cvi_company_id                number(9, 0) not null,
    cvi_object_id                 number(9, 0) not null,
    cvi_object_type               varchar2(100) not null,
    cvi_view_name                 varchar2(256) not null,
    cvi_view_id                   number(9, 0),
    constraint cvi_0_uk
        unique (cvi_company_id, cvi_object_id, cvi_object_type, cvi_view_name)
) 
tablespace users;


drop synonym cvi;
create synonym cvi for tsec_cvi_ctg_view;

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

-- ===================================================================
--
-- Table tsec_cdu_default_view_user
--
-- This table stores the default views for each user
-- ===================================================================

drop table tsec_cdu_default_view_user cascade constraints;
create table tsec_cdu_default_view_user
( 
    cdu_company_id                number(9, 0) not null,
    cdu_user_id                   number(9, 0) not null,
    cdu_object_id                 number(9, 0) not null,
    cdu_object_type               varchar2(900) not null,
    cdu_view_id                   number(9, 0),
    constraint cdu_0_uk
        unique (cdu_company_id, cdu_user_id, cdu_object_id, cdu_object_type)
) 
tablespace users;


drop synonym cdu;
create synonym cdu for tsec_cdu_default_view_user;

-- ===================================================================
--
-- Table tsec_obg_object_group
--

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

drop table tsec_obg_object_group cascade constraints;
create table tsec_obg_object_group
( 
    obg_company_id                number(9, 0),
    obg_id                        number(9, 0) not null,
    obg_name                      varchar2(100),
    obg_description               varchar2(200),
    constraint obg_0_pk
        primary key (obg_id)
) 
tablespace users;


drop synonym obg;
create synonym obg for tsec_obg_object_group;

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

-- ===================================================================
--
-- Table tsec_ogm_object_group_map
--

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

drop table tsec_ogm_object_group_map cascade constraints;
create table tsec_ogm_object_group_map
( 
    ogm_company_id                number(9, 0),
    ogm_object_group_id           number(9, 0),
    ogm_object_type_id            number(9, 0)
) 
tablespace users;


drop synonym ogm;
create synonym ogm for tsec_ogm_object_group_map;

-- ===================================================================
--
-- Table tsec_orm_object_group_role_map
--
-- 'access' is a bitmap of all the object actions in the system. 'access_order' determines the order of the
-- 'access' sequence for a whole list of actions for a role. This helps to have an unlimited
-- size for the actions bitmap 'access' using 'access_order' (similar to a multi-dimensional array).
-- However, in the object_group_role_map table, 'access' only has the bits corresponding to the
-- actions of the current object_group active!
-- ===================================================================

drop table tsec_orm_object_group_role_map cascade constraints;
create table tsec_orm_object_group_role_map
( 
    orm_company_id                number(9, 0),
    orm_object_group_id           number(9, 0),
    orm_role_id                   number(9, 0),
    orm_access                    varchar2(4000),
    orm_access_order              number(9, 0)
) 
tablespace users;


drop synonym orm;
create synonym orm for tsec_orm_object_group_role_map;

-- ===================================================================
--
-- Table tsec_rsm_role_to_script_map
--
-- Tables that maps role id to script names that the particular role has access to.
-- ===================================================================

drop table tsec_rsm_role_to_script_map cascade constraints;
create table tsec_rsm_role_to_script_map
( 
    rsm_company_id                number(9, 0),
    rsm_role_id                   number(9, 0),
    rsm_script_name               varchar2(500)
) 
tablespace users;


drop synonym rsm;
create synonym rsm for tsec_rsm_role_to_script_map;

drop sequence qsec_cmp_mkt_company_id;
create sequence qsec_cmp_mkt_company_id start with 101 increment by 1 nocache;
drop sequence qsec_cmp_sup_company_id;
create sequence qsec_cmp_sup_company_id start with 1 increment by 1 nocache;


