/*****************************************************************************
*
* Filename         - $Workfile:   inbound_term_bag_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 inbound_term_bag_trace table
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2007
*
*****************************************************************************/

PROMPT Creating table INBOUND_TERM_BAG_TRACE

create table INBOUND_TERM_BAG_TRACE (
   SITE_ID                       NUMBER(10) not null,
   FLIGHT_NO                     CHAR(8) not null,
   FLIGHT_DATE                   CHAR(5) not null,
   BAG_TAG                       CHAR(10) not null,
   LOCATION                      CHAR(6) not null,
   USER_ID                       NUMBER(10) not null,
   SCAN_TIME                     DATE 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 inbound_term_bag_trace add (constraint inbound_term_bag_trace_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table inbound_term_bag_trace
  add constraint inbound_term_bag_trace_fk_uid foreign key (user_id)
  references TAGTRAK_USERS (User_id);
alter table inbound_term_bag_trace
  add constraint inbound_term_bag_fk_loc foreign key (location)
  references location (location_code);
alter table inbound_term_bag_trace
  add constraint inbound_term_bag_trace_fk_sid foreign key (site_id)
  references site_info (site_id);


COMMENT ON TABLE INBOUND_TERM_BAG_TRACE IS 'This table contains details of bags from incoming flights that have been scanned';

COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.SITE_ID IS  'Site id';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.FLIGHT_NO IS  'Flight number';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.FLIGHT_DATE IS  'Flight date';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.BAG_TAG IS  'Bag tag of the inbound terminating bag';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.LOCATION IS  'Scan location';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.USER_ID IS  'User ID of person performing scan';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.SCAN_TIME IS  'Scan time';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.CUSER IS 'The user who created the row';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN INBOUND_TERM_BAG_TRACE.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';

/

