/*****************************************************************************
*
* Filename         - $Workfile:   uld_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         - Live Schema: uld_trace table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   uld_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/uld_trace.svl  $
 * 
 *    Rev 1.3   06 Jun 2000 09:53:32   tagtrak
 *  
 * 
 *    Rev 1.2.1.2   10 Jun 1999 14:51:52   tagtrak
 * OR:
 * CR: 14043
 * REV:
 * Changed Archive and Backup so that the database
 * can be accessed during the eraseLive function.
 * 
 * Neil Bishop.
 * 
 *    Rev 1.2   02 Apr 1998 19:43:54   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial Issue
 * See label for concession
 * 
 *    Rev 1.1   26 Feb 1998 11:08:30   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial core product version
 * 
 *    Rev 1.0   22 Oct 1997 11:08:24   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial check-in
*
****************************************************************************/

PROMPT Creating table ULD_TRACE

create table ULD_TRACE (
   ULD_NO                        char(10) NOT NULL,
   ULD_TRACE_TIME                date NOT NULL,
   USER_ID                       number(10) NOT NULL,
   ULD_LOCATION_CODE             char(8) NOT NULL,
   SCANNER_ID                    char(6) NOT NULL,
   RECORD_ID                     number(10) NOT NULL,
   FLIGHT_ID                     number(10) NULL,
   trace_action                  char(10),
   flight_no                     char(8),
   flight_date                   char(5),
   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 uld_trace add ( constraint uld_trace_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table uld_trace add ( constraint uld_trace_fk_flight foreign key (flight_id) references flight (flight_id) on delete cascade);

alter table uld_trace add ( constraint uld_trace_fk_tagtrak_users foreign key (user_id) references tagtrak_users (user_id));

create index ULD_TRACE_SK1 on ULD_TRACE(ULD_NO) tablespace &1._indexes;
 
create index ULD_TRACE_SK2 on ULD_TRACE(RECORD_ID) tablespace &1._indexes;
 
create index ULD_TRACE_SK3 on ULD_TRACE(ULD_TRACE_TIME) tablespace &1._indexes;

create index uld_trace_sk4 on uld_trace(flight_id) tablespace &1._indexes;

CREATE INDEX uld_trace_sk5 ON uld_trace(user_id) TABLESPACE &1._indexes;

COMMENT ON TABLE ULD_TRACE IS 'This table contains ULD trace information ';

COMMENT ON COLUMN ULD_TRACE.AIRPORT_CODE IS  'Airport code';
COMMENT ON COLUMN ULD_TRACE.FLIGHT_DATE IS  'Flight date';
COMMENT ON COLUMN ULD_TRACE.FLIGHT_ID IS  'Flight identifier';
COMMENT ON COLUMN ULD_TRACE.FLIGHT_NO IS  'Flight number';
COMMENT ON COLUMN ULD_TRACE.RECORD_ID IS  'Record identifier';
COMMENT ON COLUMN ULD_TRACE.SCANNER_ID IS  'Scanner identifier';
COMMENT ON COLUMN ULD_TRACE.TRACE_ACTION IS  'Trace action';
COMMENT ON COLUMN ULD_TRACE.ULD_LOCATION_CODE IS  'ULD location code';
COMMENT ON COLUMN ULD_TRACE.ULD_NO IS  'ULD number';
COMMENT ON COLUMN ULD_TRACE.ULD_TRACE_TIME IS  'Time of this trace entry';
COMMENT ON COLUMN ULD_TRACE.USER_ID IS  'User identifier';
COMMENT ON COLUMN ULD_TRACE.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN ULD_TRACE.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN ULD_TRACE.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN ULD_TRACE.CUSER IS 'The user who created the row';
COMMENT ON COLUMN ULD_TRACE.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN ULD_TRACE.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN ULD_TRACE.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN ULD_TRACE.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN ULD_TRACE.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
