/*****************************************************************************
*
* Filename         - $user_trace.sql$
*
*                     Name              Date      Version     CR Number
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - TAGTRAK(Oracle database)
*
* Source Code
* Identifier       - 0/3/300/8010/112
*
* Design Spec
* Section          - 
*
* Contents         - Definition of the user_trace table.
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1998
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   user_trace.sql  $  $Revision:   1.3  $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:   /pvcsarch/db_ora/db/source/live/tables/user_trace.svl  $
* 
*    Rev 1.3   21 Jun 2001 14:48:28   tagtrak
* OR:
* CR:
* Re-baseline version 4.0.0 to include patches.
* 
*    Rev 1.2   04 Nov 1998 16:26:02   tagtrak
* OR: 12141
* CR: 12141
* REV:
* User login allows connection with invalid name/password
* User logout causes errors
* Andrew Walker
* (branch ATS revision copied to trunk.)
* Andrew Walker
* 
*    Rev 1.1.1.0   22 Oct 1998 14:46:18   tagtrak
* OR: 12141
* CR: 12141
* REV:
* User login allows connection with invalid name/password
* User logout causes errors
* Andrew Walker
* 
*    Rev 1.1   02 Apr 1998 19:44:00   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.0   26 Feb 1998 11:16:26   tagtrak
* OR:
* CR:
* REV:
* Initial core product version
*
****************************************************************************/


PROMPT Creating table USER_TRACE

create table user_trace (
   id                            number(10)   not null,
   insert_date                   date         not null,
   login_name                    char(15),
   kit_id                        number(10)   not null,
   trace_action                  varchar2(15) not null,
   error_id                      number(10)   default null,
   location_code                 char(6),
   airport_code                  char(3) not null,
   row_create_time               date,
   row_date_time                 date,
   cuser                         varchar2(30),
   muser                         varchar2(30),
   mterm                         varchar2(64),
   source                        varchar2(8),
   to_be_archived                varchar2(1),
   appn_row_id                   number(18) not null,
   system_id                     number(4) default 0 not null
);

alter table user_trace add ( constraint user_trace_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table user_trace add ( constraint user_trace_uk1 unique (id) using index tablespace &1._indexes);

alter table user_trace add ( constraint user_trace_fk_error foreign key (error_id) references error( error_id ));

alter table user_trace add ( constraint user_trace_fk_kit foreign key (kit_id) references kit( id ));

CREATE INDEX user_trace_sk1 ON user_trace(error_id) TABLESPACE &1._indexes;

CREATE INDEX user_trace_sk2 ON user_trace(kit_id) TABLESPACE &1._indexes;

COMMENT ON TABLE USER_TRACE IS 'This table contains trace information for user activities';

COMMENT ON COLUMN USER_TRACE.AIRPORT_CODE IS  'Airport code';
COMMENT ON COLUMN USER_TRACE.ERROR_ID IS  'Error identifier';
COMMENT ON COLUMN USER_TRACE.ID IS  'Identifier';
COMMENT ON COLUMN USER_TRACE.INSERT_DATE IS  'Date the row was inserted';
COMMENT ON COLUMN USER_TRACE.KIT_ID IS  'Kit identifier';
COMMENT ON COLUMN USER_TRACE.LOCATION_CODE IS  'Location code';
COMMENT ON COLUMN USER_TRACE.LOGIN_NAME IS  'Login name';
COMMENT ON COLUMN USER_TRACE.TRACE_ACTION IS  'Trace action';
COMMENT ON COLUMN USER_TRACE.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN USER_TRACE.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN USER_TRACE.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN USER_TRACE.CUSER IS 'The user who created the row';
COMMENT ON COLUMN USER_TRACE.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN USER_TRACE.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN USER_TRACE.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN USER_TRACE.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN USER_TRACE.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
